Mythus commited on
Commit
33c8d8d
·
verified ·
1 Parent(s): 86ef224

Create lordchannel.py

Browse files
Files changed (1) hide show
  1. lordchannel.py +82 -0
lordchannel.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tmdbv3api import TMDb, Movie, TV
2
+ import requests
3
+ import logging
4
+ from bs4 import BeautifulSoup,SoupStrainer
5
+ from datetime import datetime
6
+ import dateparser
7
+ from convert import get_TMDb_id_from_IMDb_id
8
+ from info import get_info_tmdb, is_movie, get_info_imdb
9
+ import config
10
+ import re
11
+ LC_DOMAIN = config.LC_DOMAIN
12
+ def search(query,date,season,episode,ismovie):
13
+ response = requests.get(query)
14
+ soup = BeautifulSoup(response.text,"lxml")
15
+ cards = soup.find_all('div', class_='col-6 col-sm-4 col-lg-3 col-xl-3')
16
+ for card in cards:
17
+ a_tag = card.find('a', class_='card__play')
18
+ if a_tag is not None: # check if the a_tag exists
19
+ href = a_tag['href']
20
+ link = f'https://lordchannel.{LC_DOMAIN}{href}'
21
+ response = requests.get(link)
22
+ soup2 = BeautifulSoup(response.text,'lxml')
23
+ li_tag = soup2.select_one("ul.card__meta li:nth-of-type(2)")
24
+ if li_tag is not None: # check if the li_tag exists
25
+ card_date = li_tag.text[-4:]
26
+ if card_date == date:
27
+ quality = soup2.select('ul.card__list li')[0].text
28
+ if ismovie == 1:
29
+ video_url = soup2.find('a', class_="btn-streaming streaming_btn")
30
+ video_url = video_url['href']
31
+ return video_url,quality
32
+ elif ismovie == 0:
33
+ div = soup2.find('div', id=f'collapse{season}')
34
+ episode = episode -1 #Index start from 0 so I need to subtract 1
35
+ episode = div.select('tr')[2] # index is 2 because we want the correct element
36
+ video_url = href = episode.find('a').get('href')
37
+ return video_url,quality
38
+ else:
39
+ print("Sadly date are not equals")
40
+ continue
41
+
42
+ def get_m3u8(video_url):
43
+ response = requests.get(video_url)
44
+ pattern = r'const videoData = \[(.*?)\];'
45
+ match = re.search(pattern, response.text)
46
+
47
+ if match:
48
+ video_data = match.group(1).strip().split(', ')
49
+ url = video_data[0]
50
+ return url
51
+
52
+ def lordchannel(imdb):
53
+ try:
54
+ general = is_movie(imdb)
55
+ ismovie = general[0]
56
+ imdb_id = general[1]
57
+ type = "LordChannel"
58
+ if ismovie == 0:
59
+ season = int(general[2])
60
+ episode = int(general[3])
61
+ if "tt" in imdb:
62
+ tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
63
+ else:
64
+ tmdba = imdb_id
65
+ else:
66
+ season = None
67
+ episode = None
68
+ if "tt" in imdb:
69
+ tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
70
+ else:
71
+ tmdba = imdb_id
72
+ showname,date = get_info_tmdb(tmdba,ismovie,type)
73
+ showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
74
+ query = f'https://lordchannel.{LC_DOMAIN}/cerca/?q={showname}'
75
+ video_url,quality = search(query,date,season,episode,ismovie)
76
+ url = get_m3u8(video_url)
77
+ url = url.replace('"','')
78
+ print(url)
79
+ return url,quality
80
+ except:
81
+ print("Lordchannel Failed")
82
+ return None,None