This commit is contained in:
Croneter 2018-06-15 14:05:48 +02:00
parent 18c6d8f784
commit bf8f238af4
2 changed files with 28 additions and 28 deletions

View file

@ -153,14 +153,14 @@ class Main():
elif '/extrafanart' in argv[0]: elif '/extrafanart' in argv[0]:
plexpath = argv[2][1:] plexpath = argv[2][1:]
plexid = itemid plexid = itemid
entrypoint.getExtraFanArt(plexid, plexpath) entrypoint.extra_fanart(plexid, plexpath)
entrypoint.getVideoFiles(plexid, plexpath) entrypoint.get_video_files(plexid, plexpath)
# Called by e.g. 3rd party plugin video extras # Called by e.g. 3rd party plugin video extras
elif ('/Extras' in argv[0] or '/VideoFiles' in argv[0] or elif ('/Extras' in argv[0] or '/VideoFiles' in argv[0] or
'/Extras' in argv[2]): '/Extras' in argv[2]):
plexId = itemid or None plexId = itemid or None
entrypoint.getVideoFiles(plexId, params) entrypoint.get_video_files(plexId, params)
else: else:
entrypoint.show_main_menu(content_type=params.get('content_type')) entrypoint.show_main_menu(content_type=params.get('content_type'))

View file

@ -386,13 +386,13 @@ def recent_episodes(mediatype, tagname, limit):
append_show_title = settings('RecentTvAppendShow') == 'true' append_show_title = settings('RecentTvAppendShow') == 'true'
append_sxxexx = settings('RecentTvAppendSeason') == 'true' append_sxxexx = settings('RecentTvAppendSeason') == 'true'
# First we get a list of all the TV shows - filtered by tag # First we get a list of all the TV shows - filtered by tag
allshowsIds = set() show_ids = set()
params = { params = {
'sort': {'order': "descending", 'method': "dateadded"}, 'sort': {'order': "descending", 'method': "dateadded"},
'filter': {'operator': "is", 'field': "tag", 'value': "%s" % tagname}, 'filter': {'operator': "is", 'field': "tag", 'value': "%s" % tagname},
} }
for tv_show in js.get_tv_shows(params): for tv_show in js.get_tv_shows(params):
allshowsIds.add(tv_show['tvshowid']) show_ids.add(tv_show['tvshowid'])
params = { params = {
'sort': {'order': "descending", 'method': "dateadded"}, 'sort': {'order': "descending", 'method': "dateadded"},
'properties': ["title", "playcount", "season", "episode", "showtitle", 'properties': ["title", "playcount", "season", "episode", "showtitle",
@ -408,7 +408,7 @@ def recent_episodes(mediatype, tagname, limit):
'value': "1" 'value': "1"
} }
for episode in js.get_episodes(params): for episode in js.get_episodes(params):
if episode['tvshowid'] in allshowsIds: if episode['tvshowid'] in show_ids:
listitem = create_listitem(episode, listitem = create_listitem(episode,
append_show_title=append_show_title, append_show_title=append_show_title,
append_sxxexx=append_sxxexx) append_sxxexx=append_sxxexx)
@ -421,14 +421,14 @@ def recent_episodes(mediatype, tagname, limit):
xbmcplugin.endOfDirectory(handle=HANDLE) xbmcplugin.endOfDirectory(handle=HANDLE)
def getVideoFiles(plexId, params): def get_video_files(plex_id, params):
""" """
GET VIDEO EXTRAS FOR LISTITEM GET VIDEO EXTRAS FOR LISTITEM
returns the video files for the item as plugin listing, can be used for returns the video files for the item as plugin listing, can be used for
browsing the actual files or videoextras etc. browsing the actual files or videoextras etc.
""" """
if plexId is None: if plex_id is None:
filename = params.get('filename') filename = params.get('filename')
if filename is not None: if filename is not None:
filename = filename[0] filename = filename[0]
@ -436,19 +436,19 @@ def getVideoFiles(plexId, params):
regex = re.compile(r'''library/metadata/(\d+)''') regex = re.compile(r'''library/metadata/(\d+)''')
filename = regex.findall(filename) filename = regex.findall(filename)
try: try:
plexId = filename[0] plex_id = filename[0]
except IndexError: except IndexError:
pass pass
if plexId is None: if plex_id is None:
LOG.info('No Plex ID found, abort getting Extras') LOG.info('No Plex ID found, abort getting Extras')
return xbmcplugin.endOfDirectory(HANDLE) return xbmcplugin.endOfDirectory(HANDLE)
item = GetPlexMetadata(plexId) item = GetPlexMetadata(plex_id)
try: try:
path = item[0][0][0].attrib['file'] path = item[0][0][0].attrib['file']
except: except (TypeError, IndexError, AttributeError, KeyError):
LOG.error('Could not get file path for item %s' % plexId) LOG.error('Could not get file path for item %s' % plex_id)
return xbmcplugin.endOfDirectory(HANDLE) return xbmcplugin.endOfDirectory(HANDLE)
# Assign network protocol # Assign network protocol
if path.startswith('\\\\'): if path.startswith('\\\\'):
@ -463,17 +463,17 @@ def getVideoFiles(plexId, params):
for root, dirs, files in walk(path): for root, dirs, files in walk(path):
for directory in dirs: for directory in dirs:
item_path = try_encode(join(root, directory)) item_path = try_encode(join(root, directory))
li = ListItem(item_path, path=item_path) listitem = ListItem(item_path, path=item_path)
xbmcplugin.addDirectoryItem(handle=HANDLE, xbmcplugin.addDirectoryItem(handle=HANDLE,
url=item_path, url=item_path,
listitem=li, listitem=listitem,
isFolder=True) isFolder=True)
for file in files: for file in files:
item_path = try_encode(join(root, file)) item_path = try_encode(join(root, file))
li = ListItem(item_path, path=item_path) listitem = ListItem(item_path, path=item_path)
xbmcplugin.addDirectoryItem(handle=HANDLE, xbmcplugin.addDirectoryItem(handle=HANDLE,
url=file, url=file,
listitem=li) listitem=listitem)
break break
else: else:
LOG.error('Kodi cannot access folder %s' % path) LOG.error('Kodi cannot access folder %s' % path)
@ -481,30 +481,30 @@ def getVideoFiles(plexId, params):
@catch_exceptions(warnuser=False) @catch_exceptions(warnuser=False)
def getExtraFanArt(plexid, plexPath): def extra_fanart(plex_id, plex_path):
""" """
Get extrafanart for listitem Get extrafanart for listitem
will be called by skinhelper script to get the extrafanart will be called by skinhelper script to get the extrafanart
for tvshows we get the plexid just from the path for tvshows we get the plex_id just from the path
""" """
LOG.debug('Called with plexid: %s, plexPath: %s' % (plexid, plexPath)) LOG.debug('Called with plex_id: %s, plex_path: %s', plex_id, plex_path)
if not plexid: if not plex_id:
if "plugin.video.plexkodiconnect" in plexPath: if "plugin.video.plexkodiconnect" in plex_path:
plexid = plexPath.split("/")[-2] plex_id = plex_path.split("/")[-2]
if not plexid: if not plex_id:
LOG.error('Could not get a plexid, aborting') LOG.error('Could not get a plex_id, aborting')
return xbmcplugin.endOfDirectory(HANDLE) return xbmcplugin.endOfDirectory(HANDLE)
# We need to store the images locally for this to work # We need to store the images locally for this to work
# because of the caching system in xbmc # because of the caching system in xbmc
fanartDir = try_decode(translatePath( fanartDir = try_decode(translatePath(
"special://thumbnails/plex/%s/" % plexid)) "special://thumbnails/plex/%s/" % plex_id))
if not exists_dir(fanartDir): if not exists_dir(fanartDir):
# Download the images to the cache directory # Download the images to the cache directory
makedirs(fanartDir) makedirs(fanartDir)
xml = GetPlexMetadata(plexid) xml = GetPlexMetadata(plex_id)
if xml is None: if xml is None:
LOG.error('Could not download metadata for %s' % plexid) LOG.error('Could not download metadata for %s', plex_id)
return xbmcplugin.endOfDirectory(HANDLE) return xbmcplugin.endOfDirectory(HANDLE)
api = API(xml[0]) api = API(xml[0])