Skip to content

Commit

Permalink
[tld] add profile support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandmann79 committed Sep 30, 2020
1 parent d2097da commit 5e98759
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
25 changes: 23 additions & 2 deletions plugin.video.amazon-test/resources/lib/amazontld.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ def BrowseRoot(self):

if self._s.multiuser:
addDir(getString(30134).format(loadUser('name')), 'switchUser', '', cm=self._g.CONTEXTMENU_MULTIUSER)
if self._s.profiles:
act, profiles = self.getProfiles()
addDir(profiles[act][0], 'switchProfile', '', thumb=profiles[act][2])
addDir('Watchlist', 'getListMenu', self._g.watchlist, cm=cm_wl)
self.listCategories(0)
addDir('Channels', 'Channel', '/gp/video/storefront/ref=nav_shopall_nav_sa_aos?filterId=OFFER_FILTER%3DSUBSCRIPTIONS', opt='root')
addDir(getString(30136), 'Recent', '')
addDir(getString(30108), 'Search', '')
addDir(getString(30100), 'getListMenu', self._g.library, cm=cm_lb)
# addDir('[B]{}[/B]'.format(getString(5)), 'openSettings', self._g.addon.getAddonInfo('id'))
xbmcplugin.endOfDirectory(self._g.pluginhandle, updateListing=False)
xbmcplugin.endOfDirectory(self._g.pluginhandle, updateListing=False, cacheToDisc=False)

@staticmethod
def _cleanName(name, isfile=True):
Expand Down Expand Up @@ -1178,3 +1180,22 @@ def crctxmenu(item):
'''
setContentAndView(vw)
return

def getProfiles(self):
j = GrabJSON(self._g.BaseUrl + '/gp/video/profiles')
profiles = []
active = 0
for item in j['profiles']:
url = self._g.BaseUrl + item['switchLink']['partialURL']
q = urlencode(item['switchLink']['query'])
profiles.append((item['name'], '{}?{}'.format(url, q), item['avatarUrl']))
if item.get('isSelected', False):
active = len(profiles) - 1
return active, profiles

def switchProfile(self):
active, profiles = self.getProfiles()
ret = self._g.dialog.select('Amazon', [i[0] for i in profiles])
if ret < 0 or ret == active:
return
getURL(profiles[ret][1], useCookie=True, rjson=False, silent=True)
2 changes: 1 addition & 1 deletion plugin.video.amazon-test/resources/lib/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def writeConfig(cfile, value):
return True
else:
l = xbmcvfs.File(cfglockfile)
modified = float(l.read())
modified = float('0'+l.read())
l.close()
if time.time() - modified > 0.1:
xbmcvfs.delete(cfglockfile)
3 changes: 2 additions & 1 deletion plugin.video.amazon-test/resources/lib/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def EntryPoint():
g.amz.Search(searchString)
elif mode in ['LogIn', 'remLoginData', 'removeUser', 'renameUser', 'switchUser']:
exec('{}()'.format(mode))
elif mode in ['checkMissing', 'Recent']:
elif mode in ['checkMissing', 'Recent', 'switchProfile']:
exec('g.amz.{}()'.format(mode))
elif mode == 'Channel':
g.amz.Channel(url=args.get('url'), uid=args.get('opt'))

2 changes: 1 addition & 1 deletion plugin.video.amazon-test/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<!-- - -->
<setting label="30001" type="lsep"/>
<setting id="region" type="enum" label="Region" values="Auto|Germany|United Kingdom|USA|Japan|ROE Europe|ROW Europe|ROW Far East|ROW North America" default="0" />
<setting id="profiles" type="bool" label="30024" default="true"/>
<setting id="multiuser" type="bool" label="30009" default="false"/>
<setting id="rememberme" type="bool" label="30022" default="true"/>
<!-- Multiuser -->
Expand Down Expand Up @@ -112,7 +113,6 @@
</category>
<!-- PrimeVideo -->
<category label="30250">
<setting id="profiles" type="bool" label="30024" default="true"/>
<setting id="pv_episode_thumbnails" type="bool" label="30249" default="true"/>
<setting id="catalog_cache_expiry" type="enum" lvalues="30258|30259|30260|30261|30262|30263|30264|30265" label="30257" default="2"/>
<setting id="pv_clearcache" type="action" label="30087" action="RunPlugin(plugin://plugin.video.amazon-test/pv/clearcache/)" option="close"/>
Expand Down

0 comments on commit 5e98759

Please sign in to comment.