Skip to content

Commit

Permalink
add season handling
Browse files Browse the repository at this point in the history
  • Loading branch information
antonsoroko committed Mar 14, 2021
1 parent c41529f commit b852662
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<label>My submenu</label>
<item library="context_play.py">
<label>32000</label>
<visible>StringCompare(ListItem.dbtype,movie) | StringCompare(ListItem.dbtype,episode) | String.IsEqual(ListItem.dbtype,movie) | String.IsEqual(ListItem.dbtype,episode)</visible>
<visible>StringCompare(ListItem.dbtype,movie) | StringCompare(ListItem.dbtype,episode) | StringCompare(ListItem.dbtype,season) | String.IsEqual(ListItem.dbtype,movie) | String.IsEqual(ListItem.dbtype,episode) | String.IsEqual(ListItem.dbtype,season)</visible>
</item>
<item library="context_download.py">
<label>32012</label>
<visible>StringCompare(ListItem.dbtype,movie) | StringCompare(ListItem.dbtype,episode) | String.IsEqual(ListItem.dbtype,movie) | String.IsEqual(ListItem.dbtype,episode)</visible>
<visible>StringCompare(ListItem.dbtype,movie) | StringCompare(ListItem.dbtype,episode) | StringCompare(ListItem.dbtype,season) | String.IsEqual(ListItem.dbtype,movie) | String.IsEqual(ListItem.dbtype,episode) | String.IsEqual(ListItem.dbtype,season)</visible>
</item>
<!-- <item library="context_menu.py">
<label>32001</label>
Expand Down
18 changes: 16 additions & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,27 @@ def doDownload():
def getDbId():
infolabel = xbmc.getInfoLabel('ListItem.Label')
truelabel = sys.listitem.getLabel()

if infolabel == truelabel and xbmc.getInfoLabel('ListItem.DBID'):
dbid = xbmc.getInfoLabel('ListItem.DBID')
elif 'elementum' in sys.listitem.getfilename():
dbid = sys.listitem.getfilename().split('?')[0].rstrip('/').split('/')[-1]
else:
if xbmc.getInfoLabel('ListItem.Episode') and xbmc.getInfoLabel('ListItem.TVSHowTitle') and xbmc.getInfoLabel('ListItem.Season'):
season = int(xbmc.getInfoLabel('ListItem.Season'))
episode = int(xbmc.getInfoLabel('ListItem.Episode'))

dbid = '{} s{:02d}e{:02d}'.format(xbmc.getInfoLabel('ListItem.TVSHowTitle'), season, episode)
dbid = requests.utils.quote(dbid)
elif xbmc.getInfoLabel('ListItem.TVSHowTitle') and xbmc.getInfoLabel('ListItem.Season'):
season = int(xbmc.getInfoLabel('ListItem.Season'))

dbid = '{} s{:02d}'.format(xbmc.getInfoLabel('ListItem.TVSHowTitle'), season)
dbid = requests.utils.quote(dbid)
elif xbmc.getInfoLabel('ListItem.Title') and xbmc.getInfoLabel('ListItem.Year'):
title = xbmc.getInfoLabel('ListItem.Title')
year = xbmc.getInfoLabel('ListItem.Year')

dbid = '{} ({})'.format(title, year)
dbid = requests.utils.quote(dbid)
else:
dbid = requests.utils.quote(infolabel)
return dbid
Expand Down Expand Up @@ -108,6 +118,10 @@ def getMediaType():
if 'error' not in response:
return 'episode'

response = getJSONResponse('{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasonDetails", "params": { "seasonid": %s }, "id": "0"}' % dbid)
if 'error' not in response:
return 'season'

return None


Expand Down

0 comments on commit b852662

Please sign in to comment.