MammaMia-Urlo commited on
Commit
3d1ebc5
·
verified ·
1 Parent(s): 063ff93

Delete streamingcommunity.py

Browse files
Files changed (1) hide show
  1. streamingcommunity.py +0 -102
streamingcommunity.py DELETED
@@ -1,102 +0,0 @@
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 loadenv import load_env
9
- from info import get_info, is_movie
10
- #Get domain
11
- _, _,SC_DOMAIN,_ ,_= load_env()
12
-
13
- headers = {
14
- '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',
15
- 'Accept-Language': 'en-US,en;q=0.5'
16
- }
17
-
18
- def search(query,date,ismovie):
19
- #Do a request to get the ID of serie/move and it's slug in the URL
20
- response = requests.get(query).json()
21
- for item in response['data']:
22
- tid = item['id']
23
- slug = item['slug']
24
- return tid,slug
25
-
26
-
27
- def get_film(tid):
28
- #Access the iframe
29
- url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
30
- response = requests.get(url, headers=headers)
31
- iframe = BeautifulSoup(response.text, 'lxml')
32
- #Get the link of iframe
33
- iframe = iframe.find('iframe').get("src")
34
- #Get the ID containted in the src of iframe
35
- vixid = iframe.split("/embed/")[1].split("?")[0]
36
- #Build the url with 1080p, to get the highest resolution
37
- url = f'https://vixcloud.co/playlist/{vixid}'
38
- return url
39
-
40
- def get_season_episode_id(tid,slug,season,episode):
41
- #Set some basic headers for the request
42
- headers = {
43
- '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",
44
- 'x-inertia': 'true',
45
- #Version of streaming community
46
- 'x-inertia-version': 'c1bdf1189cb68fca28151c8e909bd053'
47
- }
48
- #Get episode ID
49
- response = requests.get(f'https://streamingcommunity.{SC_DOMAIN}/titles/{tid}-{slug}/stagione-{season}', headers=headers)
50
- # Print the json got
51
- json_response = response.json().get('props', {}).get('loadedSeason', {}).get('episodes', [])
52
- for dict_episode in json_response:
53
- if dict_episode['number'] == episode:
54
- return dict_episode['id']
55
-
56
- def get_episode_link(episode_id,tid):
57
- #The parameters for the request
58
- params = {
59
- 'episode_id': episode_id,
60
- 'next_episode': '1'
61
- }
62
- #Let's try to get the link from iframe source
63
- # Make a request to get iframe source
64
- response = requests.get(f"https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}", params=params)
65
-
66
- # Parse response with BeautifulSoup to get iframe source
67
- soup = BeautifulSoup(response.text, "lxml")
68
- iframe = soup.find("iframe").get("src")
69
- vixid = iframe.split("/embed/")[1].split("?")[0]
70
- url = f"https://vixcloud.co/playlist/{vixid}"
71
- return url
72
-
73
-
74
- def streaming_community(imdb):
75
- general = is_movie(imdb)
76
- ismovie = general[0]
77
- imdb_id = general[1]
78
- if ismovie == 0 :
79
- season = int(general[2])
80
- episode = int(general[3])
81
- if "tt" in imdb:
82
- #If it is a imbd then conver it to tmbd
83
- tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
84
- else:
85
- #else just equals them
86
- tmdba = imdb_id.replace("tmdb:","")
87
- type = "StreamingCommunity"
88
- showname,date = get_info(tmdba,ismovie,type)
89
- showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
90
- query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
91
- tid,slug = search(query,date,ismovie)
92
- if ismovie == 1:
93
- #TID means temporaly ID
94
- url = get_film(tid)
95
- logging.info(url)
96
- return url
97
- if ismovie == 0:
98
- #Uid = URL ID
99
- episode_id = get_season_episode_id(tid,slug,season,episode)
100
- url = get_episode_link(episode_id,tid)
101
- logging.info(url)
102
- return url