Skip to content

Commit

Permalink
[Amazon.de] db update improvements
Browse files Browse the repository at this point in the history
* revert back to title search order
* skip empty/http error results as suggested by @mlc42
  • Loading branch information
Sandmann79 committed Nov 9, 2019
1 parent cc98003 commit 96fce73
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
10 changes: 2 additions & 8 deletions plugin.video.amazon/resources/lib/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def addMoviesdb(full_update=True, cj=True):
endIndex = 0
new_mov = 0
retrycount = 0
retrystart = 0
approx = 0

while not approx:
Expand All @@ -150,7 +149,6 @@ def addMoviesdb(full_update=True, cj=True):
if titles:
for title in titles:
retrycount = 0
retrystart = 0
if full_update and dialog.iscanceled():
goAhead = -1
break
Expand All @@ -167,16 +165,12 @@ def addMoviesdb(full_update=True, cj=True):
new_mov += ASIN_ADD(title)
else:
retrycount += 1
endIndex += 1

if retrycount > 2:
if not retrystart:
retrystart = time.time()
elif time.time() > retrystart + max_wt:
Log('Maxium wait time exceed, canceling database update')
return False
wait_time = randint(180, 420)
Log('Getting {} times a empty response. Waiting {} sec'.format(retrycount, wait_time))
sleep(wait_time)
#sleep(wait_time)
retrycount = 0

endIndex += len(titles)
Expand Down
52 changes: 21 additions & 31 deletions plugin.video.amazon/resources/lib/tv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from . import db
Expand Down Expand Up @@ -292,7 +291,6 @@ def addTVdb(full_update=True, libasins=None, cj=True):
EPISODE_COUNT = 0
approx = 0
retrycount = 0
retrystart = 0

if full_update and not libasins:
if updateRunning():
Expand All @@ -315,32 +313,26 @@ def addTVdb(full_update=True, libasins=None, cj=True):
ALL_SEASONS_ASINS = []
new_libasins = checkLibraryAsins(libasins, cj)
if not new_libasins:
return
return False
else:
while not approx:
jsondata = appfeed.getList('TVEpisode&RollUpToSeason=T', randint(1, 20), NumberOfResults=1)
approx = jsondata['message']['body'].get('approximateSize', 0)
xbmc.sleep(randint(500, 1000))

while goAhead == 1:
MAX = randint(5, MAX_RES)
MAX = randint(20, MAX_RES)
jsondata = appfeed.getList('TVEpisode&RollUpToSeason=T', endIndex, isPrime=prime,
OrderBy='Title', NumberOfResults=MAX, AsinList=new_libasins)
if not jsondata:
goAhead = -1
break

titles = jsondata['message']['body']['titles']
endI = jsondata['message']['body']['endIndex']
if endI:
endIndex = endI
else:
endIndex += len(titles)
del jsondata
endIndex += len(titles)

if titles:
retrycount = 0
retrystart = 0
SERIES_ASINS = ''
EPISODE_ASINS = []
EPISODE_NUM = []
Expand Down Expand Up @@ -406,40 +398,38 @@ def addTVdb(full_update=True, libasins=None, cj=True):
del titles
else:
retrycount += 1
endIndex += 1

if (approx and endIndex + 1 >= approx) or (not approx):
goAhead = 0

if retrycount > 2:
if not retrystart:
retrystart = time.time()
elif time.time() > retrystart + max_wt:
Log('Maxium wait time exceed, canceling database update')
return False
wait_time = randint(180, 420)
Log('Getting {} times a empty response. Waiting {} sec'.format(retrycount, wait_time))
sleep(wait_time)
#sleep(wait_time)
retrycount = 0

if goAhead == 0:
finished = False
if not libasins:
updatePop()
delShows, delSeasons, delEpisodes = deleteremoved(getcompresult(ALL_SEASONS_ASINS))
UpdateDialog(SERIES_COUNT, SEASON_COUNT, EPISODE_COUNT, delShows, delSeasons, delEpisodes)
addTVdb(False, 'full', cj)

fixDBLShows()
fixYears()
fixStars()
fixHDshows()
updateEpisodes()
fixTitles()
if full_update:
setNewest()
DialogPG.close()
updateFanart()
tvDB.commit()
return True
finished = addTVdb(False, 'full', cj)

if not finished:
fixDBLShows()
fixYears()
fixStars()
fixHDshows()
updateEpisodes()
fixTitles()
if full_update:
setNewest()
DialogPG.close()
updateFanart()
tvDB.commit()
return True

return False

Expand Down

0 comments on commit 96fce73

Please sign in to comment.