Skip to content

Commit

Permalink
Merge pull request #11 from antonsoroko/add-season
Browse files Browse the repository at this point in the history
Add season handling
  • Loading branch information
elgatito authored Mar 16, 2021
2 parents 32d8628 + b852662 commit 8534bb9
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 8534bb9

Please sign in to comment.