add settings for filtered episode name and number of items to show

This commit is contained in:
sfaulds 2017-06-25 16:20:20 +10:00
parent 44ef69b347
commit 1e3738922b
5 changed files with 111 additions and 66 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.embycon"
name="EmbyCon"
version="1.3.6"
version="1.3.7"
provider-name="Team B">
<requires>
<import addon="xbmc.python" version="2.1.0"/>

View File

@ -74,6 +74,14 @@ msgctxt "#30017"
msgid "Show Connected Clients"
msgstr ""
msgctxt "#30018"
msgid "Number of items to show in filtered lists"
msgstr ""
msgctxt "#30019"
msgid "Filtered episode name format"
msgstr ""
msgctxt "#30022"
msgid "Advanced"
msgstr ""

View File

@ -175,7 +175,7 @@ def mainEntryPoint():
if not media_type:
xbmcgui.Dialog().ok(i18n('error'), i18n('no_media_type'))
log.info("EmbyCon -> media_type: " + str(media_type))
getContent(param_url, pluginhandle, media_type)
getContent(param_url, pluginhandle, media_type, params)
elif mode == "PLAY":
PLAY(params, pluginhandle)
@ -433,7 +433,7 @@ def addGUIItem(url, details, extraData, folder=True):
if extraData.get('NumEpisodes') != None:
list_item.setProperty('NumEpisodes', extraData.get('NumEpisodes'))
list_item.setProperty('ItemGUID', extraData.get('guiid'))
#list_item.setProperty('ItemGUID', extraData.get('guiid'))
list_item.setProperty('id', extraData.get('id'))
return (u, list_item, folder)
@ -531,7 +531,7 @@ def setView(viewType):
xbmc.executebuiltin("Container.SetViewMode(%s)" % int(viewNum))
def getContent(url, pluginhandle, media_type):
def getContent(url, pluginhandle, media_type, params):
log.info("== ENTER: getContent ==")
log.info("URL: " + str(url))
log.info("MediaType: " + str(media_type))
@ -552,7 +552,7 @@ def getContent(url, pluginhandle, media_type):
elif media_type == "series":
viewType = "Seasons"
xbmcplugin.setContent(pluginhandle, 'seasons')
elif media_type == "season":
elif media_type == "season" or media_type == "episodes":
viewType = "Episodes"
xbmcplugin.setContent(pluginhandle, 'episodes')
log.info("ViewType: " + viewType)
@ -574,7 +574,11 @@ def getContent(url, pluginhandle, media_type):
progress.close()
return
dirItems = processDirectory(url, result, progress, pluginhandle)
name_format = params.get("name_format", None)
if name_format is not None:
name_format = urllib.unquote(name_format)
dirItems = processDirectory(url, result, progress, name_format)
xbmcplugin.addDirectoryItems(pluginhandle, dirItems)
# set the view mode based on what the user wanted for this view type
@ -589,9 +593,10 @@ def getContent(url, pluginhandle, media_type):
return
def processDirectory(url, results, progress, pluginhandle):
def processDirectory(url, results, progress, name_format = None):
log.info("== ENTER: processDirectory ==")
userid = downloadUtils.getUserId()
#userid = downloadUtils.getUserId()
#name_format = "{SeriesName} - s{SeasonIndex}e{EpisodeIndex} - {ItemName}"
settings = xbmcaddon.Addon(id='plugin.video.embycon')
server = downloadUtils.getServer()
@ -612,45 +617,61 @@ def processDirectory(url, results, progress, pluginhandle):
progress.update(int(percentDone), i18n('processing_item:') + str(current_item))
current_item = current_item + 1
if (item.get("Name") != None):
tempTitle = item.get("Name").encode('utf-8')
else:
tempTitle = i18n('missing_title')
id = str(item.get("Id")).encode('utf-8')
guiid = id
#guiid = id
isFolder = item.get("IsFolder")
item_type = str(item.get("Type")).encode('utf-8')
tempEpisode = ""
if (item.get("IndexNumber") != None):
episodeNum = item.get("IndexNumber")
if episodeNum < 10:
tempEpisode = "0" + str(episodeNum)
tempEpisode = item.get("IndexNumber")
if tempEpisode is not None:
if tempEpisode < 10:
tempEpisode = "0" + str(tempEpisode)
else:
tempEpisode = str(episodeNum)
tempEpisode = str(tempEpisode)
else:
tempEpisode = ""
tempSeason = ""
if (str(item.get("ParentIndexNumber")) != None):
tempSeason = str(item.get("ParentIndexNumber"))
if item.get("ParentIndexNumber") < 10:
tempSeason = "0" + tempSeason
tempSeason = item.get("ParentIndexNumber")
if tempSeason is not None:
if tempSeason < 10:
tempSeason = "0" + str(tempSeason)
else:
tempSeason = str(tempSeason)
else:
tempSeason = ""
if item.get("Type") == "Season":
guiid = item.get("SeriesId")
elif item.get("Type") == "Episode":
prefix = ''
if settings.getSetting('addSeasonNumber') == 'true':
prefix = "S" + str(tempSeason)
# set the item name
# override with name format string from request
if name_format is not None:
nameInfo = {}
nameInfo["ItemName"] = item.get("Name", "").encode('utf-8')
nameInfo["SeriesName"] = item.get("SeriesName", "").encode('utf-8')
nameInfo["SeasonIndex"] = tempSeason
nameInfo["EpisodeIndex"] = tempEpisode
log.debug("FormatName : %s | %s" % (name_format, nameInfo))
tempTitle = name_format.format(**nameInfo).strip()
else:
if (item.get("Name") != None):
tempTitle = item.get("Name").encode('utf-8')
else:
tempTitle = i18n('missing_title')
if item.get("Type") == "Episode":
prefix = ''
if settings.getSetting('addSeasonNumber') == 'true':
prefix = "S" + str(tempSeason)
if settings.getSetting('addEpisodeNumber') == 'true':
prefix = prefix + "E"
if settings.getSetting('addEpisodeNumber') == 'true':
prefix = prefix + "E"
# prefix = str(tempEpisode)
if settings.getSetting('addEpisodeNumber') == 'true':
prefix = prefix + str(tempEpisode)
if prefix != '':
tempTitle = prefix + ' - ' + tempTitle
guiid = item.get("SeriesId")
prefix = prefix + str(tempEpisode)
if prefix != '':
tempTitle = prefix + ' - ' + tempTitle
#guiid = item.get("SeriesId")
#elif item.get("Type") == "Season":
# guiid = item.get("SeriesId")
if (item.get("PremiereDate") != None):
premieredatelist = (item.get("PremiereDate")).split("T")
@ -804,7 +825,7 @@ def processDirectory(url, results, progress, pluginhandle):
'landscape': art['landscape'],
'tvshow.poster': art['tvshow.poster'],
'id': id,
'guiid': guiid,
#'guiid': guiid,
'mpaa': item.get("OfficialRating"),
'rating': item.get("CommunityRating"),
'criticrating': item.get("CriticRating"),
@ -1042,7 +1063,7 @@ def showContent(pluginName, handle, params):
"&IncludeItemTypes=" + item_type)
log.info("showContent Content Url : " + str(contentUrl))
getContent(contentUrl, handle, media_type)
getContent(contentUrl, handle, media_type, params)
def showParentContent(pluginName, handle, params):
log.info("showParentContent Called: " + str(params))
@ -1073,7 +1094,7 @@ def showParentContent(pluginName, handle, params):
"&format=json")
log.info("showParentContent Content Url : " + str(contentUrl))
getContent(contentUrl, handle, media_type)
getContent(contentUrl, handle, media_type, params)
def checkService():
home_window = HomeWindow()

View File

@ -136,6 +136,8 @@ def displaySections():
for collection in collections:
url = (sys.argv[0] + "?url=" + urllib.quote(collection['path']) +
"&mode=GET_CONTENT&media_type=" + collection["media_type"])
if collection.get("name_format") is not None:
url += "&name_format=" + urllib.quote(collection.get("name_format"))
log.info("addMenuDirectoryItem: " + collection.get('title', i18n('unknown')) + " " + str(url))
addMenuDirectoryItem(collection.get('title', i18n('unknown')), url, thumbnail=collection.get("thumbnail"))
@ -168,6 +170,9 @@ def getCollections(detailsString):
if settings.getSetting('show_collections') == "true":
show_collections = "true"
show_x_filtered_items = settings.getSetting("show_x_filtered_items")
filtered_episode_format = settings.getSetting("episode_name_format")
userid = downloadUtils.getUserId()
if userid == None or len(userid) == 0:
@ -228,7 +233,7 @@ def getCollections(detailsString):
'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server),
'path': ('{server}/emby/Users/{userid}/Items' +
'?ParentId=' + item.get("Id") +
'&Limit=20' +
'&Limit=' + show_x_filtered_items +
'&IsVirtualUnaired=false' +
'&IsMissing=False' +
'&Fields=' + detailsString +
@ -237,13 +242,14 @@ def getCollections(detailsString):
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json'),
'media_type': collection_type})
'media_type': collection_type,
'name_format': filtered_episode_format})
collections.append({
'title': item_name + i18n('_recently_added'),
'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server),
'path': ('{server}/emby/Users/{userid}/Items' +
'?ParentId=' + item.get("Id") +
'&Limit=20' +
'&Limit=' + show_x_filtered_items +
'&IsVirtualUnaired=false' +
'&IsMissing=False' +
'&Fields=' + detailsString +
@ -254,13 +260,14 @@ def getCollections(detailsString):
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json'),
'media_type': collection_type})
'media_type': collection_type,
'name_format': filtered_episode_format})
collections.append({
'title': item_name + i18n('_next_up'),
'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server),
'path': ('{server}/emby/Shows/NextUp/?Userid={userid}' +
'&ParentId=' + item.get("Id") +
'&Limit=20' +
'&Limit=' + show_x_filtered_items +
'&Recursive=true' +
'&Fields=' + detailsString +
'&Filters=IsUnplayed,IsNotFolder' +
@ -269,7 +276,8 @@ def getCollections(detailsString):
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json'),
'media_type': collection_type})
'media_type': collection_type,
'name_format': filtered_episode_format})
if collection_type == "movies":
collections.append({
@ -277,7 +285,7 @@ def getCollections(detailsString):
'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server),
'path': ('{server}/emby/Users/{userid}/Items' +
'?ParentId=' + item.get("Id") +
'&Limit=20' +
'&Limit=' + show_x_filtered_items +
'&IsVirtualUnaired=false' +
'&IsMissing=False' +
'&Fields=' + detailsString +
@ -290,7 +298,7 @@ def getCollections(detailsString):
'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server),
'path': ('{server}/emby/Users/{userid}/Items' +
'?ParentId=' + item.get("Id") +
'&Limit=20' +
'&Limit=' + show_x_filtered_items +
'&IsVirtualUnaired=false' +
'&IsMissing=False' +
'&Fields=' + detailsString +
@ -317,7 +325,7 @@ def getCollections(detailsString):
item_data['title'] = i18n('movies_recently_added')
item_data['media_type'] = 'Movies'
item_data['path'] = ('{server}/emby/Users/{userid}/Items' +
'?Limit=20' +
'?Limit=' + show_x_filtered_items +
'&Recursive=true' +
'&SortBy=DateCreated' +
'&Fields=' + detailsString +
@ -332,7 +340,7 @@ def getCollections(detailsString):
item_data['title'] = i18n('movies_in_progress')
item_data['media_type'] = 'Movies'
item_data['path'] = ('{server}/emby/Users/{userid}/Items' +
'?Limit=20' +
'?Limit=' + show_x_filtered_items +
'&Recursive=true' +
'&Fields=' + detailsString +
'&Filters=IsResumable' +
@ -384,10 +392,25 @@ def getCollections(detailsString):
'&format=json')
collections.append(item_data)
item_data = {}
item_data['title'] = i18n('episodes_in_progress')
item_data['media_type'] = 'Episodes'
item_data['path'] = ('{server}/emby/Users/{userid}/Items' +
'?Limit=' + show_x_filtered_items +
'&Recursive=true' +
'&Fields=' + detailsString +
'&Filters=IsResumable' +
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json')
item_data['name_format'] = filtered_episode_format
collections.append(item_data)
item_data = {}
item_data['title'] = i18n('episodes_recently_added')
item_data['media_type'] = 'Season'
item_data['path'] = ('{server}/emby/Users/{userid}/Items?Limit=20' +
item_data['media_type'] = 'Episodes'
item_data['path'] = ('{server}/emby/Users/{userid}/Items' +
'?Limit=' + show_x_filtered_items +
'&Recursive=true' +
'&SortBy=DateCreated' +
'&Fields=' + detailsString +
@ -398,24 +421,14 @@ def getCollections(detailsString):
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json')
collections.append(item_data)
item_data = {}
item_data['title'] = i18n('episodes_in_progress')
item_data['media_type'] = 'Episodes'
item_data['path'] = ('{server}/emby/Users/{userid}/Items?Limit=20' +
'&Recursive=true' +
'&Fields=' + detailsString +
'&Filters=IsResumable' +
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json')
item_data['name_format'] = filtered_episode_format
collections.append(item_data)
item_data = {}
item_data['title'] = i18n('episodes_up_next')
item_data['media_type'] = 'Episodes'
item_data['path'] = ('{server}/emby/Shows/NextUp/?Userid={userid}&Limit=20' +
item_data['path'] = ('{server}/emby/Shows/NextUp/?Userid={userid}' +
'&Limit=' + show_x_filtered_items +
'&Recursive=true' +
'&Fields=' + detailsString +
'&Filters=IsUnplayed,IsNotFolder' +
@ -424,6 +437,7 @@ def getCollections(detailsString):
'&IncludeItemTypes=Episode' +
'&ImageTypeLimit=1' +
'&format=json')
item_data['name_format'] = filtered_episode_format
collections.append(item_data)
item_data = {}

View File

@ -44,6 +44,8 @@
<setting id="include_media" type="bool" label="30182" default="true" visible="true" enable="true" />
<setting id="include_people" type="bool" label="30183" default="false" visible="true" enable="true" />
<setting id="show_collections" type="bool" label="30184" default="true" visible="true" enable="true" />
<setting id="show_x_filtered_items" type="slider" label="30018" default="20" range="5,1,100" option="int" visible="true"/>
<setting id="episode_name_format" type="text" default="{SeriesName} - s{SeasonIndex}e{EpisodeIndex} - {ItemName}" label="30019" />
</category>
<category label="30022"> <!-- Advanced -->
<setting id="logLevel" type="enum" label="30004" values="None|Info|Debug" default="0" />