Found filmpertutti api and therefore used it

This commit is contained in:
UrloMythus
2024-07-07 17:48:28 +02:00 Unverified
parent 6e63f37b0a
commit a190ed4bac
3 changed files with 33 additions and 53 deletions
+7
View File
@@ -0,0 +1,7 @@
# Spacefile Docs: https://go.deta.dev/docs/spacefile/v0
v: 0
micros:
- name: MammaMia
src: ./
engine: python3.9
primary: true
Binary file not shown.
+26 -53
View File
@@ -76,52 +76,27 @@ def get_mamma(tmbda,ismovie):
else: else:
return showname,date return showname,date
def search(query,date): def search(showname2,date):
response = requests.get(query, headers=headers) base_url = f'https://filmpertutti.{DOMAIN}/wp-json/wp/v2/posts'
soup = BeautifulSoup(response.text, 'html.parser') params = {
test= soup.find('div', class_='elementor-posts-container elementor-posts elementor-posts--skin-classic elementor-grid') "search": showname2,
# Find all articles "page": "1",
articles = test.select('article', class_='elementor-post elementor-grid-item post-629565') "_fields": "title,date,id" # Only fetch the 'title' and 'date' fields
}
# Loop through each article response = requests.get(base_url, params=params)
for article in articles: all_fields = response.json()
# Find the link inside the article for post in all_fields:
link = article.find('a', class_='elementor-post__thumbnail__link') title = post['title']['rendered']
date2 = post['date'].split('T')[0] # remove the time part
# Extract the href attribute from the link tid = post['id']
href = link['href'] if date2 == date:
#replace base url for easier scraping return tid
href = href.replace('definizionealta.com', f'filmpertutti.{DOMAIN}')
#Get the correct serie by checking if the date is equals def get_episode_link(season,episode,tid):
series_response = requests.get(href, headers=headers) base_url = f'https://filmpertutti.{DOMAIN}/'
series_soup = BeautifulSoup(series_response.text, 'html.parser')
release_span = series_soup.find('span', class_='released')
if release_span:
if release_span.text != "Data di uscita: N/A":
date_string = release_span.text.split(': ')[-1] # Get the date part
for eng, ita in month_mapping.items():
date_string = re.sub(rf'\b{eng}\b', ita, date_string)
# Swap to YY-MM-DD formatting using dateparser
release_date = dateparser.parse(date_string, languages=['it']).strftime("%Y-%m-%d")
print(release_date)
if release_date == date:
url = href
break
return url
def get_episode_link(season,episode,url):
response = requests.get(url)
# Extract the 'link' field from the headers
link_field = response.headers.get('Link')
links = link_field.split(',')
links = [link.split(';')[0].strip('<>') for link in links]
second_link = links[2]
#Get the ID of the serie (not tmbd or imbd)
tid = second_link.split("=")[1]
episode = int(episode) episode = int(episode)
season = int(season) season = int(season)
tlink = f'{url}?show_video=true&post_id={tid}&season_id={season-1}&episode_id={episode-1}' tlink = f'{base_url}?show_video=true&post_id={tid}&season_id={season-1}&episode_id={episode-1}'
return tlink return tlink
@@ -165,15 +140,12 @@ def get_stream_link(imbd):
else: else:
tmdba,ismovie = info tmdba,ismovie = info
showname,date = get_mamma(tmdba,ismovie) showname,date = get_mamma(tmdba,ismovie)
showname2 = showname.replace("–", "+").replace("—","+")
query = f"https://filmpertutti.{DOMAIN}/?s=+{showname}" print(showname2)
query = query.replace(" ", "+").replace("–", "+").replace("—","+") print(date)
print(query) tid = search(showname2,date)
url = search(query,date)
print(ismovie)
print(url)
if ismovie == 0: if ismovie == 0:
episode_link = get_episode_link(season,episode,url) episode_link = get_episode_link(season,episode,tid)
print(episode_link) print(episode_link)
#Let's get mixdrop link #Let's get mixdrop link
real_link = get_real_link(episode_link) real_link = get_real_link(episode_link)
@@ -187,4 +159,5 @@ def get_stream_link(imbd):
real_link = get_real_link(film_link) real_link = get_real_link(film_link)
#let's get delivery link, streaming link #let's get delivery link, streaming link
streaming_link = get_true_link(real_link) streaming_link = get_true_link(real_link)
return streaming_link return streaming_link
get_stream_link("tt16288804:1:1")