diff --git a/platformcode/contextmenu/contextmenu.json b/platformcode/contextmenu/contextmenu.json index f0d9b60c..0bd8617f 100644 --- a/platformcode/contextmenu/contextmenu.json +++ b/platformcode/contextmenu/contextmenu.json @@ -1,4 +1,5 @@ [ "platformcode.contextmenu.search", - "platformcode.contextmenu.update_tv_show" + "platformcode.contextmenu.update_tv_show", + "platformcode.contextmenu.trailer" ] \ No newline at end of file diff --git a/platformcode/contextmenu/search.py b/platformcode/contextmenu/search.py index b7203520..9dd82078 100644 --- a/platformcode/contextmenu/search.py +++ b/platformcode/contextmenu/search.py @@ -107,7 +107,7 @@ def execute(): contentType= mediatype, mode="search", contextual= True, - text= title, + text=title, type= mediatype, infoLabels= { 'tmdb_id': tmdbid, diff --git a/platformcode/contextmenu/trailer.py b/platformcode/contextmenu/trailer.py new file mode 100644 index 00000000..6ad64c31 --- /dev/null +++ b/platformcode/contextmenu/trailer.py @@ -0,0 +1,23 @@ +import xbmc + +from core.item import Item +from platformcode import config + + +def get_menu_items(): + return [(config.get_localized_string(60359), execute)] + + +def execute(): + tmdbid = xbmc.getInfoLabel('ListItem.Property(tmdb_id)') + year = xbmc.getInfoLabel('ListItem.Year') + mediatype = xbmc.getInfoLabel('ListItem.DBTYPE') + title = xbmc.getInfoLabel('ListItem.Title') + if mediatype in ('episode', 'season'): + mediatype = 'tvshow' + title = xbmc.getInfoLabel('ListItem.TVShowTitle') + + item = Item(channel="trailertools", action="buscartrailer", search_title=title, contentType=mediatype, + year=year, contentTitle=title, contextual=True) + item.infoLabels['tmdb_id'] = tmdbid + xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") diff --git a/platformcode/contextmenu/update_tv_show.py b/platformcode/contextmenu/update_tv_show.py index 3f44530e..fd507aef 100644 --- a/platformcode/contextmenu/update_tv_show.py +++ b/platformcode/contextmenu/update_tv_show.py @@ -9,6 +9,9 @@ from core.item import Item from lib.sambatools import libsmb as samba from core import scrapertools, support +path = '' +mediatype = '' + def exists(path, silent=False, vfs=True): path = xbmc.translatePath(path) @@ -105,26 +108,75 @@ def execute_sql(sql): return records +def get_id(): + global mediatype + + mediatype = xbmc.getInfoLabel('ListItem.DBTYPE') + if mediatype == 'tvshow': + dbid = xbmc.getInfoLabel('ListItem.DBID') + elif mediatype in ('season', 'episode'): + dbid = xbmc.getInfoLabel('ListItem.TvShowDBID') + else: + dbid = '' + return dbid + def check_condition(): # support.dbg() - dbid = xbmc.getInfoLabel('ListItem.TvShowDBID') - path = search_paths(dbid) - if path: - return True - return False + global path + path = search_paths(get_id()) + return path def get_menu_items(): logger.debug('get menu item') if check_condition(): - return [(config.get_localized_string(70269), execute)] + items = [(config.get_localized_string(70269), update)] + # if config.get_setting('downloadenabled'): + # from core import videolibrarytools + # from core import filetools + # if xbmc.getInfoLabel('ListItem.FilenameAndPath'): + # item = Item().fromurl(filetools.read(xbmc.getInfoLabel('ListItem.FilenameAndPath'))) + # else: + # item = videolibrarytools.read_nfo(path + 'tvshow.nfo')[1] + # if item: + # item_url = item.tourl() + # + # Download movie + # if mediatype == "movie": + # items.append((config.get_localized_string(60354), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?%s&%s)" % (item_url, + # 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action)))) + # + # elif item.contentSerieName: + # Download series + # if mediatype == "tvshow" and item.action not in ['findvideos']: + # if item.channel == 'videolibrary': + # items.append((config.get_localized_string(60003), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?%s&%s)" % ( + # item_url, + # 'channel=downloads&action=save_download&unseen=true&from_channel=' + item.channel + '&from_action=' + item.action)))) + # items.append((config.get_localized_string(60355), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?%s&%s)" % ( + # item_url, + # 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action)))) + # items.append((config.get_localized_string(60357), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?%s&%s)" % ( + # item_url, + # 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action)))) + # Download episode + # elif mediatype == "episode" and item.action in ['findvideos']: + # items.append((config.get_localized_string(60356), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?%s&%s)" % ( + # item_url, + # 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action)))) + # Download season + # elif mediatype == "season": + # items.append((config.get_localized_string(60357), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?%s&%s)" % ( + # item_url, + # 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action)))) + + return items else: return [] - -def execute(): - dbid = xbmc.getInfoLabel('ListItem.TvShowDBID') +def update(): + dbid = get_id() path = search_paths(dbid) if path: item = Item(action="update_tvshow", channel="videolibrary", path=path) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 312066df..8c87fb38 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -640,7 +640,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs): context_commands.append((config.get_localized_string(60354), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) elif item.contentSerieName: - # Descargar series + # Download series if item.contentType == "tvshow" and item.action not in ['findvideos']: if item.channel == 'videolibrary': context_commands.append((config.get_localized_string(60003), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&unseen=true&from_channel=' + item.channel + '&from_action=' + item.action))) diff --git a/specials/trailertools.py b/specials/trailertools.py index c0792973..0790788e 100644 --- a/specials/trailertools.py +++ b/specials/trailertools.py @@ -6,6 +6,7 @@ from __future__ import division # from builtins import str +import random import sys from channelselector import get_thumb @@ -199,6 +200,8 @@ def youtube_search(item): else: title = urllib.quote(title) title = title.replace("%20", "+") + httptools.set_cookies({'domain': 'youtube.com', 'name': 'CONSENT', + 'value': 'YES+cb.20210328-17-p0.en+FX+' + str(random.randint(100, 999))}) data = httptools.downloadpage("https://www.youtube.com/results?sp=EgIQAQ%253D%253D&search_query=" + title).data patron = r'thumbnails":\[\{"url":"(https://i.ytimg.com/vi[^"]+).*?' patron += r'text":"([^"]+).*?'