Mythus commited on
Commit
0b47aae
·
verified ·
1 Parent(s): 600960d

Delete filmpertutti.py

Browse files
Files changed (1) hide show
  1. filmpertutti.py +0 -136
filmpertutti.py DELETED
@@ -1,136 +0,0 @@
1
-
2
- from tmdbv3api import TMDb, Movie, TV
3
- import requests
4
- from bs4 import BeautifulSoup,SoupStrainer
5
- import string
6
- import re
7
- from datetime import datetime
8
- import dateparser
9
- from convert import get_TMDb_id_from_IMDb_id
10
- from info import get_info_tmdb, is_movie, get_info_imdb
11
- from convert_date import convert_US_date
12
- import logging
13
- import config
14
-
15
- FT_DOMAIN = config.FT_DOMAIN
16
-
17
- #Some basic headers
18
- headers = {
19
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.10; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
20
- 'Accept-Language': 'en-US,en;q=0.5'
21
- }
22
- #Map months to check if date = date
23
- month_mapping = {
24
- 'Jan': 'Gennaio', 'Feb': 'Febbraio', 'Mar': 'Marzo', 'Apr': 'Aprile',
25
- 'May': 'Maggio', 'Jun': 'Giugno', 'Jul': 'Luglio', 'Aug': 'Agosto',
26
- 'Sep': 'Settembre', 'Oct': 'Ottobre', 'Nov': 'Novembre', 'Dec': 'Dicembre'
27
- }
28
-
29
- def search(query,date):
30
- response = requests.get(query).json()
31
- #Get link tid of every item and then open the link to see if the date = date
32
- for json in response:
33
- link = json['link']
34
- tid = json['id']
35
- series_response = requests.get(link, headers=headers)
36
- series_soup = BeautifulSoup(series_response.text, 'lxml')
37
- release_span = series_soup.find('span', class_='released')
38
- if release_span:
39
- if release_span.text != "Data di uscita: N/A":
40
- date_string = release_span.text.split(': ')[-1] # Get the date part
41
- for eng, ita in month_mapping.items():
42
- date_string = re.sub(rf'\b{eng}\b', ita, date_string)
43
-
44
- # Swap to YY-MM-DD formatting using dateparser
45
- release_date = dateparser.parse(date_string, languages=['it']).strftime("%Y-%m-%d")
46
- if release_date == date:
47
- url = link
48
- tid = tid
49
- return url, tid
50
- else:
51
- print("Date are not equals")
52
-
53
- def get_episode_link(season,episode,tid,url):
54
- #Get the link from where we have to obtain mixdrop link
55
- tlink = f'{url}?show_video=true&post_id={tid}&season_id={season-1}&episode_id={episode-1}'
56
- return tlink
57
-
58
-
59
- def get_film(url):
60
- #Get the link from where we have to obtain mixdrop link
61
- tlink = url + "?show_video=true"
62
- return tlink
63
-
64
- def get_real_link(tlink):
65
- #Some basic code to get the mixdrop link
66
- page = requests.get(tlink, headers=headers)
67
- soup = BeautifulSoup(page.content, features="lxml",parse_only=SoupStrainer('iframe'))
68
- iframe_src = soup.find('iframe')['src']
69
-
70
- iframe_page = requests.get(iframe_src, headers=headers)
71
- iframe_soup = BeautifulSoup(iframe_page.content, features="lxml")
72
-
73
- mega_button = iframe_soup.find('div', attrs={'class': 'megaButton', 'rel': 'nofollow'}, string='MIXDROP')
74
- if mega_button:
75
- real_link = mega_button.get('meta-link')
76
- return real_link
77
-
78
- def get_true_link(real_link):
79
- response = requests.get(real_link, headers=headers)
80
- [s1, s2] = re.search(r"\}\('(.+)',.+,'(.+)'\.split", response.text).group(1, 2)
81
- schema = s1.split(";")[2][5:-1]
82
- terms = s2.split("|")
83
- charset = string.digits + string.ascii_letters
84
- d = dict()
85
- for i in range(len(terms)):
86
- d[charset[i]] = terms[i] or charset[i]
87
- s = 'https:'
88
- for c in schema:
89
- s += d[c] if c in d else c
90
- return s
91
-
92
- def filmpertutti(imdb):
93
- general = is_movie(imdb)
94
- ismovie = general[0]
95
- imdb_id = general[1]
96
- type = "Filmpertutti"
97
- if ismovie == 0 :
98
- season = int(general[2])
99
- episode = int(general[3])
100
- if "tt" in imdb:
101
- if ismovie == 0:
102
- #Get showname and date
103
- showname,date = get_info_imdb(imdb_id,ismovie,type)
104
- else:
105
- #THIS IS needed cause the only way to get all releases dates is by giving a tmdb ID not a IMDB
106
- tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
107
- showname,date = get_info_tmdb(tmdba,ismovie,type)
108
-
109
- elif "tmdb" in imdb:
110
- #Get showname and date
111
- tmdba = imdb_id.replace("tmdb:","")
112
- showname,date = get_info_tmdb(tmdba,ismovie,type)
113
- showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
114
- #Build the query
115
- query = f'https://filmpertutti.{FT_DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
116
- try:
117
- url,tid = search(query,date)
118
- except:
119
- print("No results found")
120
- return None
121
- if ismovie == 0:
122
- episode_link = get_episode_link(season,episode,tid,url)
123
- #Let's get mixdrop link
124
- real_link = get_real_link(episode_link)
125
- #let's get delivery link, streaming link
126
- streaming_link = get_true_link(real_link)
127
- print(streaming_link)
128
- return streaming_link
129
- elif ismovie == 1:
130
- film_link = get_film(url)
131
- #Let's get mixdrop link
132
- real_link = get_real_link(film_link)
133
- #let's get delivery link, streaming link
134
- streaming_link = get_true_link(real_link)
135
- print(streaming_link)
136
- return streaming_link