Skip to content

Commit

Permalink
[tld] linked profile to recently watched and warn if cookie is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandmann79 committed Oct 4, 2020
1 parent bb35622 commit 9eaa0c3
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,16 @@ msgid "Clear cache"
msgstr "Cache leeren"

msgctxt "#30088"
msgid "Clear cached catalog or video data?\nVideo data includes series/season metadata."
msgstr "Katalogcache oder Videoinfos leeren?\nVideoinfos enthalten Serien/Staffel Metadaten."
msgid ""
"Clear cached catalog or video data?\n"
"Video data includes series/season metadata."
msgstr ""
"Katalogcache oder Videoinfos leeren?\n"
"Videoinfos enthalten Serien/Staffel Metadaten."

msgctxt "#30089"
msgid "No"
msgstr "No"
msgstr "Nein"

msgctxt "#30090"
msgid "Catalog"
Expand Down Expand Up @@ -747,4 +751,8 @@ msgstr "15 Tage"

msgctxt "#30265"
msgid "30 days"
msgstr "30 Tage"
msgstr "30 Tage"

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr "Zugangsdaten ungültig, bitte erneut anmelden."
Original file line number Diff line number Diff line change
Expand Up @@ -763,4 +763,8 @@ msgstr ""

msgctxt "#30265"
msgid "30 days"
msgstr ""
msgstr ""

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ msgid "Clear cache"
msgstr ""

msgctxt "#30088"
msgid "Clear cached catalog or video data?\nVideo data includes series/season metadata."
msgid ""
"Clear cached catalog or video data?\n"
"Video data includes series/season metadata."
msgstr ""

msgctxt "#30089"
Expand Down Expand Up @@ -748,3 +750,7 @@ msgstr "15 días"
msgctxt "#30265"
msgid "30 days"
msgstr "30 días"

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ msgid "Clear cache"
msgstr ""

msgctxt "#30088"
msgid "Clear cached catalog or video data?\nVideo data includes series/season metadata."
msgid ""
"Clear cached catalog or video data?\n"
"Video data includes series/season metadata."
msgstr ""

msgctxt "#30089"
Expand Down Expand Up @@ -751,4 +753,8 @@ msgstr ""

msgctxt "#30265"
msgid "30 days"
msgstr ""
msgstr ""

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ msgid "Clear cache"
msgstr ""

msgctxt "#30088"
msgid "Clear cached catalog or video data?\nVideo data includes series/season metadata."
msgid ""
"Clear cached catalog or video data?\n"
"Video data includes series/season metadata."
msgstr ""

msgctxt "#30089"
Expand Down Expand Up @@ -757,4 +759,8 @@ msgstr ""

msgctxt "#30265"
msgid "30 days"
msgstr ""
msgstr ""

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,12 @@ msgid "Clear cache"
msgstr "Pulizia della cache"

msgctxt "#30088"
msgid "Clear cached catalog or video data?\nVideo data includes series/season metadata."
msgstr "Pulire la cache del catalogo e dei dati video?\nI dati video includono metadati di serie/stagioni."
msgid ""
"Clear cached catalog or video data?\n"
"Video data includes series/season metadata."
msgstr ""
"Pulire la cache del catalogo e dei dati video?\n"
"I dati video includono metadati di serie/stagioni."

msgctxt "#30089"
msgid "No"
Expand Down Expand Up @@ -749,3 +753,7 @@ msgstr "15 giorni"
msgctxt "#30265"
msgid "30 days"
msgstr "30 giorni"

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ msgid "Clear cache"
msgstr ""

msgctxt "#30088"
msgid "Clear cached catalog or video data?\nVideo data includes series/season metadata."
msgid ""
"Clear cached catalog or video data?\n"
"Video data includes series/season metadata."
msgstr ""

msgctxt "#30089"
Expand Down Expand Up @@ -753,4 +755,8 @@ msgstr ""

msgctxt "#30265"
msgid "30 days"
msgstr ""
msgstr ""

msgctxt "#30266"
msgid "Login credentials invalid, please login again."
msgstr ""
19 changes: 15 additions & 4 deletions plugin.video.amazon-test/resources/lib/amazontld.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def BrowseRoot(self):
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])
if act is not False:
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')
Expand Down Expand Up @@ -195,7 +196,7 @@ def getRecents(self):
with open(self.recentsdb, 'rb') as fp:
all_rec = pickle.load(fp)

cur_user = loadUser('name')
cur_user = loadUser('name') + getConfig('profileID')
user_rec = all_rec.get(cur_user, [])
return all_rec, user_rec

Expand All @@ -221,7 +222,7 @@ def updateRecents(self, asin, rem=0):
rec = rec[0:200]

with open(self.recentsdb, 'wb') as fp:
cur_user = loadUser('name')
cur_user = loadUser('name') + getConfig('profileID')
if cur_user in all_rec.keys():
all_rec[cur_user] = rec
else:
Expand Down Expand Up @@ -398,6 +399,7 @@ def listContent(self, catalog, url, page, parent, export=0):
oldurl = url
titlelist = []
ResPage = self._s.MaxResults
contentType = ''

if export:
ResPage = 240
Expand Down Expand Up @@ -799,6 +801,8 @@ def _scrapeAsins(self, aurl, cj):
asins = []
url = self._g.BaseUrl + aurl
json = getURL(url, useCookie=cj, binary=True)
if not json:
return False, False
WriteLog(str(json), 'watchlist')
cont = self.findKey('content', json)
info = {'approximateSize': cont.get('totalItems', 0),
Expand All @@ -813,7 +817,7 @@ def getList(self, listing, export, cont, page=1):
if listing in [self._g.watchlist, self._g.library]:
cj = MechanizeLogin()
if not cj:
return
return [], ''
args = {listing: {'sort': self._s.wl_order,
'libraryType': 'Items',
'primeOnly': False,
Expand All @@ -823,6 +827,10 @@ def getList(self, listing, export, cont, page=1):

url = '/gp/video/api/myStuff{}?viewType={}&args={}'.format(listing.capitalize(), listing, json.dumps(args, separators=(',', ':')))
info, asins = self._scrapeAsins(url, cj)
if info is False:
Log('Cookie invalid', Log.ERROR)
g.dialog.notification(g.__plugin__, getString(30266), xbmcgui.NOTIFICATION_ERROR)
return [], ''
else:
asins = listing

Expand Down Expand Up @@ -1183,6 +1191,8 @@ def crctxmenu(item):

def getProfiles(self):
j = GrabJSON(self._g.BaseUrl + '/gp/video/profiles')
if not j:
return False, False
profiles = []
active = 0
for item in j['profiles']:
Expand All @@ -1191,6 +1201,7 @@ def getProfiles(self):
profiles.append((item['name'], '{}?{}'.format(url, q), item['avatarUrl']))
if item.get('isSelected', False):
active = len(profiles) - 1
writeConfig('profileID', '' if item.get('isDefault', False) else item['name'])
return active, profiles

def switchProfile(self):
Expand Down
6 changes: 5 additions & 1 deletion plugin.video.amazon-test/resources/lib/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def getURL(url, useCookie=False, silent=False, headers=None, rjson=True, attempt
else:
session = requests.Session()

retval = [] if rjson else ''
retval = {} if rjson else ''
if useCookie:
cj = MechanizeLogin() if isinstance(useCookie, bool) else useCookie
if isinstance(cj, bool):
Expand Down Expand Up @@ -170,6 +170,10 @@ class NoRetries(Exception):
response = r.content.decode('utf-8') if binary else r.text
else:
rjson = False
if useCookie and 'auth-cookie-warning-message' in response:
Log('Cookie invalid', Log.ERROR)
g.dialog.notification(g.__plugin__, getString(30266), xbmcgui.NOTIFICATION_ERROR)
return retval
# 408 Timeout, 429 Too many requests and 5xx errors are temporary
# Consider everything else definitive fail (like 404s and 403s)
if (408 == r.status_code) or (429 == r.status_code) or (500 <= r.status_code):
Expand Down

0 comments on commit 9eaa0c3

Please sign in to comment.