diff --git a/core/support.py b/core/support.py index 244c385d..6f87c0e5 100755 --- a/core/support.py +++ b/core/support.py @@ -1278,26 +1278,22 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru videoitem.server = videoitem.server.lower() if videoitem.video_urls or srv_param.get('active', False): - title = typo(item.contentTitle.strip(), 'bold') if item.contentType == 'movie' or (config.get_localized_string(30161) in item.title) else item.title + vi = item.clone(server=videoitem.server, + serverName=videoitem.serverName, + url=videoitem.url, + videoUrls= videoitem.videoUrlsn, + ch_name=channeltools.get_channel_parameters(item.channel)['title'], + action = "play") - quality = videoitem.quality if videoitem.quality else item.quality if item.quality else '' - videoitem.title = (title if item.channel not in ['url'] else '')\ - + (typo(videoitem.title, '_ color kod [] bold') if videoitem.title else "")\ - + (typo(videoitem.quality, '_ color kod []') if videoitem.quality else "")\ - + (typo(videoitem.contentLanguage, '_ color kod []') if videoitem.contentLanguage else "")\ - + (typo(videoitem.extraInfo, '_ color kod []') if videoitem.extraInfo else "") - videoitem.plot = typo(videoitem.title, 'bold') + (typo(quality, '_ [] bold') if quality else '') - videoitem.channel = item.channel - videoitem.fulltitle = item.fulltitle - videoitem.show = item.show - if not videoitem.video_urls: videoitem.thumbnail = item.thumbnail - videoitem.contentType = item.contentType - videoitem.infoLabels = item.infoLabels - videoitem.quality = quality - videoitem.referer = item.referer if item.referer else item.url - videoitem.action = "play" - # videoitem.nfo = item.nfo - # videoitem.strm_path = item.strm_path + if videoitem.title: vi.serverName = videoitem.title + if videoitem.quality: vi.quality = videoitem.quality + if not vi.referer: vi.referer = item.url + vi.contentFanart = item.infoLabels['fanart'] + vi.contentThumb = item.infoLabels['fanart'] + if videoitem.forcethumb: + vi.thumbnail = videoitem.thumbnail + vi.forcethumb = True + videoitem = vi return videoitem # non threaded for webpdb diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 753de632..96b52db8 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -233,24 +233,8 @@ def run(item=None): # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": - from core import servertools - if reload: - item.autoplay = True - platformtools.fakeVideo() - - # First checks if channel has a "findvideos" function - if hasattr(channel, 'findvideos'): - itemlist = getattr(channel, item.action)(item) - - # If not, uses the generic findvideos function - else: - logger.debug("No channel 'findvideos' method, " "executing core method") - itemlist = servertools.find_video_items(item) - - if config.get_setting("max_links", "videolibrary") != 0: - itemlist = limit_itemlist(itemlist) - - platformtools.render_items(itemlist, item) + findvideos(item) + # platformtools.render_items(itemlist, item) # Special action for adding a movie to the library elif item.action == "add_pelicula_to_library": @@ -446,6 +430,37 @@ def limit_itemlist(itemlist): return itemlist +def findvideos(item): + logger.debug('Executing channel', item.channel, 'method', item.action) + channel = platformtools.channelImport(item.channel) + if not channel: + logger.debug('Channel', item.channel, 'not exist!') + return + from core import servertools + + p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60683)) + p_dialog.update(0) + + # First checks if channel has a "findvideos" function + if hasattr(channel, 'findvideos'): + itemlist = getattr(channel, item.action)(item) + + # If not, uses the generic findvideos function + else: + logger.debug('No channel "findvideos" method, executing core method') + itemlist = servertools.find_video_items(item) + + itemlist = limit_itemlist(itemlist) + + p_dialog.update(100) + p_dialog.close() + + # If there is only one server play it immediately + # if len(itemlist) == 1 or len(itemlist) > 1 and not itemlist[1].server: + # play(itemlist[0].clone(no_return=True)) + # else: + platformtools.serverWindow(item, itemlist) + def play_from_library(item): """ The .strm files when played from kodi, this expects it to be a "playable" file so it cannot contain @@ -458,110 +473,10 @@ def play_from_library(item): @param item: item with information """ - def get_played_time(item): - from core import videolibrarytools - - if item.contentType == 'movie': - nfo_path = item.nfo - if nfo_path.startswith('\\') or nfo_path.startswith('/'): - nfo_path = filetools.join(videolibrarytools.MOVIES_PATH, nfo_path) - - else: - nfo_path =item.strm_path.replace('strm','nfo') - if nfo_path.startswith('\\') or nfo_path.startswith('/'): - nfo_path = filetools.join(videolibrarytools.TVSHOWS_PATH, nfo_path) - - if nfo_path and filetools.isfile(nfo_path): - head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path) - sleep(1) - played_time = platformtools.get_played_time(item_nfo) - - else: played_time = 0 - - return played_time - - import xbmcgui, xbmcplugin, xbmc - from time import sleep - - if not item.autoplay and not item.next_ep: - platformtools.fakeVideo() + item.action = item.next_action if item.next_action else 'findvideos' + logger.debug('Executing channel', item.channel, 'method', item.action) + if item.action == 'findvideos': + item.fakevideo = True + return run(item) - itemlist=[] - item.fromLibrary = True - item.window = True - logger.debug() - - # Modify the action (currently the video library needs "findvideos" since this is where the sources are searched - item.action = item.next_action if item.next_action else "findvideos" - - if item.contentType == 'movie' or item.contentType != 'movie' and config.get_setting('next_ep') < 3: - window_type = config.get_setting("window_type", "videolibrary") - else: window_type = 1 - - # and launch kodi again - if (xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1) or item.action != 'findvideos': - xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")") - - else: - # Pop-up window - from specials import videolibrary - from core.channeltools import get_channel_parameters - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60683)) - p_dialog.update(0, '') - item.play_from = 'window' - itemlist = videolibrary.findvideos(item) - p_dialog.update(100, ''); sleep(0.5); p_dialog.close() - played = False - - # The number of links to show is limited - if config.get_setting("max_links", "videolibrary") != 0: itemlist = limit_itemlist(itemlist) - # The list of links is slightly "cleaned" - if config.get_setting("replace_VD", "videolibrary") == 1: itemlist = reorder_itemlist(itemlist) - - if len(itemlist) > 0: - reopen = False - - while not xbmc.Monitor().abortRequested(): - played = True - # if config.get_setting('next_ep') == 3 and xbmc.Player().playnext: - # return - # The user chooses the mirror - if not platformtools.is_playing(): - if config.get_setting('next_ep') == 3: - xbmc.sleep(500) - if platformtools.is_playing(): - return - if config.get_setting('autoplay') or reopen: - played_time = get_played_time(item) - if not played_time and played: - return - - options = [] - selection_implementation = 0 - for item in itemlist: - item.thumbnail = config.get_online_server_thumb(item.server) - quality = '[B][' + item.quality + '][/B]' if item.quality else '' - if item.server: - path = filetools.join(config.get_runtime_path(), 'servers', item.server.lower() + '.json') - name = jsontools.load(open(path, "rb").read())['name'] - if name.startswith('@'): name = config.get_localized_string(int(name.replace('@',''))) - logger.debug(item) - it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s [%s]' % (name, quality, item.contentTitle, get_channel_parameters(item.contentChannel)['title'])) - it.setArt({'thumb':item.thumbnail}) - options.append(it) - else: - selection_implementation += 1 - # The selection window opens - if (item.contentSerieName and item.contentSeason and item.contentEpisodeNumber): head = ("%s - %sx%s | %s" % (item.contentSerieName, item.contentSeason, item.contentEpisodeNumber, config.get_localized_string(30163))) - else: head = config.get_localized_string(30163) - selection = platformtools.dialog_select(head, options, preselect= -1, useDetails=True) - if selection == -1: - return - else: - item = videolibrary.play(itemlist[selection + selection_implementation])[0] - platformtools.play_video(item) - reopen = True - if item.server == 'torrent': return - # if (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break - diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 14fb7aad..4f0d8df8 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -627,7 +627,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs): # Add to kodfavoritos (My links) if item.channel not in ["favorites", "videolibrary", "help", ""] and parent_item.channel != "favorites": context_commands.append( (config.get_localized_string(70557), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action})))) - # Add to kodfavoritos + # Add to kodfavoritos if parent_item.channel == 'globalsearch': context_commands.append( (config.get_localized_string(30155), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "favorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action})))) # Search in other channels @@ -1386,7 +1386,7 @@ def set_player(item, xlistitem, mediaurl, view, strm): logger.info("mediaurl=" + mediaurl) if player_mode in [0,1]: - prevent_busy(item) + prevent_busy() if player_mode in [1]: item.played_time = resume_playback(get_played_time(item)) @@ -1490,7 +1490,7 @@ def play_torrent(item, xlistitem, mediaurl): selection = 0 if selection >= 0: - prevent_busy(item) + prevent_busy() mediaurl = urllib.quote_plus(item.url) torr_client = torrent_options[selection][0] @@ -1684,10 +1684,137 @@ def prevent_busy(item=None): xbmc.executebuiltin('Dialog.Close(all,true)') -def fakeVideo(): - xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, - xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))) - sleep = 200 - while not is_playing(): - xbmc.sleep(sleep) - xbmc.Player().stop() +def fakeVideo(sleep = False): + mediaurl = os.path.join(config.get_runtime_path(), "resources", "kod.mp4") + xbmc.executebuiltin("PlayMedia(" + mediaurl + ")") + if sleep: + while is_playing(): + xbmc.sleep(sleep) + xbmc.Player().stop() + + +def channelImport(channelId): + from core import filetools + ch = '' + path = filetools.join(config.get_runtime_path(), '{}', channelId + ".py") + if filetools.exists(path.format('channels')): ch = 'channels.{}'.format(channelId) + elif filetools.exists(path.format('specials')): ch = 'specials.{}'.format(channelId) + elif filetools.exists(path.format('platformcode')): ch = 'platformcode.{}'.format(channelId) + elif filetools.exists(path.format('core')): ch = 'core.{}'.format(channelId) + if ch: + channel = __import__(ch, None, None, [ch]) + else: + logger.info('Channel {} not Exist'.format(channelId)) + channel = None + return channel + +def serverWindow(item, itemlist): + LEFT = 1 + RIGHT = 2 + UP = 3 + DOWN = 4 + ENTER = 7 + EXIT = 10 + BACKSPACE = 92 + + class ServerWindow(xbmcgui.WindowXMLDialog): + def start(self, item, itemlist): + self.itemlist = itemlist + self.item = item + self.servers = [] + items = [] + self.selection = -1 + self.actions = {} + for videoitem in self.itemlist: + videoitem.thumbnail = config.get_online_server_thumb(videoitem.server) + quality = ' [' + videoitem.quality + ']' if videoitem.quality else '' + if videoitem.server: + color = scrapertools.find_single_match(videoitem.alive, r'(FF[^\]]+)') + it = xbmcgui.ListItem('{}{}'.format(videoitem.serverName, quality)) + + # format Title + if videoitem.contentSeason and videoitem.contentEpisodeNumber: + title = '{}x{:02d}. {}'.format(videoitem.contentSeason, videoitem.contentEpisodeNumber, videoitem.contentTitle) + elif videoitem.contentEpisodeNumber: + title = '{:02d}. {}'.format(videoitem.contentEpisodeNumber, videoitem.contentTitle) + else: + title = videoitem.title + + it.setProperties({'name': title, 'channel': videoitem.ch_name, 'color': color if color else 'FF0082C2'}) + it.setArt({'poster':videoitem.contentThumbnail, 'thumb':videoitem.thumbnail, 'fanart':videoitem.contentFanart}) + self.servers.append(it) + items.append(videoitem) + else: + it = xbmcgui.ListItem(videoitem.title) + if 'library' in videoitem.action: + self.actions['videolibrary'] = videoitem + if 'download' in videoitem.action: + self.actions['download'] = videoitem + + self.itemlist = items + self.doModal() + return self.selection + + def onInit(self): + self.SERVERS = self.getControl(100) + self.VIDEOLIBRARY = self.getControl(102) + self.DOWNLOAD = self.getControl(103) + if 'videolibrary' not in self.actions.keys(): + self.VIDEOLIBRARY.setVisible(False) + if 'download' not in self.actions.keys(): + self.DOWNLOAD.setVisible(False) + self.SERVERS.reset() + self.SERVERS.addItems(self.servers) + self.setFocusId(100) + # from core.support import dbg;dbg() + + def onAction(self, action): + action = action.getId() + focus = self.getFocusId() + if action in [UP, DOWN, LEFT, RIGHT] and focus not in [100, 101, 102, 103]: + self.setFocusId(100) + elif action in [EXIT, BACKSPACE]: + self.close() + + def onClick(self, control): + if control == 100: + self.selection = self.itemlist[self.SERVERS.getSelectedPosition()].clone(window=True) + self.close() + elif control in [101]: + self.close() + elif control in [102]: + self.run(self.actions['videolibrary']) + elif control in [103]: + self.run(self.actions['download']) + + def run(self, action): + from platformcode.launcher import run + run(action) + + + + if itemlist: + reopen = False + 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('autoplay') or reopen: + played_time = get_played_time(item) + if not played_time and played: + return + + selection = ServerWindow('Servers.xml', config.get_runtime_path()).start(item, itemlist) + + if selection == -1: + if item.fakevideo: + return fakeVideo() + else: return + + else: + from platformcode.launcher import run + run(selection) + reopen = True diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index cfff9235..efab70e8 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -97,10 +97,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(700) - xbmc.executebuiltin('Action(ParentDir)') - xbmc.sleep(500) + # 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 @@ -109,6 +109,7 @@ def mark_auto_as_watched(item): # db need to be closed when not used, it will cause freezes from core import db db.close() + # from core.support import dbg;dbg() # If it is configured to mark as seen if config.get_setting("mark_as_watched", "videolibrary"): diff --git a/resources/skins/Default/720p/Servers.xml b/resources/skins/Default/720p/Servers.xml new file mode 100644 index 00000000..a6066104 --- /dev/null +++ b/resources/skins/Default/720p/Servers.xml @@ -0,0 +1,237 @@ + + + 0.52 + + 0 + 0 + + + + Servers Group + + + + + + + + Window Background + 100% + 100% + white.png + + + Fanart + 100% + 100% + scale + $INFO[Container(100).ListItem.Art(fanart)] + + + Poster + 0 + 0 + 480 + 720 + $INFO[Container(100).ListItem.Art(poster)] + + + + + + + + + + + Main Title + 520 + 40 + 1150 + 30 + font13 + FFFFFFFF + 00000000 + left + center + + + + + + + + + + + + Servers List + 40 + 520 + 700 + 570 + 101 + 101 + 101 + + + + + + + + + 300 + + + Servers Icon + 5 + 5 + 120 + 120 + $INFO[ListItem.Art(thumb)] + scale + + + Server Title + 150 + 30 + 450 + 30 + font13 + FFFFFFFF + 00000000 + left + center + + + + Channel + 150 + 65 + 450 + 30 + font13 + FFAAAAAA + 00000000 + left + center + + + + + + Selection Background + 700 + 130 + white.png + scale + + + Servers Color + 0 + 0 + 130 + 130 + white.png + scale + + + Servers Icon + 5 + 5 + 120 + 120 + $INFO[ListItem.Art(thumb)] + scale + + + Server Title + 150 + 30 + 450 + 30 + font13 + FF232323 + 00000000 + left + center + + + + Channel + 150 + 65 + 450 + 30 + font13 + FF555555 + 00000000 + left + center + + + + + + + 30 + 30 + + + + + + + + + + Close + 0 + 0 + 40 + 40 + 100 + 100 + 102 + 103 + 100 + 100 + close.png + close.png + + + + videolibrary + 0 + 40 + 40 + 40 + 100 + 100 + 103 + 100 + 101 + add.png + add.png + + + Download + 0 + 40 + Conditional + 40 + 40 + 100 + 100 + 100 + 102 + 101 + down.png + down.png + + + + + + \ No newline at end of file diff --git a/specials/videolibrary.json b/specials/videolibrary.json index c92a3cbb..97952ade 100644 --- a/specials/videolibrary.json +++ b/specials/videolibrary.json @@ -62,6 +62,7 @@ "type": "list", "label": "@60618", "default": 0, + "visible": false, "enabled": "!eq(-4,@60615)", "lvalues": [ "@60619", @@ -110,7 +111,7 @@ "label": "@60653", "default": true, "enabled": "eq(-1,TVDB)", - "visible": true + "visible": false }, { "id": "info_language", @@ -127,18 +128,6 @@ "pt" ] }, - { - "id": "window_type", - "type": "list", - "label": "@60621", - "default": 0, - "enabled": true, - "visible": true, - "lvalues": [ - "@60622", - "@60623" - ] - }, { "id": "max_links", "type": "list", @@ -162,7 +151,7 @@ "type": "bool", "label": "@60626", "enabled": true, - "visible": true, + "visible": false, "default": false }, { @@ -170,7 +159,7 @@ "type": "bool", "label": "@60627", "enabled": true, - "visible": true, + "visible": false, "default": false }, { @@ -178,7 +167,7 @@ "type": "bool", "label": "@60628", "enabled": "eq(-4,@60623)", - "visible": true, + "visible": false, "default": false }, { @@ -223,7 +212,7 @@ "type": "bool", "label": "@60638", "default": false, - "visible": true, + "visible": false, "enabled": "eq(-3,true)" }, { @@ -231,7 +220,7 @@ "type": "bool", "label": "@60639", "default": true, - "visible": true, + "visible": false, "enabled": "eq(-1,true)" }, {