From f946f7ba6981a5a328d52c8dc1e12d1fdf971264 Mon Sep 17 00:00:00 2001 From: im85288 Date: Mon, 22 Jun 2015 20:18:00 +0100 Subject: [PATCH] tv tunes now accepts both music/video themes in the same nfo --- addon.xml | 2 +- resources/lib/Entrypoint.py | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/addon.xml b/addon.xml index c2153b58..fad2337b 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/Entrypoint.py b/resources/lib/Entrypoint.py index 7f863fff..75ef56ae 100644 --- a/resources/lib/Entrypoint.py +++ b/resources/lib/Entrypoint.py @@ -200,6 +200,18 @@ def getThemeMedia(): else: playurl = playUtils.directStream(result, server, theme[u'Id']) pathstowrite += ('%s' % playurl.encode('utf-8')) + + # Check if the item has theme songs and add them + url = "{server}/mediabrowser/Items/%s/ThemeSongs?format=json" % itemId + result = doUtils.downloadUrl(url) + + # May be more than one theme + for theme in result[u'Items']: + if playback == "DirectPlay": + playurl = playUtils.directPlay(theme) + else: + playurl = playUtils.directStream(result, server, theme[u'Id'], "Audio") + pathstowrite += ('%s' % playurl.encode('utf-8')) nfo_file.write( '%s' % pathstowrite @@ -208,7 +220,7 @@ def getThemeMedia(): nfo_file.close() # Get Ids with Theme songs - itemIds = {} + musicitemIds = {} for view in userViews: url = "{server}/mediabrowser/Users/{UserId}/Items?HasThemeSong=True&ParentId=%s&format=json" % view result = doUtils.downloadUrl(url) @@ -217,21 +229,22 @@ def getThemeMedia(): itemId = item[u'Id'] folderName = item[u'Name'] folderName = utils.normalize_string(folderName.encode('utf-8')) - itemIds[itemId] = folderName + musicitemIds[itemId] = folderName # Get paths - for itemId in itemIds: - nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/%s/" % itemIds[itemId]) + for itemId in musicitemIds: + + # if the item was already processed with video themes back out + if itemId in itemIds: + continue + + nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/%s/" % musicitemIds[itemId]) # Create folders for each content if not xbmcvfs.exists(nfo_path): xbmcvfs.mkdir(nfo_path) # Where to put the nfos nfo_path = "%s%s" % (nfo_path, "tvtunes.nfo") - # if the nfo already exists assume a theme video was added so back out because if both are added it rotates between theme video and theme music - if xbmcvfs.exists(nfo_path): - continue - url = "{server}/mediabrowser/Items/%s/ThemeSongs?format=json" % itemId result = doUtils.downloadUrl(url)