Added async support
This commit is contained in:
+40
-40
@@ -12,15 +12,15 @@ env_vars = load_env()
|
||||
PROXY_CREDENTIALS = env_vars.get('PROXY_CREDENTIALS')
|
||||
|
||||
|
||||
def search(showname,ismovie,date):
|
||||
async def search(showname,ismovie,date,client):
|
||||
url = f'https://www.tanti.{TF_DOMAIN}/search/{showname}'
|
||||
response = requests.get(url)
|
||||
response = await client.get(url, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, "lxml")
|
||||
if ismovie == 1:
|
||||
all_link = soup.select('#movies .col .list-media')
|
||||
for link in all_link:
|
||||
url = link['href']
|
||||
response = requests.get(url)
|
||||
response = client.get(url, follow_redirects=True)
|
||||
pattern = r'Data di rilascio\s*</div>\s*<div class="text">\s*(\d{4})\s*</div>'
|
||||
found_date = re.search(pattern, response.text)
|
||||
release_date = str(found_date.group(1))
|
||||
@@ -34,7 +34,7 @@ def search(showname,ismovie,date):
|
||||
for link in all_link:
|
||||
base_url = link['href']
|
||||
url = f'{base_url}-1-season-1-episode'
|
||||
response = requests.get(url)
|
||||
response = await client.get(url, follow_redirects=True)
|
||||
pattern = r'Data di rilascio\s*</div>\s*<div class="text">\s*(\d{4})\s*</div>'
|
||||
found_date = re.search(pattern, response.text)
|
||||
release_date = str(found_date.group(1))
|
||||
@@ -46,9 +46,9 @@ def search(showname,ismovie,date):
|
||||
#I try to get doodstream link inside this function so I do not have to get again the response
|
||||
return url,embed_id
|
||||
|
||||
def fast_search(showname,ismovie):
|
||||
async def fast_search(showname,ismovie,client):
|
||||
url = f'https://www.tanti.{TF_DOMAIN}/search/{showname}'
|
||||
response = requests.get(url)
|
||||
response = await client.get(url, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, "lxml")
|
||||
if ismovie == 1:
|
||||
first_link = soup.select_one('#movies .col .list-media')
|
||||
@@ -59,7 +59,7 @@ def fast_search(showname,ismovie):
|
||||
first_link = soup.select_one('#series .col .list-media')
|
||||
base_url = first_link['href']
|
||||
url = f'{base_url}-1-season-1-episode'
|
||||
response = requests.get(url)
|
||||
response = await client.get(url, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, 'lxml')
|
||||
a_tag = soup.find('a', class_='dropdown-toggle btn-service selected')
|
||||
embed_id = a_tag['data-embed']
|
||||
@@ -67,16 +67,16 @@ def fast_search(showname,ismovie):
|
||||
|
||||
|
||||
|
||||
def get_protect_link(id,url):
|
||||
async def get_protect_link(id,url,client):
|
||||
#Get the link where the Iframe is located, which contains the doodstream url kind of.
|
||||
response = requests.get(f"https://p.hdplayer.casa/myadmin/play.php?id={id}")
|
||||
response = await client.get(f"https://p.hdplayer.casa/myadmin/play.php?id={id}", follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, "lxml", parse_only=SoupStrainer('iframe'))
|
||||
protect_link = soup.iframe['src']
|
||||
if "protect" in protect_link:
|
||||
return protect_link
|
||||
else:
|
||||
#DO this in case the movie has a 3D version etc
|
||||
response = requests.get(url)
|
||||
response = await client.get(url, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, 'lxml')
|
||||
a_tag = soup.find('a', class_='dropdown-toggle btn-service selected')
|
||||
embed_id = a_tag['data-embed']
|
||||
@@ -89,9 +89,9 @@ def get_protect_link(id,url):
|
||||
'id': embed_id
|
||||
}
|
||||
ajax_url = f"https://www.tanti.{TF_DOMAIN}/ajax/embed"
|
||||
response = requests.post(ajax_url, headers=headers, data=data)
|
||||
response = await client.post(ajax_url, headers=headers, data=data)
|
||||
hdplayer = response.text[43:-27]
|
||||
response = requests.get(hdplayer)
|
||||
response = await client.get(hdplayer, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, 'lxml')
|
||||
links_dict = {}
|
||||
li_tags = soup.select('ul.nav.navbar-nav li.dropdown')
|
||||
@@ -103,7 +103,7 @@ def get_protect_link(id,url):
|
||||
if title == "1" or "Tantifilm" in title:
|
||||
continue # Get the text of the <a> tag
|
||||
href = a_tag['href']
|
||||
response = requests.get(href)
|
||||
response = await client.get(href, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, "lxml", parse_only=SoupStrainer('iframe'))
|
||||
protect_link = soup.iframe['src']
|
||||
if "protect" in protect_link:
|
||||
@@ -113,7 +113,7 @@ def get_protect_link(id,url):
|
||||
# Get the value of the href attribute
|
||||
|
||||
|
||||
def get_nuovo_indirizzo_and_protect_link(url,embed_id,season,episode):
|
||||
async def get_nuovo_indirizzo_and_protect_link(url,embed_id,season,episode,client):
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
||||
'Referer': url
|
||||
@@ -123,21 +123,21 @@ def get_nuovo_indirizzo_and_protect_link(url,embed_id,season,episode):
|
||||
'id': embed_id
|
||||
}
|
||||
ajax_url = f"https://www.tanti.{TF_DOMAIN}/ajax/embed"
|
||||
response = requests.post(ajax_url, headers=headers, data=data)
|
||||
response = await client.post(ajax_url, headers=headers, data=data)
|
||||
nuovo_indirizzo = response.text[43:-27]
|
||||
response = requests.get(nuovo_indirizzo)
|
||||
response = await client.get(nuovo_indirizzo, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, 'lxml')
|
||||
#Get season
|
||||
season = season - 1
|
||||
li_tags = soup.select('ul.nav.navbar-nav > li.dropdown')
|
||||
if len(li_tags) != 1:
|
||||
link = li_tags[season].find('a')['href']
|
||||
response = requests.get(link)
|
||||
response = await client.get(link, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, 'lxml')
|
||||
option_tag = soup.select(f'select[name="ep_select"] > option:nth-of-type({episode})')[0]
|
||||
link = option_tag['value']
|
||||
#Let's find protect link now
|
||||
response = requests.get(link)
|
||||
response = await client.get(link, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, "lxml", parse_only=SoupStrainer('iframe'))
|
||||
protect_link = soup.iframe['src']
|
||||
return protect_link
|
||||
@@ -147,13 +147,13 @@ def get_nuovo_indirizzo_and_protect_link(url,embed_id,season,episode):
|
||||
option_tag = soup.select('select.dynamic_select > option')[episode]
|
||||
link = option_tag['value']
|
||||
#Let's find protect link now
|
||||
response = requests.get(link)
|
||||
response = await client.get(link, follow_redirects=True)
|
||||
soup = BeautifulSoup(response.text, "lxml", parse_only=SoupStrainer('iframe'))
|
||||
protect_link = soup.iframe['src']
|
||||
return protect_link
|
||||
|
||||
|
||||
def true_url(protect_link):
|
||||
async def true_url(protect_link,client):
|
||||
print(protect_link)
|
||||
# Define headers
|
||||
headers = {
|
||||
@@ -166,9 +166,9 @@ def true_url(protect_link):
|
||||
"http": proxy,
|
||||
"https": proxy
|
||||
}
|
||||
response = requests.get(protect_link, proxies=proxies)
|
||||
response = await client.get(protect_link, proxies=proxies, follow_redirects=True)
|
||||
else:
|
||||
response = requests.get(protect_link)
|
||||
response = await client.get(protect_link, follow_redirects=True)
|
||||
link = response.url
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ def true_url(protect_link):
|
||||
# Create real link (match[0] includes all matched elements)
|
||||
url =f'https://d000d.com{match[1]}'
|
||||
print("MD5: ", url)
|
||||
rebobo = requests.get(url, headers=headers)
|
||||
rebobo = await client.get(url, headers=headers, follow_redirects=True)
|
||||
real_url = f'{rebobo.text}123456789{match[2]}{real_time}'
|
||||
print(real_url)
|
||||
return real_url
|
||||
@@ -201,7 +201,7 @@ def true_url(protect_link):
|
||||
|
||||
|
||||
#Get temporaly ID
|
||||
def tantifilm(imdb):
|
||||
async def tantifilm(imdb,client):
|
||||
urls = None
|
||||
try:
|
||||
general = is_movie(imdb)
|
||||
@@ -213,44 +213,44 @@ def tantifilm(imdb):
|
||||
episode = int(general[3])
|
||||
if "tt" in imdb:
|
||||
if TF_FAST_SEARCH == "0":
|
||||
showname,date = get_info_imdb(imdb_id,ismovie,type)
|
||||
url,embed_id = search(showname,ismovie,date)
|
||||
showname,date = await get_info_imdb(imdb_id,ismovie,type,client)
|
||||
url,embed_id = await search(showname,ismovie,date,client)
|
||||
elif TF_FAST_SEARCH == "1":
|
||||
showname = get_info_imdb(imdb_id,ismovie,type)
|
||||
url,embed_id = fast_search(showname,ismovie)
|
||||
showname = await get_info_imdb(imdb_id,ismovie,type,client)
|
||||
url,embed_id = await fast_search(showname,ismovie,client)
|
||||
else:
|
||||
#else just equals them
|
||||
tmdba = imdb_id.replace("tmdb:","")
|
||||
if TF_FAST_SEARCH == "0":
|
||||
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
||||
url,embed_id = search(showname,ismovie,date)
|
||||
url,embed_id = await search(showname,ismovie,date,client)
|
||||
elif TF_FAST_SEARCH == "1":
|
||||
showname= get_info_tmdb(tmdba,ismovie,type)
|
||||
url,embed_id = fast_search(showname,ismovie)
|
||||
protect_link = get_nuovo_indirizzo_and_protect_link(url,embed_id,season,episode)
|
||||
url = true_url(protect_link)
|
||||
url,embed_id = await fast_search(showname,ismovie,client)
|
||||
protect_link = await get_nuovo_indirizzo_and_protect_link(url,embed_id,season,episode,client)
|
||||
url = await true_url(protect_link,client)
|
||||
return url
|
||||
elif ismovie == 1:
|
||||
if "tt" in imdb:
|
||||
#Get showname
|
||||
if TF_FAST_SEARCH == "0":
|
||||
showname,date = get_info_imdb(imdb_id,ismovie,type)
|
||||
tid,url = search(showname,ismovie,date)
|
||||
showname,date = await get_info_imdb(imdb_id,ismovie,type,client)
|
||||
tid,url = await search(showname,ismovie,date,client)
|
||||
elif TF_FAST_SEARCH == "1":
|
||||
showname = get_info_imdb(imdb_id,ismovie,type)
|
||||
showname = await get_info_imdb(imdb_id,ismovie,type,client)
|
||||
date = None
|
||||
tid,url = fast_search(showname,ismovie)
|
||||
tid,url = await fast_search(showname,ismovie,client)
|
||||
else:
|
||||
|
||||
#else just equals themtantifilm("tt2096673")
|
||||
|
||||
if TF_FAST_SEARCH == "0":
|
||||
showname,date = get_info_tmdb(imdb,ismovie,type)
|
||||
tid,url = search(showname,ismovie,date)
|
||||
tid,url = await search(showname,ismovie,date,client)
|
||||
elif TF_FAST_SEARCH == "1":
|
||||
showname = get_info_tmdb(imdb,ismovie,type)
|
||||
tid,url = fast_search(showname,ismovie)
|
||||
protect_link = get_protect_link(tid,url)
|
||||
tid,url = await fast_search(showname,ismovie,client)
|
||||
protect_link = await get_protect_link(tid,url,client)
|
||||
if not isinstance(protect_link, str):
|
||||
urls = protect_link
|
||||
if urls:
|
||||
@@ -258,7 +258,7 @@ def tantifilm(imdb):
|
||||
else:
|
||||
print("Tantifilm Error v2")
|
||||
else:
|
||||
url = true_url(protect_link)
|
||||
url = await true_url(protect_link,client)
|
||||
if url:
|
||||
return url
|
||||
|
||||
|
||||
Reference in New Issue
Block a user