Merge remote-tracking branch 'origin/master'

This commit is contained in:
mac12m99
2021-01-29 18:22:40 +01:00
6 changed files with 191 additions and 256 deletions
+8 -1
View File
@@ -3,7 +3,7 @@
# from future import standard_library # from future import standard_library
# standard_library.install_aliases() # standard_library.install_aliases()
# from builtins import str # from builtins import str
import sys import sys, requests
PY3 = False PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
@@ -1430,6 +1430,13 @@ class Tmdb(object):
return ret_dic return ret_dic
def get_list_episodes(self):
# from core.support import dbg;dbg()
url = 'https://api.themoviedb.org/3/tv/{id}?api_key=a1ab8b8669da03637a4b98fa39c39228&language={lang}'.format(id=self.busqueda_id, lang=self.busqueda_idioma)
# url = 'https://api.themoviedb.org/3/tv/{id}/episode_groups?api_key=a1ab8b8669da03637a4b98fa39c39228&language={lang}'.format(id=_id, lang=self.busqueda_idioma)
results = requests.get(url).json()['seasons']
return results if 'Error' not in results else {}
def get_videos(self): def get_videos(self):
""" """
:return: Returns an ordered list (language / resolution / type) of Dict objects in which each of its elements corresponds to a trailer, teaser or clip from youtube. :return: Returns an ordered list (language / resolution / type) of Dict objects in which each of its elements corresponds to a trailer, teaser or clip from youtube.
+133 -195
View File
@@ -5,23 +5,21 @@
import xbmc, xbmcgui, re, base64, inspect, sys import xbmc, xbmcgui, re, base64, inspect, sys
from core import jsontools, tvdb, scrapertools, filetools from core import jsontools, tmdb, scrapertools, filetools
from core.item import Item from core.item import Item
from core.support import typo, match, dbg, Item from core.support import typo, match, dbg, Item
from platformcode import config, platformtools, logger from platformcode import config, platformtools, logger
PY3 = True if sys.version_info[0] >= 3 else False PY3 = True if sys.version_info[0] >= 3 else False
# Json Var # Json Var
TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER" RENUMBER = 'TVSHOW_AUTORENUMBER'
ID = "ID" ID = 'id'
SEASON = "Season" SEASONSDICT = 'seasons'
EPISODE = "Episode" SEASON = 'season'
SPECIAL = "Special" EPISODE = 'episode'
MODE = "Mode" EPISODES = 'episodes'
EPLIST = "EpList" SPECIALEPISODES = 'specials'
CHECK = "ReCheck" MANUALMODE = 'manual'
SPLIST = "SpList"
TYPE = "Type"
# helper Functions # helper Functions
def check(item): def check(item):
@@ -41,21 +39,15 @@ def filename(item):
def load(item): def load(item):
logger.debug() logger.debug()
try: try: json = jsontools.load(open(filename(item), "r").read())[RENUMBER]
json_file = open(filename(item), "r").read() except: json = {}
json = jsontools.load(json_file)[TVSHOW_RENUMERATE]
except:
json = {}
return json return json
def write(item, json): def write(item, json):
logger.debug() logger.debug()
json_file = open(filename(item), "r").read() js = jsontools.load(open(filename(item), "r").read())
js = jsontools.load(json_file) js[RENUMBER] = json
js[TVSHOW_RENUMERATE] = json
with open(filename(item), "w") as file: with open(filename(item), "w") as file:
file.write(jsontools.dump(js)) file.write(jsontools.dump(js))
file.close() file.close()
@@ -69,15 +61,6 @@ def b64(json, mode = 'encode'):
ret = jsontools.load(base64.b64decode(json)) ret = jsontools.load(base64.b64decode(json))
return ret return ret
def RepresentsInt(s):
# Controllo Numro Stagione
logger.debug()
try:
int(s)
return True
except ValueError:
return False
def find_episodes(item): def find_episodes(item):
logger.debug() logger.debug()
ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel]) ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
@@ -88,6 +71,15 @@ def busy(state):
if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)') if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)') else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
def RepresentsInt(s):
# Controllo Numro Stagione
logger.debug()
try:
int(s)
return True
except ValueError:
return False
# Main # Main
def start(itemlist, item=None): def start(itemlist, item=None):
if not itemlist: return if not itemlist: return
@@ -106,48 +98,44 @@ class autorenumber():
def __init__(self, itemlist, item=None): def __init__(self, itemlist, item=None):
self.item = item self.item = item
self.itemlist = itemlist self.itemlist = itemlist
self.renumberdict = load(self.itemlist[0]) if self.itemlist else load(item) if item else {}
self.selectspecials = False
self.manual = False
self.auto = False self.auto = False
self.dictSeries = load(self.itemlist[0]) if self.itemlist else load(item) if item else {}
self.Episodes = {}
self.sp = False
if self.item: if self.item:
self.auto = config.get_setting('autorenumber', item.channel) self.auto = config.get_setting('autorenumber', item.channel)
self.title = self.item.fulltitle.strip() self.title = self.item.fulltitle.strip()
if match(self.itemlist[0].title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: if match(self.itemlist[0].title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
item.exit = True item.exit = True
return return
elif self.item.channel in self.item.channel_prefs and TVSHOW_RENUMERATE in self.item.channel_prefs[item.channel] and self.title not in self.dictSeries: elif self.item.channel in self.item.channel_prefs and RENUMBER in self.item.channel_prefs[item.channel] and self.title not in self.renumberdict:
from core.videolibrarytools import check_renumber_options from core.videolibrarytools import check_renumber_options
from specials.videolibrary import update_videolibrary from specials.videolibrary import update_videolibrary
check_renumber_options(self.item) check_renumber_options(self.item)
update_videolibrary(self.item) update_videolibrary(self.item)
if self.title in self.dictSeries and ID in self.dictSeries[self.title] and self.dictSeries[self.title][ID] != '0': self.series = self.renumberdict.get(self.title,{})
self.id = self.dictSeries[self.title][ID] self.id = self.series.get(ID, 0)
self.Episodes = b64(self.dictSeries[self.title][EPISODE], 'decode') if EPISODE in self.dictSeries[self.title] else {} self.episodes = self.series.get(EPISODES,{})
self.Season = self.dictSeries[self.title][SEASON] self.seasonsdict = self.series.get(SEASONSDICT,{})
self.Mode = self.dictSeries[self.title].get(MODE, False) self.season = self.series.get(SEASON, -1)
self.Type = self.dictSeries[self.title].get(TYPE, False) self.episode = self.series.get(EPISODE, -1)
if self.item.renumber: self.manual = self.series.get(MANUALMODE, False)
self.config() self.specials = self.series.get(SPECIALEPISODES, {})
else: if self.id and self.episodes and self.season >= 0 and self.episode >= 0:
self.renumber() if self.item.renumber: self.config()
else:self.renumber()
elif self.auto or self.item.renumber: elif self.auto or self.item.renumber:
self.Episodes = {} self.episodes = {}
self.config() self.config()
else: else:
for item in self.itemlist: for item in self.itemlist:
item.context = [{"title": typo(config.get_localized_string(70585), 'bold'), item.context = [{"title": typo(config.get_localized_string(70585), 'bold'),
"action": "start", "action": "start",
"channel": "autorenumber", "channel": "autorenumber",
"from_channel": item.channel, "from_channel": item.channel,
"from_action": item.action}] "from_action": item.action}]
def config(self): def config(self):
self.id = ''
if self.title in self.dictSeries:
self.id = self.dictSeries[self.title].get(ID,'')
# Pulizia del Titolo # Pulizia del Titolo
if any( word in self.title.lower() for word in ['specials', 'speciali']): if any( word in self.title.lower() for word in ['specials', 'speciali']):
self.title = re.sub(r'\s*specials|\s*speciali', '', self.title.lower()) self.title = re.sub(r'\s*specials|\s*speciali', '', self.title.lower())
@@ -155,184 +143,132 @@ class autorenumber():
self.item.contentSerieName = self.title.rstrip('123456789 ') self.item.contentSerieName = self.title.rstrip('123456789 ')
while not self.item.exit: while not self.item.exit:
tvdb.find_and_set_infoLabels(self.item) self.item.infoLabels['tmdb_id'] = ''
if self.item.infoLabels['tvdb_id']: self.item.exit = True self.item.infoLabels['year'] = '-'
else: self.item = platformtools.dialog_info(self.item, 'tvdb') self.item.contentType ='tvshow'
tmdb.find_and_set_infoLabels(self.item)
if self.item.infoLabels['tmdb_id']: self.item.exit = True
else: self.item = platformtools.dialog_info(self.item, 'tmdb')
# Rinumerazione Automatica # Rinumerazione Automatica
if (not self.id and self.auto) or self.item.renumber: if (not self.id and self.auto) or self.item.renumber:
self.id = self.item.infoLabels['tvdb_id'] if 'tvdb_id' in self.item.infoLabels else '' self.id = self.item.infoLabels['tmdb_id'] if 'tmdb_id' in self.item.infoLabels else 0
if self.id: if self.id:
self.dictRenumber = {ID: self.id} self.series = {ID: self.id}
self.dictSeries[self.title] = self.dictRenumber self.renumberdict[self.title] = self.series
if any(word in self.title.lower() for word in ['specials', 'speciali']): season = '0' if any(word in self.title.lower() for word in ['specials', 'speciali']): season = 0
elif RepresentsInt(self.title.split()[-1]): season = self.title.split()[-1] elif RepresentsInt(self.title.split()[-1]): season = int(self.title.split()[-1])
else: season = '1' else: season = 1
self.Season = self.dictRenumber[SEASON] = season self.season = self.series[SEASON] = season
self.episode = 1
self.renumber() self.renumber()
def renumber(self): def renumber(self):
if not self.item.renumber and self.itemlist: if not self.item.renumber and self.itemlist:
if '|' in self.Season:
season = int(self.Season.split('|')[0])
addNumber = int(self.Season.split('|')[-1]) - 1
else:
season = int(self.Season)
addNumber = 0
for item in self.itemlist: for item in self.itemlist:
if not match(item.title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: if not match(item.title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
number = match(item.title, patron=r'(\d+)').match.lstrip('0') number = match(item.title, patron=r'(\d+)').match.lstrip('0')
if number: if number:
if number in self.Episodes: if not number in self.episodes: self.makelist()
if season > 0: item.title = typo(self.Episodes[number] + ' - ', 'bold') + item.title item.title = '{} - {}'.format(typo(self.episodes[number], 'bold'), item.title)
else: item.title = typo('0x%s - ' % str(int(number) + addNumber), 'bold') + item.title
else:
self.makelist()
if season > 0: item.title = typo(self.Episodes[number] + ' - ', 'bold') + item.title
else: item.title = typo('0x%s - ' % str(int(number) + addNumber), 'bold') + item.title
else: else:
self.makelist() self.makelist()
def makelist(self): def makelist(self):
FirstOfSeason= 0 self.epdict = {}
self.EpList = b64(self.dictSeries[self.title][EPLIST], 'decode') if EPLIST in self.dictSeries[self.title] else []
self.Pages = self.dictSeries[self.title].get(CHECK, [1])
self.Mode = self.dictSeries[self.title].get(MODE, False)
self.Type = self.dictSeries[self.title].get(TYPE, False)
Specials = {}
Seasons = {}
if '|' in self.Season:
ep = int(self.Season.split('|')[-1])
Season = int(self.Season.split('|')[0])
else:
Season = int(self.Season)
ep = 1
busy(True) busy(True)
itemlist = find_episodes(self.item) itemlist = find_episodes(self.item)
busy(False) busy(False)
if self.item.renumber: if self.item.renumber or self.manual:
self.s = Season self.item.renumber = False
self.e = 1 self.season, self.episode, self.manual, self.specials, Manual, Exit = SelectreNumeration(self, itemlist)
Season, Episode, self.Mode, Specials, Seasons, Exit = SelectreNumeration(self, itemlist) if Exit:
if Exit: return self.item.exit = True
if ep != 1: self.Season = '%s|%s' % (Season, Episode) return
else: self.Season = str(Season) if self.manual:
self.episodes = Manual
elif self.Episodes and not self.Mode:
self.s = Season
self.e = ep
self.sp = True
Season, Episode, self.Mode, Specials, Seasons, Exit = SelectreNumeration(self, itemlist)
if self.Mode:
if not Seasons:
self.s = 1
self.e = 1
Season, Episode, self.Mode, Specials, Seasons, Exit = SelectreNumeration(self, itemlist, True)
self.Episodes = Seasons
else: else:
# Ricava Informazioni da TVDB seasons = tmdb.Tmdb(id_Tmdb=self.id).get_list_episodes()
checkpages = [] count = 0
exist = True for season in seasons:
Page = self.Pages[-1] s = season['season_number']
Episode = ep c = season['episode_count']
self.seasonsdict[str(s)] = c
if s > 0:
for e in range(1, c + 1):
count += 1
self.epdict[count] = '{}x{:02d}'.format(s,e)
# dbg()
firstep = 0
if self.season > 1:
for c in range(1, self.season):
firstep += self.seasonsdict[str(c)]
firstep += self.episode - 1
count = 0
if self.epdict:
for item in itemlist:
if not match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
# Otiene Numerazione Episodi
scraped_ep = match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'(\d+)').match
if scraped_ep:
episode = int(scraped_ep)
if episode == 0:
self.episodes[str(episode)] = '0x01'
elif str(episode) in self.specials:
self.episodes[str(episode)] = self.specials[str(episode)]
count += 1
elif episode - count + firstep in self.epdict:
self.episodes[str(episode)] = self.epdict[episode - count + firstep]
else:
self.episodes[str(episode)] = '0x{:02d}'.format(count + 1)
count += 1
if self.episodes: self.renumberdict[self.title][EPISODES] = self.episodes
self.renumberdict[self.title][MANUALMODE] = self.manual
self.renumberdict[self.title][SEASON] = self.season
self.renumberdict[self.title][EPISODE] = self.episode
self.renumberdict[self.title][SPECIALEPISODES] = self.specials
self.renumberdict[self.title][SEASONSDICT] = self.seasonsdict
write(self.item, self.renumberdict)
# if self.auto: self.renumber()
while exist:
data = tvdb.Tvdb(tvdb_id=self.id).get_list_episodes(self.id, Page)
if data:
for episode in data['data']:
if episode['firstAired'] and [episode['firstAired'], episode['airedSeason'], episode['airedEpisodeNumber']] not in self.EpList:
self.EpList.append([episode['firstAired'], episode['airedSeason'], episode['airedEpisodeNumber']])
Page += 1
else:
if Page not in checkpages:
checkpages.append(Page -1)
exist = False
self.Pages = [checkpages[-1]]
self.EpList.sort()
# Crea Dizionari per la Rinumerazione
if self.EpList:
self.specials = []
self.regular = {}
self.complete = {}
allep = 1
specialep = 0
for episode in self.EpList:
self.complete[allep] = [str(episode[1]) + 'x' + str(episode[2]), episode[0]]
if episode[1] == 0:
self.specials.append(allep)
specialep = specialep + 1
else:
self.regular[ep] = [str(episode[1]) + 'x' + str(episode[2]), str(episode[0]), allep - 1]
ep = ep + 1
allep = allep + 1
if Season > 1:
for numbers, data in self.regular.items():
if data[0] == str(Season) + 'x1':
FirstOfSeason = numbers - 1
else: FirstOfSeason = Episode - 1
addiction = 0
for item in itemlist:
if not match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
# Otiene Numerazione Episodi
scraped_ep = match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'(\d+)').match
if scraped_ep:
episode = int(scraped_ep)
number = episode + FirstOfSeason - addiction
if episode == 0:
self.Episodes[str(episode)] = str(self.complete[self.regular[FirstOfSeason+1][2]][0])
elif episode in Specials:
self.Episodes[str(episode)] = Specials[episode]
addiction += 1
elif number <= len(self.regular) and number in self.regular:
self.Episodes[str(episode)] = str(self.regular[number][0])
else:
try: self.Episodes[str(episode)] = str(self.complete[self.regular[number+2][2]][0])
except: self.Episodes[str(episode)] = '0x0'
if self.Episodes: self.dictSeries[self.title][EPISODE] = b64(jsontools.dump(self.Episodes))
self.dictSeries[self.title][EPLIST] = b64(jsontools.dump(self.EpList))
self.dictSeries[self.title][MODE] = self.Mode
self.dictSeries[self.title][SEASON] = self.Season
self.dictSeries[self.title][CHECK] = self.Pages
write(self.item, self.dictSeries)
if self.auto: self.renumber()
def SelectreNumeration(opt, itemlist, manual=False): def SelectreNumeration(opt, itemlist, manual=False):
class SelectreNumerationWindow(xbmcgui.WindowXMLDialog): class SelectreNumerationWindow(xbmcgui.WindowXMLDialog):
def start(self, opt): def start(self, opt):
self.episodes = opt.Episodes if opt.Episodes else {} self.episodes = opt.episodes if opt.episodes else {}
self.dictSeries = opt.dictSeries self.renumberdict = opt.renumberdict
self.item = opt.item self.item = opt.item
self.title = opt.title self.title = opt.title
self.season = opt.s self.season = opt.season
self.episode = opt.e self.episode = opt.episode
self.mode = opt.Mode self.manual = opt.manual
self.sp = opt.sp self.sp = opt.selectspecials
self.manual = opt.manual self.manual = opt.manual
self.offset = 0 self.offset = 0
self.Exit = False self.Exit = False
self.itemlist = opt.itemlist self.itemlist = opt.itemlist
self.count = 1 self.count = 1
self.specials = {} self.specials = opt.specials
self.items = [] self.items = []
self.selected = [] self.selected = []
self.seasons = {} self.seasons = {}
self.seasonsdict = opt.seasonsdict
self.doModal() self.doModal()
return self.season, self.episode, self.mode, self.specials, self.seasons, self.Exit return self.season, self.episode, self.manual, self.specials, self.seasons, self.Exit
def onInit(self): def onInit(self):
# Compatibility with Kodi 18 # Compatibility with Kodi 18
@@ -349,7 +285,7 @@ def SelectreNumeration(opt, itemlist, manual=False):
if fanart: self.getControl(MBACKGROUND).setImage(fanart) if fanart: self.getControl(MBACKGROUND).setImage(fanart)
self.getControl(INFO).setLabel(typo(config.get_localized_string(70822) + self.title, 'bold')) self.getControl(INFO).setLabel(typo(config.get_localized_string(70822) + self.title, 'bold'))
self.mode = True self.manual = True
se = '1' se = '1'
ep = '1' ep = '1'
@@ -434,17 +370,19 @@ def SelectreNumeration(opt, itemlist, manual=False):
self.setFocusId(focus - 1) self.setFocusId(focus - 1)
elif action in [UP]: elif action in [UP]:
if focus in [S]: if focus in [S]:
s += 1 if str(s + 1) in self.seasonsdict:
self.getControl(S).setLabel(str(s)) s += 1
self.getControl(S).setLabel(str(s))
elif focus in [E]: elif focus in [E]:
e += 1 if self.seasonsdict[str(s)] > e:
self.getControl(E).setLabel(str(e)) e += 1
self.getControl(E).setLabel(str(e))
elif action in [DOWN]: elif action in [DOWN]:
if focus in [S]: if focus in [S]:
if s > 0: s -= 1 if str(s - 1) in self.seasonsdict: s -= 1
self.getControl(S).setLabel(str(s)) self.getControl(S).setLabel(str(s))
elif focus in [E]: elif focus in [E]:
if e > 0: e -= 1 if e > 1: e -= 1
self.getControl(E).setLabel(str(e)) self.getControl(E).setLabel(str(e))
# MANUAL # MANUAL
if focus in [MS, ME]: if focus in [MS, ME]:
@@ -508,7 +446,7 @@ def SelectreNumeration(opt, itemlist, manual=False):
# OPEN MANUAL # OPEN MANUAL
elif control_id in [M]: elif control_id in [M]:
self.getControl(INFO).setLabel(typo(config.get_localized_string(70823) + self.title, 'bold')) self.getControl(INFO).setLabel(typo(config.get_localized_string(70823) + self.title, 'bold'))
self.mode = True self.manual = True
if self.episodes: if self.episodes:
items = [] items = []
se = '1' se = '1'
@@ -539,8 +477,8 @@ def SelectreNumeration(opt, itemlist, manual=False):
# DELETE # DELETE
if control_id in [D]: if control_id in [D]:
self.Exit = True self.Exit = True
self.dictSeries.pop(self.title) self.renumberdict.pop(self.title)
write(self.item, self.dictSeries) write(self.item, self.renumberdict)
self.close() self.close()
## SPECIAL SECTION ## SPECIAL SECTION
@@ -548,7 +486,7 @@ def SelectreNumeration(opt, itemlist, manual=False):
p1 = self.getControl(SELECTED).getSelectedPosition() p1 = self.getControl(SELECTED).getSelectedPosition()
if control_id in [LIST]: if control_id in [LIST]:
item = self.getControl(LIST).getSelectedItem() item = self.getControl(LIST).getSelectedItem()
it = xbmcgui.ListItem(str(len(self.selected) + 1)) it = xbmcgui.ListItem(str(len(self.selected) + len(self.specials) + 1))
it.setProperty('title', item.getLabel()) it.setProperty('title', item.getLabel())
self.selected.append(it) self.selected.append(it)
index = self.getControl(SELECTED).getSelectedPosition() index = self.getControl(SELECTED).getSelectedPosition()
BIN
View File
Binary file not shown.
Binary file not shown.
+47 -58
View File
@@ -1,109 +1,98 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
from platformcode import config
PY3 = False PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
if PY3: if PY3: import urllib.parse as urllib
#from future import standard_library else: import urllib
#standard_library.install_aliases()
import urllib.parse as urllib # Es muy lento en PY2. En PY3 es nativo
else:
import urllib # Usamos el nativo de PY2 que es más rápido
from core import httptools from core import httptools
from core import scrapertools from core import scrapertools
from platformcode import logger from platformcode import logger
from core.support import match
def test_video_exists(page_url): def test_video_exists(page_url):
logger.debug("(page_url='%s')" % page_url) logger.info("(page_url='%s')" % page_url)
global data
data = httptools.downloadpage(page_url).data data = httptools.downloadpage(page_url).data
if "Streaming link:" in data: if "Streaming link:" in data:
return True, "" return True, ""
elif "Unfortunately, the file you want is not available." in data or "Unfortunately, the video you want to see is not available" in data or "This stream doesn" in data\ elif "Unfortunately, the file you want is not available." in data or "Unfortunately, the video you want to see is not available" in data or "This stream doesn" in data or "Page not found" in data or "Archivo no encontrado" in data:
or "Page not found" in data: return False, config.get_localized_string(70449) % "UPtoStream"
return False, config.get_localized_string(70449) % "Uptobox"
wait = scrapertools.find_single_match(data, "You have to wait ([0-9]+) (minute|second)") wait = scrapertools.find_single_match(data, "You have to wait ([0-9]+) (minute|second)")
if len(wait) > 0: if len(wait) > 0:
tiempo = wait[1].replace("minute", "minuto/s").replace("second", "segundos") return False, "[UPtoStream] Limite di download raggiunto. <br/> Attendi " + wait[0] + " " + wait[1]
return False, "[Uptobox] Alcanzado límite de descarga.<br/>Tiempo de espera: " + wait[0] + " " + tiempo
return True, "" return True, ""
def get_video_url(page_url, premium=False, user="", password="", video_password=""): def get_video_url(page_url, premium=False, user="", password="", video_password=""):
logger.debug("(page_url='%s')" % page_url) logger.info("(page_url='%s')" % page_url)
# Si el enlace es directo de upstream global data
# If the link is direct from upstream
if "uptobox" not in page_url: if "uptobox" not in page_url:
data = httptools.downloadpage(page_url).data
if "Video not found" in data: if "Video not found" in data:
page_url = page_url.replace("uptostream.com/iframe/", "uptobox.com/") page_url = page_url.replace("uptostream.com/iframe/", "uptobox.com/")
data = httptools.downloadpage(page_url).data video_urls = uptobox(page_url, httptools.downloadpage(page_url).data)
video_urls = uptobox(page_url, data)
else: else:
video_urls = uptostream(data) video_urls = uptostream(data)
else: else:
data = httptools.downloadpage(page_url).data # If the file has a streaming link, it is redirected to upstream
# Si el archivo tiene enlace de streaming se redirige a upstream
if "Streaming link:" in data: if "Streaming link:" in data:
page_url = "http://uptostream.com/iframe/" + scrapertools.find_single_match(page_url, page_url = "http://uptostream.com/iframe/" + scrapertools.find_single_match(page_url, 'uptobox.com/([a-z0-9]+)')
'uptobox.com/([a-z0-9]+)') video_urls = uptostream(httptools.downloadpage(page_url).data)
data = httptools.downloadpage(page_url).data
video_urls = uptostream(data)
else: else:
# Si no lo tiene se utiliza la descarga normal # If you don't have it, the normal download is used
video_urls = uptobox(page_url, data) video_urls = uptobox(page_url, data)
for video_url in video_urls:
logger.debug("%s - %s" % (video_url[0], video_url[1]))
return video_urls return video_urls
def uptostream(data): def uptostream(data):
subtitle = scrapertools.find_single_match(data, "kind='subtitles' src='//([^']+)'") video_id = match(data, patron=r"var videoId\s*=\s*'([^']+)").match
if subtitle: subtitle = match(data, patron=r'kind="subtitles" src="([^"]+)"').match
if subtitle and not '://' in subtitle:
subtitle = "http://" + subtitle subtitle = "http://" + subtitle
video_urls = [] video_urls = []
videos1 = [] api_url = "https://uptostream.com/api/streaming/source/get?token=null&file_code=%s" % video_id
data = data.replace("\\","") api_data = httptools.downloadpage(api_url).json
patron = 'src":"([^"]+).*?' js_code = api_data.get('data', '').get('sources', '')
patron += 'type":"([^"]+).*?'
patron += 'res":"([^"]+).*?' from lib import js2py
patron += 'lang":"([^"]+)'
media = scrapertools.find_multiple_matches(data, patron) context = js2py.EvalJs({'atob': atob})
for media_url, tipo, res, lang in media: context.execute(js_code)
videos1.append([media_url, tipo, res, lang]) result = context.sources
videos1.sort(key=lambda videos1: int(videos1[2]))
for x in videos1: for x in result:
media_url = x[0] media_url = x.get('src', '')
tipo = x[1] tipo = x.get('type', '')
res = x[2] res = x.get('label', '')
lang = x[3] lang = x.get('lang', '')
tipo = tipo.replace("video/","") tipo = tipo.replace("video/","")
extension = ".%s (%s)" % (tipo, res) if lang: extension = "{} - {} [{}]".format(tipo, res, lang.upper())
if lang: else: extension = "{} - {}".format(tipo, res)
extension = extension.replace(")", "/%s)" % lang[:3]) video_urls.append([extension + " [UPtoStream]", media_url, 0, subtitle])
video_urls.append([extension + " [uptostream]", media_url, 0, subtitle]) video_urls.sort(key=lambda url: int(match(url[0], patron=r'(\d+)p').match))
return video_urls return video_urls
def atob(s):
import base64
return base64.b64decode('{}'.format(s)).decode('utf-8')
def uptobox(url, data): def uptobox(url, data):
video_urls = [] video_urls = []
post = "" post = ""
matches = scrapertools.find_multiple_matches(data, '<input type="hidden".*?name="([^"]+)".*?value="([^"]*)">')
matches = match(data, patron=r'name="([^"]+)".*?value="([^"]*)"').matches
for inputname, inputvalue in matches: for inputname, inputvalue in matches:
post += inputname + "=" + inputvalue + "&" post += inputname + "=" + inputvalue + "&"
data = httptools.downloadpage(url, post=post[:-1]).data media = match(url, post=post[:-1], patron=r'<a href="([^"]+)">\s*<span class="button_upload green">').match
media = scrapertools.find_single_match(data, '<a href="([^"]+)">\s*<span class="button_upload green">') url_strip = media.rsplit('/', 1)[1]
# Solo es necesario codificar la ultima parte de la url
url_strip = urllib.quote(media.rsplit('/', 1)[1])
media_url = media.rsplit('/', 1)[0] + "/" + url_strip media_url = media.rsplit('/', 1)[0] + "/" + url_strip
video_urls.append([media_url[-4:] + " [uptobox]", media_url]) video_urls.append([media_url[-4:] + " [UPtoStream]", media_url])
return video_urls return video_urls
+1
View File
@@ -401,6 +401,7 @@ def findvideos(item):
json = item.url['links'] json = item.url['links']
else: else:
json = item.url json = item.url
item.url = ''
for option in json: for option in json:
extra = set_extra_values(item, option, item.path) extra = set_extra_values(item, option, item.path)
title = item.fulltitle + (' - '+option['title'] if 'title' in option else '') title = item.fulltitle + (' - '+option['title'] if 'title' in option else '')