Skip to content

Commit

Permalink
plugin.video.dstv.now > v0.15.2
Browse files Browse the repository at this point in the history
  • Loading branch information
matthuisman authored and johnny5-is-alive committed Aug 4, 2021
1 parent 03d309a commit 2cccc19
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 30 deletions.
4 changes: 2 additions & 2 deletions plugin.video.dstv.now/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.dstv.now" name="DStv Now" provider-name="SlyGuy" version="0.15.1">
<addon id="plugin.video.dstv.now" name="DStv Now" provider-name="SlyGuy" version="0.15.2">
<requires>
<import addon="script.module.slyguy"/>
</requires>
Expand All @@ -14,7 +14,7 @@ Subscription required.</description>
<license></license>
<language/>
<website></website>
<news>New Search!</news>
<news>Add Flatten Single Season setting</news>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
Expand Down
Expand Up @@ -64,8 +64,8 @@ msgctxt "#30013"
msgid "Could not find that channel ({id})"
msgstr ""

msgctxt "#30017"
msgid "Next Page ({page})"
msgctxt "#30014"
msgid "Flatten Single Seasons"
msgstr ""

## COMMON SETTINGS ##
Expand Down
6 changes: 3 additions & 3 deletions plugin.video.dstv.now/resources/lib/api.py
Expand Up @@ -108,11 +108,11 @@ def _request_json(self, url, type='get', timeout=30, attempts=3, refresh_token=T
else:
raise APIError(_(_.REQUEST_ERROR, url=url.split(';')[0], code=r.status_code))

def content(self, tags, sort, category='', page=0, pagesize=24):
def content(self, tags, sort, category='', page=1, pagesize=24):
category = 'filter={};'.format(category) if category else ''

data = self._request_json('now-content/v7/catalogueByPackageAndCountry;productId={product};platformId={platform};tags={tags};subscriptionPackage={package};country={country};{category}sort={sort};page={page};pageSize={pagesize}'.format(
product=PRODUCT_ID, platform=PLATFORM_ID, tags=tags, country=userdata.get('country', DEFAULT_COUNTRY), package=userdata.get('package', DEFAULT_PACKAGE), sort=sort, category=category, page=page, pagesize=pagesize,
data = self._request_json('now-content/v6/catalogueByPackageAndCountry;videoAssetsFilter=HasStream;productId={product};platformId={platform};tags={tags};subscriptionPackage={package};country={country};{category}sort={sort};page={page};pageSize={pagesize}'.format(
product=PRODUCT_ID, platform=PLATFORM_ID, tags=tags, country=userdata.get('country', DEFAULT_COUNTRY), package=userdata.get('package', DEFAULT_PACKAGE), sort=sort, category=category, page=page-1, pagesize=pagesize,
))

return data
Expand Down
3 changes: 1 addition & 2 deletions plugin.video.dstv.now/resources/lib/language.py
Expand Up @@ -15,7 +15,6 @@ class Language(BaseLanguage):
API_ERROR = 30011
REFRESH_TOKEN_ERROR = 30012
CHANNEL_NOT_FOUND = 30013

NEXT_PAGE = 30017
FLATTEN_SEASONS = 30014

_ = Language()
56 changes: 35 additions & 21 deletions plugin.video.dstv.now/resources/lib/plugin.py
Expand Up @@ -3,7 +3,7 @@
from xml.sax.saxutils import escape

import arrow
from kodi_six import xbmcplugin, xbmc
from kodi_six import xbmc
from six.moves import queue

from slyguy import plugin, gui, userdata, inputstream, signals, settings
Expand Down Expand Up @@ -81,15 +81,12 @@ def live_tv(**kwargs):
return folder

@plugin.route()
def content(title, tags, sort='az', category=None, page=0, **kwargs):
def content(title, tags, sort='az', category=None, page=1, **kwargs):
folder = plugin.Folder(title)

page = int(page)
data = api.content(tags, sort, category=category, page=page, pagesize=24)

if page > 0:
folder.title += ' ({})'.format(page+1)

if category is None:
category = ''
for section in data['subSections']:
Expand All @@ -114,8 +111,9 @@ def content(title, tags, sort='az', category=None, page=0, **kwargs):

if data['total'] > ((data['pageSize'] * data['page']) + data['count']):
folder.add_item(
label = _(_.NEXT_PAGE, page=page+2, _bold=True),
label = _(_.NEXT_PAGE, page=page+1),
path = plugin.url_for(content, title=title, tags=tags, sort=sort, category=category, page=page+1),
specialsort = 'bottom',
)

return folder
Expand Down Expand Up @@ -153,27 +151,34 @@ def _process_program(program):
label = program['title'],
art = {'thumb': _get_image(program['images']), 'fanart': _get_image(program['images'], 'fanart')},
info = {
'plot': program['synopsis'],
'genre': program['genres'],
'plot': program.get('synopsis'),
'genre': program.get('genres'),
'tvshowtitle': program['title'],
'mediatype': 'tvshow',
},
path = plugin.url_for(list_seasons, id=program['id']),
)

def _process_video(video):
if video.get('type') == 'Movie':
media_type = 'movie'
elif video.get('type') == 'Episode':
media_type = 'episode'
else:
media_type = 'video'

return plugin.Item(
label = video['title'],
info = {
'plot': video['synopsis'],
'year': video['yearOfRelease'],
'duration': video['durationInSeconds'],
'season': video['seasonNumber'],
'episode': video['seasonEpisode'],
'genre': video['genres'],
'dateadded': video['airDate'],
'tvshowtitle': video['displayTitle'],
'mediatype': 'episode' if video['seasonEpisode'] else 'video', #movie
'plot': video.get('synopsis'),
'year': video.get('yearOfRelease'),
'duration': video.get('durationInSeconds'),
'season': video.get('seasonNumber'),
'episode': video.get('seasonEpisode'),
'genre': video.get('genres'),
'dateadded': video.get('airDate'),
'tvshowtitle': video.get('displayTitle'),
'mediatype': media_type,
},
art = {'thumb': _get_image(video['images']), 'fanart': _get_image(video['images'], 'fanart')},
path = plugin.url_for(play_asset, stream_url=video['videoAssets'][0]['url'], content_id=video['videoAssets'][0]['manItemId']),
Expand All @@ -183,15 +188,20 @@ def _process_video(video):
@plugin.route()
def list_seasons(id, **kwargs):
series = api.series(id)

# Flatten
if len(series['seasons']) == 1 and settings.getBool('flatten_single_season', True):
return _episodes(series, int(series['seasons'][0]['seasonNumber']))

folder = plugin.Folder(series['title'])

for row in series['seasons']:
folder.add_item(
label = 'Season {}'.format(row['seasonNumber']),
info = {
'plot': row.get('synopsis', ''),
'plot': row.get('synopsis'),
'tvshowtitle': series['title'],
'season': row['seasonNumber'],
'season': row.get('seasonNumber'),
'mediatype': 'season',
},
art = {'thumb': _get_image(series['images']), 'fanart': _get_image(series['images'], 'fanart')},
Expand All @@ -203,14 +213,18 @@ def list_seasons(id, **kwargs):
@plugin.route()
def episodes(series, season, **kwargs):
series = api.series(series)
folder = plugin.Folder(series['title'], fanart= _get_image(series['images'], 'fanart'), sort_methods=[xbmcplugin.SORT_METHOD_EPISODE, xbmcplugin.SORT_METHOD_UNSORTED, xbmcplugin.SORT_METHOD_LABEL, xbmcplugin.SORT_METHOD_DATEADDED])
return _episodes(series, int(season))

def _episodes(series, season):
folder = plugin.Folder(series['title'], fanart= _get_image(series['images'], 'fanart'))

for row in series['seasons']:
if int(row['seasonNumber']) != int(season):
continue

has_eps = len([x for x in row['videos'] if x['seasonEpisode']])
for video in row['videos']:
if not video['seasonEpisode']:
if has_eps and not video['seasonEpisode']:
log.debug('Skipping info video item: {}'.format(video['title']))
continue

Expand Down
2 changes: 2 additions & 0 deletions plugin.video.dstv.now/resources/settings.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="$ADDON[script.module.slyguy 32034]">
<setting label="30014" type="bool" id="flatten_single_season" default="true"/>
<setting label="30000" type="text" id="device_id" default="{mac_address}"/>
</category>

Expand All @@ -20,6 +21,7 @@
</category>

<category label="$ADDON[script.module.slyguy 32036]">
<setting label="$ADDON[script.module.slyguy 32129]" id="video_folder_content" type="bool" default="true"/>
<setting label="$ADDON[script.module.slyguy 32120]" id="show_series_folders" type="bool" default="true"/>
<setting label="$ADDON[script.module.slyguy 32111]" id="bookmarks" type="bool" default="true"/>
<setting label="$ADDON[script.module.slyguy 32078]" id="kiosk" type="bool" default="false"/>
Expand Down

0 comments on commit 2cccc19

Please sign in to comment.