Skip to content

Commit 96fce73

Browse files
committed
[Amazon.de] db update improvements
* revert back to title search order * skip empty/http error results as suggested by @mlc42
1 parent cc98003 commit 96fce73

File tree

2 files changed

+23
-39
lines changed

2 files changed

+23
-39
lines changed

plugin.video.amazon/resources/lib/movies.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def addMoviesdb(full_update=True, cj=True):
129129
endIndex = 0
130130
new_mov = 0
131131
retrycount = 0
132-
retrystart = 0
133132
approx = 0
134133

135134
while not approx:
@@ -150,7 +149,6 @@ def addMoviesdb(full_update=True, cj=True):
150149
if titles:
151150
for title in titles:
152151
retrycount = 0
153-
retrystart = 0
154152
if full_update and dialog.iscanceled():
155153
goAhead = -1
156154
break
@@ -167,16 +165,12 @@ def addMoviesdb(full_update=True, cj=True):
167165
new_mov += ASIN_ADD(title)
168166
else:
169167
retrycount += 1
168+
endIndex += 1
170169

171170
if retrycount > 2:
172-
if not retrystart:
173-
retrystart = time.time()
174-
elif time.time() > retrystart + max_wt:
175-
Log('Maxium wait time exceed, canceling database update')
176-
return False
177171
wait_time = randint(180, 420)
178172
Log('Getting {} times a empty response. Waiting {} sec'.format(retrycount, wait_time))
179-
sleep(wait_time)
173+
#sleep(wait_time)
180174
retrycount = 0
181175

182176
endIndex += len(titles)

plugin.video.amazon/resources/lib/tv.py

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# !/usr/bin/env python
32
# -*- coding: utf-8 -*-
43
from __future__ import unicode_literals
54
from . import db
@@ -292,7 +291,6 @@ def addTVdb(full_update=True, libasins=None, cj=True):
292291
EPISODE_COUNT = 0
293292
approx = 0
294293
retrycount = 0
295-
retrystart = 0
296294

297295
if full_update and not libasins:
298296
if updateRunning():
@@ -315,32 +313,26 @@ def addTVdb(full_update=True, libasins=None, cj=True):
315313
ALL_SEASONS_ASINS = []
316314
new_libasins = checkLibraryAsins(libasins, cj)
317315
if not new_libasins:
318-
return
316+
return False
319317
else:
320318
while not approx:
321319
jsondata = appfeed.getList('TVEpisode&RollUpToSeason=T', randint(1, 20), NumberOfResults=1)
322320
approx = jsondata['message']['body'].get('approximateSize', 0)
323321
xbmc.sleep(randint(500, 1000))
324322

325323
while goAhead == 1:
326-
MAX = randint(5, MAX_RES)
324+
MAX = randint(20, MAX_RES)
327325
jsondata = appfeed.getList('TVEpisode&RollUpToSeason=T', endIndex, isPrime=prime,
328326
OrderBy='Title', NumberOfResults=MAX, AsinList=new_libasins)
329327
if not jsondata:
330328
goAhead = -1
331329
break
332330

333331
titles = jsondata['message']['body']['titles']
334-
endI = jsondata['message']['body']['endIndex']
335-
if endI:
336-
endIndex = endI
337-
else:
338-
endIndex += len(titles)
339-
del jsondata
332+
endIndex += len(titles)
340333

341334
if titles:
342335
retrycount = 0
343-
retrystart = 0
344336
SERIES_ASINS = ''
345337
EPISODE_ASINS = []
346338
EPISODE_NUM = []
@@ -406,40 +398,38 @@ def addTVdb(full_update=True, libasins=None, cj=True):
406398
del titles
407399
else:
408400
retrycount += 1
401+
endIndex += 1
409402

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

413406
if retrycount > 2:
414-
if not retrystart:
415-
retrystart = time.time()
416-
elif time.time() > retrystart + max_wt:
417-
Log('Maxium wait time exceed, canceling database update')
418-
return False
419407
wait_time = randint(180, 420)
420408
Log('Getting {} times a empty response. Waiting {} sec'.format(retrycount, wait_time))
421-
sleep(wait_time)
409+
#sleep(wait_time)
422410
retrycount = 0
423411

424412
if goAhead == 0:
413+
finished = False
425414
if not libasins:
426415
updatePop()
427416
delShows, delSeasons, delEpisodes = deleteremoved(getcompresult(ALL_SEASONS_ASINS))
428417
UpdateDialog(SERIES_COUNT, SEASON_COUNT, EPISODE_COUNT, delShows, delSeasons, delEpisodes)
429-
addTVdb(False, 'full', cj)
430-
431-
fixDBLShows()
432-
fixYears()
433-
fixStars()
434-
fixHDshows()
435-
updateEpisodes()
436-
fixTitles()
437-
if full_update:
438-
setNewest()
439-
DialogPG.close()
440-
updateFanart()
441-
tvDB.commit()
442-
return True
418+
finished = addTVdb(False, 'full', cj)
419+
420+
if not finished:
421+
fixDBLShows()
422+
fixYears()
423+
fixStars()
424+
fixHDshows()
425+
updateEpisodes()
426+
fixTitles()
427+
if full_update:
428+
setNewest()
429+
DialogPG.close()
430+
updateFanart()
431+
tvDB.commit()
432+
return True
443433

444434
return False
445435

0 commit comments

Comments
 (0)