diff --git a/channels/cinemalibero.py b/channels/cinemalibero.py index 924e9807..ab9d8fd4 100644 --- a/channels/cinemalibero.py +++ b/channels/cinemalibero.py @@ -53,11 +53,13 @@ def peliculas(item): patron = r'
[^>]+>[^>]+>\s[^\)]+)\)">[^>]+>(?P[^<]+)<[^>]+>[^>]+>(?:[^>]+>)?\s?(?P<rating>[\d\.]+)?[^>]+>.+?(?:[ ]\((?P<year>\d{4})\))?<[^>]+>[^>]+>(.?[\d\-x]+\s\(?(?P<lang>[sSuUbBiItTaA\-]+)?\)?\s?(?P<quality>[\w]+)?[|]?\s?(?:[fFiInNeE]+)?\s?\(?(?P<lang2>[sSuUbBiItTaA\-]+)?\)?)?' pagination = 25 elif item.contentType == 'movie': + action = 'findvideos' patron = r'<a href="(?P<url>[^"]+)" title="(?P<title>.+?)(?:[ ]\[(?P<lang>[sSuUbB\-iItTaA]+)\])?(?:[ ]\((?P<year>\d{4})\))?"\s*alt="[^"]+"\s*class="[^"]+"(?: style="background-image: url\((?P<thumb>.+?)\)">)?\s*<div class="voto">[^>]+>[^>]+>.(?P<rating>[\d\.a-zA-Z\/]+)?[^>]+>[^>]+>[^>]+>(?:<div class="genere">(?P<quality>[^<]+)</div>)?' if item.args == 'update': patronBlock = r'<section id="slider">(?P<block>.*?)</section>' patron = r'<a href="(?P<url>(?:https:\/\/.+?\/(?P<title>[^\/]+[a-zA-Z0-9\-]+)(?P<year>\d{4})))/".+?url\((?P<thumb>[^\)]+)\)">' elif item.contentType == 'tvshow': + action = 'episodios' if item.args == 'update': patron = r'<a href="(?P<url>[^"]+)"[^<]+?url\((?P<thumb>.+?)\)">\s*?<div class="titolo">(?P<title>.+?)(?: – Serie TV)?(?:\([sSuUbBiItTaA\-]+\))?[ ]?(?P<year>\d{4})?</div>\s*?(?:<div class="genere">)?(?:[\w]+?\.?\s?[\s|S]?[\dx\-S]+?\s\(?(?P<lang>[iItTaA]+|[sSuUbBiItTaA\-]+)\)?\s?(?P<quality>[HD]+)?|.+?\(?(?P<lang2>[sSuUbBiItTaA\-]+)?\)?</div>)' pagination = 25 @@ -159,6 +161,8 @@ def newest(categoria): def check(item): support.info() + # support.dbg() + from platformcode.launcher import run data = support.match(item.url, headers=headers).data if data: ck = support.match(data, patron=r'Supportaci condividendo quest[oa] ([^:]+)').match.lower() @@ -178,7 +182,8 @@ def check(item): elif ck == 'film': item.contentType = 'movie' item.data = data - return findvideos(item) + item.action = 'findvideos' + return run(item) else: item.contentType = 'tvshow' @@ -187,8 +192,9 @@ def check(item): if not itemlist: item.contentType = 'movie' item.data = data - return findvideos(item) - return itemlist + item.action = 'findvideos' + return run(item) + def findvideos(item): diff --git a/channels/discoveryplus.py b/channels/discoveryplus.py index c56b4d9a..9fca52b4 100644 --- a/channels/discoveryplus.py +++ b/channels/discoveryplus.py @@ -67,7 +67,7 @@ def live(item): logger.debug() itemlist =[] for name, values in liveDict().items(): - itemlist.append(item.clone(title=typo(name,'bold'), fulltitle=name, plot=values['plot'], url=values['url'], id=values['id'], action='play', forcethumb=True, no_return=True)) + itemlist.append(item.clone(title=typo(name,'bold'), fulltitle=name, plot=values['plot'], url=values['url'], id=values['id'], action='findvideos', forcethumb=True, no_return=True)) return support.thumb(itemlist, live=True) @@ -169,7 +169,7 @@ def episodios(item): fulltitle=title, plot=plot, id=episode['id'], - action='play', + action='findvideos', contentType='episode', season=option['id'], episode=episode['attributes']['episodeNumber'], @@ -180,7 +180,7 @@ def episodios(item): return itemlist -def play(item): +def findvideos(item): if item.livefilter: item.id = liveDict()[item.livefilter]['id'] item.fulltitle = item.livefilter @@ -196,4 +196,4 @@ def play(item): else: item.url = data['streaming']['hls']['url'] item.manifest = 'hls' - return [item] \ No newline at end of file + return support.server(item, itemlist=[item], Download=False, Videolibrary=False) \ No newline at end of file diff --git a/channels/la7.py b/channels/la7.py index 3097fd70..fce2d748 100644 --- a/channels/la7.py +++ b/channels/la7.py @@ -34,8 +34,8 @@ def mainlist(item): def live(item): - itemlist = [item.clone(title=support.typo('La7', 'bold'), fulltitle='La7', url= host + '/dirette-tv', action='play', forcethumb = True, no_return=True), - item.clone(title=support.typo('La7d', 'bold'), fulltitle='La7d', url= host + '/live-la7d', action='play', forcethumb = True, no_return=True)] + itemlist = [item.clone(title=support.typo('La7', 'bold'), fulltitle='La7', url= host + '/dirette-tv', action='findvideos', forcethumb = True, no_return=True), + item.clone(title=support.typo('La7d', 'bold'), fulltitle='La7d', url= host + '/live-la7d', action='findvideos', forcethumb = True, no_return=True)] return support.thumb(itemlist, live=True) @@ -57,7 +57,7 @@ def replay_menu(item): @support.scrape def replay(item): - action = 'play' + action = 'findvideos' patron = r'guida-tv"><[^>]+><[^>]+>(?P<hour>[^<]+)<[^>]+><[^>]+><[^>]+>\s*<a href="(?P<url>[^"]+)"><[^>]+><div class="[^"]+" data-background-image="(?P<t>[^"]+)"><[^>]+><[^>]+><[^>]+><[^>]+>\s*(?P<name>[^<]+)<[^>]+><[^>]+><[^>]+>(?P<plot>[^<]+)<' def itemHook(item): item.title = support.typo(item.hour + ' - ' + item.name,'bold') @@ -99,7 +99,7 @@ def peliculas(item): def episodios(item): data = support.match(item).data # debug = True - action = 'play' + action = 'findvideos' if '>puntate<' in data: patronBlock = r'>puntate<(?P<block>.*?)home-block-outbrain' url = support.match(data, patron=r'>puntate<[^>]+>[^>]+>[^>]+><a href="([^"]+)"').match @@ -127,7 +127,7 @@ def episodios(item): return locals() -def play(item): +def findvideos(item): support.info() if item.livefilter: for it in live(item): @@ -169,5 +169,6 @@ def play(item): match = support.match(data, patron='/content/entry/data/(.*?).mp4').match if match: url = 'https://awsvodpkg.iltrovatore.it/local/hls/,/content/entry/data/' + support.match(item, patron='/content/entry/data/(.*?).mp4').match + '.mp4.urlset/master.m3u8' - item = item.clone(title='Direct', url=url, server='directo', action='play') - return support.servertools.find_video_items(item, data=url) + + item = item.clone(title='Direct', server='directo', url=url, action='play') + return support.server(item, itemlist=[item], Download=False, Videolibrary=False) diff --git a/channels/mediasetplay.py b/channels/mediasetplay.py index 9f6aecbe..681b7178 100644 --- a/channels/mediasetplay.py +++ b/channels/mediasetplay.py @@ -95,7 +95,7 @@ def live(item): urls=guide['tuningInstruction']['urn:theplatform:tv:location:any'], plot=plot, url=url, - action='play', + action='findvideos', thumbnail=thumb, forcethumb=True)) @@ -141,7 +141,7 @@ def peliculas(item): else: contentType = 'movie' video_id = it['guid'] - action = 'play' + action = 'findvideos' for k, v in it['thumbnails'].items(): if 'image_vertical' in k and not thumb: thumb = v['url'].replace('.jpg', '@3.jpg') @@ -228,13 +228,13 @@ def episodios(item): thumbnail=thumb, forcethumb=True, contentType='episode', - action='play', + action='findvideos', video_id=it['guid'])) return itemlist -def play(item): +def findvideos(item): logger.debug() item.no_return=True # support.dbg() @@ -262,7 +262,7 @@ def play(item): else: item.manifest = 'hls' - return[item] + return support.server(item, itemlist=[item], Download=False, Videolibrary=False) elif item.video_id: payload = '{"contentId":"' + item.video_id + ' ","streamType":"VOD","delivery":"Streaming","createDevice":true}' @@ -288,7 +288,7 @@ def play(item): else: item.manifest = 'hls' - return [item] + return support.server(item, itemlist=[item], Download=False, Videolibrary=False) def get_from_id(item): @@ -320,7 +320,7 @@ def get_programs(item): args['sid'] = sid args['sessionId'] = sid args['hitsPerPage'] = pagination - args['property'] = 'search' if args.get('query') else 'play' + args['property'] = 'search' if args.get('query') else 'findvideos' args['tenant'] = 'play-prod-v2' args['page'] = pag args['deviceId'] = '017ac511182d008322c989f3aac803083002507b00bd0' diff --git a/channels/paramount.py b/channels/paramount.py index 1049a1d0..a4259d61 100644 --- a/channels/paramount.py +++ b/channels/paramount.py @@ -7,6 +7,8 @@ from core import support, jsontools from platformcode import autorenumber, logger from collections import OrderedDict +from specials import videolibrary + host = support.config.get_channel_url() headers = [['Referer', host]] @@ -64,7 +66,7 @@ def live(item): logger.debug() itemlist=[] for key, value in liveDict().items(): - itemlist.append(item.clone(title=support.typo(key,'bold'), contentTitle=key, fulltitle=key, show=key, url=value['url'], plot=value['plot'], action='play', forcethumb=True, no_return=True)) + itemlist.append(item.clone(title=support.typo(key,'bold'), contentTitle=key, fulltitle=key, show=key, url=value['url'], plot=value['plot'], action='findvideos', forcethumb=True, no_return=True)) return support.thumb(itemlist, live=True) @@ -160,19 +162,22 @@ def episodios(item): def findvideos(item): logger.debug() - return support.server(item, itemlist=[item.clone(title='Paramount', server='directo', action='play')], Download=False) - - -def play(item): logger.debug() item.manifest = 'hls' mgid = support.match(item.url, patron=r'uri":"([^"]+)"').match url = 'https://media.mtvnservices.com/pmt/e1/access/index.html?uri=' + mgid + '&configtype=edge&ref=' + item.url ID, rootUrl = support.match(url, patron=[r'"id":"([^"]+)",',r'brightcove_mediagenRootURL":"([^"]+)"']).matches item.url = jsontools.load(support.match(rootUrl.replace('&device={device}','').format(uri = ID)).data)['package']['video']['item'][0]['rendition'][0]['src'] + return support.server(item, itemlist=[item.clone(title='Paramount', server='directo', action='play')], Download=False, Videolibrary=False) - if item.livefilter: - d = liveDict()[item.livefilter] - item = item.clone(title=support.typo(item.livefilter, 'bold'), fulltitle=item.livefilter, url=d['url'], plot=d['plot'], action='play', forcethumb=True, no_return=True) - support.thumb(item, live=True) - return [item] \ No newline at end of file + +# def play(item): +# logger.debug() +# item.manifest = 'hls' +# mgid = support.match(item.url, patron=r'uri":"([^"]+)"').match +# url = 'https://media.mtvnservices.com/pmt/e1/access/index.html?uri=' + mgid + '&configtype=edge&ref=' + item.url +# ID, rootUrl = support.match(url, patron=[r'"id":"([^"]+)",',r'brightcove_mediagenRootURL":"([^"]+)"']).matches +# item.url = jsontools.load(support.match(rootUrl.replace('&device={device}','').format(uri = ID)).data)['package']['video']['item'][0]['rendition'][0]['src'] + + +# return [item] \ No newline at end of file diff --git a/channels/raiplay.py b/channels/raiplay.py index 3b968d76..54ff89a7 100644 --- a/channels/raiplay.py +++ b/channels/raiplay.py @@ -142,7 +142,7 @@ def live(item): current = it['currentItem'] next = it['nextItem'] plot = '[B]{}[/B]\n{}\n\nA Seguire: [B]{}[/B]\n{}'.format(current['name'], current['description'], next['name'], next['description']) - itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, video_url=url + '.json', action='play')) + itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, video_url=url + '.json', action='findvideos')) itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999)) support.thumb(itemlist, live=True) return itemlist @@ -209,7 +209,7 @@ def replay(item): plot = info['description'], url = getUrl(it['weblink']), video_url = getUrl(it['path_id']), - action = 'play', + action = 'findvideos', forcethumb = True) @@ -229,7 +229,7 @@ def replay(item): return itemlist -def play(item): +def findvideos(item): logger.debug() res = requests.get(item.video_url).json() @@ -245,7 +245,7 @@ def play(item): item = item.clone(server='directo', url=url, no_return=True) # , manifest='hls') - return [item] + return support.server(item, itemlist=[item], Download=False, Videolibrary=False) def getUrl(url): @@ -306,7 +306,7 @@ def addinfo(items, item): order=n) if 'Genere' not in key.get('sub_type', '') and ('layout' not in key or key['layout'] == 'single'): - it.action = 'play' + it.action = 'findvideos' it.contentTitle = it.fulltitle else: it.action = 'episodios' diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 266fce1a..35aacdc3 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -196,6 +196,7 @@ def run(item=None): # Special play action if item.action == "play": + # from core.support import dbg;dbg() # define la info para trakt try: from core import trakt_tools @@ -460,6 +461,8 @@ def findvideos(item): if not itemlist: platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60347)) + elif len(itemlist) == 1 or len(itemlist) > 1 and not itemlist[1].server: + run(itemlist[0].clone(no_return=True)) else: platformtools.serverWindow(item, itemlist) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index ce2f759e..62189d19 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -1384,9 +1384,8 @@ def set_player(item, xlistitem, mediaurl, view, strm): if (player_mode == 3 and mediaurl.startswith("rtmp")): player_mode = 0 elif "megacrypter.com" in mediaurl: player_mode = 3 logger.info("mediaurl=" + mediaurl) - + prevent_busy() if player_mode in [0,1]: - prevent_busy() if player_mode in [1]: item.played_time = resume_playback(get_played_time(item)) @@ -1421,13 +1420,14 @@ def set_player(item, xlistitem, mediaurl, view, strm): # if it is a video library file send to mark as seen if strm or item.strm_path: item.options['strm'] = True - # if player_mode == 1: item.options['continue'] = True + if not mediaurl.startswith('plugin'): from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_auto_as_watched(item) # for cases where the audio playback window appears in place of the video one if item.focusOnVideoPlayer: + from core.support import dbg;dbg() while is_playing() and xbmcgui.getCurrentWindowId() != 12006: continue xbmc.sleep(500) @@ -1882,10 +1882,10 @@ def serverWindow(item, itemlist): while not xbmc.Monitor().abortRequested(): played = True if not is_playing(): - if config.get_setting('next_ep') == 3: - xbmc.sleep(500) - if is_playing(): - return + # if config.get_setting('next_ep') == 3: + # xbmc.sleep(500) + # if is_playing(): + # return if config.get_setting('autoplay') or reopen: xbmc.sleep(200) if not db['controls'].get('reopen', False): diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index bec58178..4ea20b5b 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -33,7 +33,6 @@ def mark_auto_as_watched(item): marked = False sync = False next_episode = None - show_server = True mark_time = 0 percentage = float(config.get_setting("watched_setting")) / 100 @@ -68,7 +67,6 @@ def mark_auto_as_watched(item): item.played_time = 0 platformtools.set_played_time(item) if item.options['strm'] : sync = True - show_server = False from specials import videolibrary videolibrary.mark_content_as_watched2(item) if not next_episode: @@ -93,6 +91,7 @@ def mark_auto_as_watched(item): else: item.played_time = 0 db['controls']['reopen'] = False + db.close() platformtools.set_played_time(item) # Silent sync with Trakt @@ -101,19 +100,10 @@ def mark_auto_as_watched(item): while platformtools.is_playing(): xbmc.sleep(100) - # if not show_server and item.play_from != 'window' and not item.no_return: - # xbmc.sleep(200) - # xbmc.executebuiltin('Action(close)') - # xbmc.sleep(500) - if next_episode and next_episode.next_ep and config.get_setting('next_ep') < 3: from platformcode.launcher import run run(next_episode) - # db need to be closed when not used, it will cause freezes - db.close() - # from core.support import dbg;dbg() - # If it is configured to mark as seen if config.get_setting("mark_as_watched", "videolibrary"): threading.Thread(target=mark_as_watched_subThread, args=[item]).start()