Spaces:
Paused
Paused
Delete streamingcommunity.py
Browse files- streamingcommunity.py +0 -182
streamingcommunity.py
DELETED
|
@@ -1,182 +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 info import get_info_tmdb, is_movie, get_info_imdb
|
| 9 |
-
import config
|
| 10 |
-
import json
|
| 11 |
-
import re
|
| 12 |
-
#Get domain
|
| 13 |
-
SC_DOMAIN= config.SC_DOMAIN
|
| 14 |
-
SC_FAST_SEARCH = config.SC_FAST_SEARCH
|
| 15 |
-
|
| 16 |
-
headers = {
|
| 17 |
-
'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',
|
| 18 |
-
'Accept-Language': 'en-US,en;q=0.5'
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
#GET VERSION OF STREAMING COMMUNITY:
|
| 22 |
-
def get_version():
|
| 23 |
-
#Extract the version from the main page of the site
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
try:
|
| 27 |
-
base_url = f'https://streamingcommunity.{SC_DOMAIN}/richiedi-un-titolo'
|
| 28 |
-
response = requests.get(base_url, headers=headers)
|
| 29 |
-
#Soup the response
|
| 30 |
-
soup = BeautifulSoup(response.text, "lxml")
|
| 31 |
-
|
| 32 |
-
# Extract version
|
| 33 |
-
version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
|
| 34 |
-
return version
|
| 35 |
-
except:
|
| 36 |
-
print("Couldn't find the version")
|
| 37 |
-
version = "65e52dcf34d64173542cd2dc6b8bb75b"
|
| 38 |
-
return version
|
| 39 |
-
|
| 40 |
-
def search(query,date,ismovie):
|
| 41 |
-
#Do a request to get the ID of serie/move and it's slug in the URL
|
| 42 |
-
response = requests.get(query).json()
|
| 43 |
-
for item in response['data']:
|
| 44 |
-
tid = item['id']
|
| 45 |
-
slug = item['slug']
|
| 46 |
-
type = item['type']
|
| 47 |
-
if type == "tv":
|
| 48 |
-
type = 0
|
| 49 |
-
elif type == "movie":
|
| 50 |
-
type = 1
|
| 51 |
-
if type == ismovie:
|
| 52 |
-
#Added a Check to see if the result is what it is supposed to be
|
| 53 |
-
if SC_FAST_SEARCH == "0":
|
| 54 |
-
if ismovie == 0:
|
| 55 |
-
seasons_count = item['seasons_count']
|
| 56 |
-
#Do not ask me why but somewhy streaming community call the first air date the last air date
|
| 57 |
-
first_air_date = item['last_air_date']
|
| 58 |
-
if first_air_date:
|
| 59 |
-
first_air_year = first_air_date.split("-")[0]
|
| 60 |
-
if first_air_year == date:
|
| 61 |
-
return tid,slug
|
| 62 |
-
else:
|
| 63 |
-
response = requests.get ( f'https://streamingcommunity.boston/titles/{tid}-{slug}')
|
| 64 |
-
pattern = r'<div[^>]*class="features"[^>]*>.*?<span[^>]*>(.*?)<\/span>'
|
| 65 |
-
match = re.search(pattern, response.text)
|
| 66 |
-
print(match.group(1).split("-")[0])
|
| 67 |
-
first_air_year = match.group(1).split("-")[0]
|
| 68 |
-
date = int(date)
|
| 69 |
-
first_air_year = int(first_air_year)
|
| 70 |
-
if first_air_year == date:
|
| 71 |
-
return tid,slug
|
| 72 |
-
elif ismovie == 1:
|
| 73 |
-
return tid,slug
|
| 74 |
-
elif SC_FAST_SEARCH == "1":
|
| 75 |
-
return tid,slug
|
| 76 |
-
else:
|
| 77 |
-
print("Couldn't find anything")
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
def get_film(tid):
|
| 81 |
-
#Access the iframe
|
| 82 |
-
url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
|
| 83 |
-
response = requests.get(url, headers=headers)
|
| 84 |
-
iframe = BeautifulSoup(response.text, 'lxml')
|
| 85 |
-
#Get the link of iframe
|
| 86 |
-
iframe = iframe.find('iframe').get("src")
|
| 87 |
-
#Get the ID containted in the src of iframe
|
| 88 |
-
vixid = iframe.split("/embed/")[1].split("?")[0]
|
| 89 |
-
#Build the url with 1080p, to get the highest resolution
|
| 90 |
-
url = f'https://vixcloud.co/playlist/{vixid}'
|
| 91 |
-
return url
|
| 92 |
-
|
| 93 |
-
def get_season_episode_id(tid,slug,season,episode,version):
|
| 94 |
-
#Set some basic headers for the request
|
| 95 |
-
headers = {
|
| 96 |
-
'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",
|
| 97 |
-
'x-inertia': 'true',
|
| 98 |
-
#Version of streaming community
|
| 99 |
-
'x-inertia-version': version
|
| 100 |
-
}
|
| 101 |
-
#Get episode ID
|
| 102 |
-
response = requests.get(f'https://streamingcommunity.{SC_DOMAIN}/titles/{tid}-{slug}/stagione-{season}', headers=headers)
|
| 103 |
-
# Print the json got
|
| 104 |
-
json_response = response.json().get('props', {}).get('loadedSeason', {}).get('episodes', [])
|
| 105 |
-
for dict_episode in json_response:
|
| 106 |
-
if dict_episode['number'] == episode:
|
| 107 |
-
return dict_episode['id']
|
| 108 |
-
|
| 109 |
-
def get_episode_link(episode_id,tid):
|
| 110 |
-
#The parameters for the request
|
| 111 |
-
params = {
|
| 112 |
-
'episode_id': episode_id,
|
| 113 |
-
'next_episode': '1'
|
| 114 |
-
}
|
| 115 |
-
#Let's try to get the link from iframe source
|
| 116 |
-
# Make a request to get iframe source
|
| 117 |
-
response = requests.get(f"https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}", params=params)
|
| 118 |
-
|
| 119 |
-
# Parse response with BeautifulSoup to get iframe source
|
| 120 |
-
soup = BeautifulSoup(response.text, "lxml")
|
| 121 |
-
iframe = soup.find("iframe").get("src")
|
| 122 |
-
vixid = iframe.split("/embed/")[1].split("?")[0]
|
| 123 |
-
url = f"https://vixcloud.co/playlist/{vixid}"
|
| 124 |
-
return url
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
def streaming_community(imdb):
|
| 128 |
-
try:
|
| 129 |
-
general = is_movie(imdb)
|
| 130 |
-
ismovie = general[0]
|
| 131 |
-
imdb_id = general[1]
|
| 132 |
-
type = "StreamingCommunity"
|
| 133 |
-
if ismovie == 0 :
|
| 134 |
-
season = int(general[2])
|
| 135 |
-
episode = int(general[3])
|
| 136 |
-
#Check if fast search is enabled or disabled
|
| 137 |
-
if SC_FAST_SEARCH == "1":
|
| 138 |
-
if "tt" in imdb:
|
| 139 |
-
#Get showname
|
| 140 |
-
showname = get_info_imdb(imdb_id,ismovie,type)
|
| 141 |
-
date = None
|
| 142 |
-
else:
|
| 143 |
-
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
| 144 |
-
date = None
|
| 145 |
-
#else just equals them
|
| 146 |
-
tmdba = imdb_id.replace("tmdb:","")
|
| 147 |
-
showname = get_info_tmdb(tmdba,ismovie,type)
|
| 148 |
-
elif SC_FAST_SEARCH == "0":
|
| 149 |
-
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
| 150 |
-
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
| 151 |
-
#HERE THE CASE IF IT IS A MOVIE
|
| 152 |
-
else:
|
| 153 |
-
if "tt" in imdb:
|
| 154 |
-
#Get showname
|
| 155 |
-
date = None
|
| 156 |
-
showname = get_info_imdb(imdb_id,ismovie,type)
|
| 157 |
-
else:
|
| 158 |
-
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
| 159 |
-
#else just equals them
|
| 160 |
-
date = None
|
| 161 |
-
tmdba = imdb_id.replace("tmdb:","")
|
| 162 |
-
showname = get_info_tmdb(tmdba,ismovie,type)
|
| 163 |
-
|
| 164 |
-
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
| 165 |
-
query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
|
| 166 |
-
tid,slug = search(query,date,ismovie)
|
| 167 |
-
if ismovie == 1:
|
| 168 |
-
#TID means temporaly ID
|
| 169 |
-
url = get_film(tid)
|
| 170 |
-
print(url)
|
| 171 |
-
return url
|
| 172 |
-
if ismovie == 0:
|
| 173 |
-
#Uid = URL ID
|
| 174 |
-
version = get_version()
|
| 175 |
-
episode_id = get_season_episode_id(tid,slug,season,episode,version)
|
| 176 |
-
url = get_episode_link(episode_id,tid)
|
| 177 |
-
print(url)
|
| 178 |
-
return url
|
| 179 |
-
except Exception as e:
|
| 180 |
-
print("Nope It failed")
|
| 181 |
-
|
| 182 |
-
streaming_community("tt0158552:3:2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|