def updateAll(): if common.updateRunning(): return cj = common.mechanizeLogin() if not cj: return import movies import tv from datetime import datetime common.addon.setSetting('update_running', datetime.today().strftime('%Y-%m-%d %H:%M')) common.Log('Starting DBUpdate') Notif = xbmcgui.Dialog().notification Notif(common.__plugin__, common.getString(30106), sound=False) tv.addTVdb(False, cj=cj) movies.addMoviesdb(False, cj=cj) NewAsins = common.getCategories() movies.setNewest(NewAsins) tv.setNewest(NewAsins) movies.updateFanart() tv.updateFanart() common.addon.setSetting('last_update', datetime.today().strftime('%Y-%m-%d')) common.addon.setSetting('update_running', 'false') Notif(common.__plugin__, common.getString(30126), sound=False) common.Log('DBUpdate finished')
def addMoviesdb(full_update=True): try: if common.args.url == 'u': full_update = False except: pass dialog = xbmcgui.DialogProgress() if full_update: if common.updateRunning(): return dialog.create(common.getString(30120)) dialog.update(0,common.getString(30121)) createMoviedb() MOVIE_ASINS = [] full_update = True else: MOVIE_ASINS = getMoviedbAsins(list=True) page = 1 goAhead = 1 endIndex = 0 new_mov = 0 while goAhead == 1: page+=1 json = appfeed.getList('Movie', endIndex, NumberOfResults=MAX) titles = json['message']['body']['titles'] if titles: for title in titles: if full_update and dialog.iscanceled(): goAhead = -1 break if title.has_key('titleId'): endIndex += 1 asin = title['titleId'] found, MOVIE_ASINS = common.compasin(MOVIE_ASINS, asin) if not found: new_mov += ASIN_ADD(title) updateMoviedb(asin, 'popularity', endIndex) if len(titles) < MAX: goAhead = 0 else: endIndex = endIndex - int(MAX/4) else: goAhead = 0 if full_update: dialog.update(int((endIndex)*100.0/MOV_TOTAL), common.getString(30122) % page, common.getString(30123) % new_mov) if full_update and dialog.iscanceled(): goAhead = -1 if goAhead == 0: updateLibrary() common.addon.setSetting("MoviesTotal",str(endIndex)) common.Log('Movie Update: New %s Deleted %s Total %s' % (new_mov, deleteremoved(MOVIE_ASINS), endIndex)) if full_update: setNewest() dialog.close() updateFanart() xbmc.executebuiltin("XBMC.Container.Refresh") MovieDB.commit()
def updateAll(): if common.updateRunning(): return import movies import tv from datetime import datetime common.addon.setSetting('update_running', datetime.today().strftime('%Y-%m-%d %H:%M')) common.Log('Starting DBUpdate') Notif = xbmcgui.Dialog().notification Notif(common.__plugin__, common.getString(30106), sound = False) tv.addTVdb(False) movies.addMoviesdb(False) NewAsins = common.getCategories() movies.setNewest(NewAsins) movies.updateFanart() tv.setNewest(NewAsins) tv.updateFanart() common.addon.setSetting('last_update', datetime.today().strftime('%Y-%m-%d')) common.addon.setSetting('update_running', 'false') Notif(common.__plugin__, common.getString(30126), sound = False) common.Log('DBUpdate finished')
def updateAll(): if common.updateRunning(): return import movies import tv from datetime import datetime common.addon.setSetting("update_running", datetime.today().strftime("%Y-%m-%d %H:%M")) common.Log("Starting DBUpdate") Notif = xbmcgui.Dialog().notification Notif(common.__plugin__, common.getString(30106), sound=False) tv.addTVdb(False) movies.addMoviesdb(False) NewAsins = common.getCategories() movies.setNewest(NewAsins) movies.updateFanart() tv.setNewest(NewAsins) tv.updateFanart() common.addon.setSetting("last_update", datetime.today().strftime("%Y-%m-%d")) common.addon.setSetting("update_running", "false") Notif(common.__plugin__, common.getString(30126), sound=False) common.Log("DBUpdate finished")
def addTVdb(full_update=True, libasins=None, cj=True): if isinstance(cj, bool): cj = common.mechanizeLogin() if not cj: return prime = True new_libasins = False endIndex = 0 goAhead = 1 SERIES_COUNT = 0 SEASON_COUNT = 0 EPISODE_COUNT = 0 if full_update and not libasins: if common.updateRunning(): return if not Dialog.yesno(common.getString(30136), common.getString(30137), common.getString(30138) % '30'): return DialogPG.create(common.getString(30130)) DialogPG.update(0, common.getString(30131)) createTVdb() ALL_SERIES_ASINS = '' ALL_SEASONS_ASINS = [] else: cleanDB() ALL_SEASONS_ASINS = getTVdbAsins('seasons', retlist=True) ALL_SERIES_ASINS = getTVdbAsins('shows') if libasins: prime = False ALL_SEASONS_ASINS = [] new_libasins = checkLibraryAsins(libasins, cj) if not new_libasins: return while goAhead == 1: jsondata = appfeed.getList('tvepisode,tvseason,tvseries&RollupToSeason=T', endIndex, isPrime=prime, OrderBy='Title', NumberOfResults=MAX, AsinList=new_libasins) titles = jsondata['message']['body']['titles'] del jsondata if titles: SERIES_ASINS = '' EPISODE_ASINS = [] EPISODE_NUM = [] for title in titles: if full_update and DialogPG.iscanceled(): goAhead = -1 break SEASONS_ASIN = title['titleId'] endIndex += 1 found, ALL_SEASONS_ASINS = common.compasin(ALL_SEASONS_ASINS, SEASONS_ASIN) if not found: if ASIN_ADD([title]): SEASON_COUNT += 1 if title['ancestorTitles']: SERIES_KEY = title['ancestorTitles'][0]['titleId'] else: SERIES_KEY = title['titleId'] if SERIES_KEY not in ALL_SERIES_ASINS and 'bbl test' not in title['title'].lower(): SERIES_COUNT += 1 SERIES_ASINS += SERIES_KEY + ',' ALL_SERIES_ASINS += SERIES_KEY + ',' season_size = int(title['childTitles'][0]['size']) if season_size < 1: season_size = MAX parsed = urlparse.urlparse(title['childTitles'][0]['feedUrl']) EPISODE_ASINS.append(urlparse.parse_qs(parsed.query)['SeasonASIN']) EPISODE_NUM.append(season_size) if len(titles) < MAX: goAhead = 0 del titles if SERIES_ASINS: ASIN_ADD(0, asins=SERIES_ASINS) if full_update: DialogPG.update(int(EPISODE_COUNT * 100.0 / EPI_TOTAL), common.getString(30132) % SERIES_COUNT, common.getString(30133) % SEASON_COUNT, common.getString(30134) % EPISODE_COUNT) episodes = 0 AsinList = '' EPISODE_NUM.append(MAX + 1) for index, item in enumerate(EPISODE_ASINS): episodes += EPISODE_NUM[index] AsinList += ','.join(item) + ',' if (episodes + EPISODE_NUM[index + 1]) > MAX: jsondata = appfeed.getList('TVEpisode', 0, isPrime=prime, NumberOfResults=MAX, AsinList=AsinList) titles = jsondata['message']['body']['titles'] if titles: EPISODE_COUNT += ASIN_ADD(titles) if full_update and DialogPG.iscanceled(): goAhead = -1 break episodes = 0 AsinList = '' if full_update: DialogPG.update(int(EPISODE_COUNT * 100.0 / EPI_TOTAL), common.getString(30132) % SERIES_COUNT, common.getString(30133) % SEASON_COUNT, common.getString(30134) % EPISODE_COUNT) del titles else: goAhead = 0 if goAhead == 0: if not libasins: updatePop() removed_seasons = [] for item in ALL_SEASONS_ASINS: if item[1] == 0: removed_seasons.append(item[0]) delShows, delSeasons, delEpisodes = deleteremoved(removed_seasons) 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() common.addon.setSetting("EpisodesTotal", str(countDB('episodes')))
def addTVdb(full_update=True, libasins=False): prime = True new_libasins = False try: if common.args.url == 'u': full_update = False except Exception: pass endIndex = 0 goAhead = 1 SERIES_COUNT = 0 SEASON_COUNT = 0 EPISODE_COUNT = 0 if full_update and not libasins: if common.updateRunning(): return if not Dialog.yesno(common.getString(30136), common.getString(30137), common.getString(30138) % '30'): return DialogPG.create(common.getString(30130)) DialogPG.update(0, common.getString(30131)) createTVdb() ALL_SERIES_ASINS = '' ALL_SEASONS_ASINS = [] else: cleanDB() ALL_SEASONS_ASINS = getTVdbAsins('seasons', list=True) ALL_SERIES_ASINS = getTVdbAsins('shows') if libasins: prime = False ALL_SEASONS_ASINS = [] new_libasins = checkLibraryAsins(libasins) if not new_libasins: return while goAhead == 1: json = appfeed.getList('tvepisode,tvseason,tvseries&RollupToSeason=T', endIndex, isPrime=prime, OrderBy='Title', NumberOfResults=MAX, AsinList=new_libasins) titles = json['message']['body']['titles'] if titles: SERIES_ASINS = '' EPISODE_ASINS = [] EPISODE_NUM = [] for title in titles: if full_update and DialogPG.iscanceled(): goAhead = -1 break SEASONS_ASIN = title['titleId'] endIndex += 1 found, ALL_SEASONS_ASINS = common.compasin(ALL_SEASONS_ASINS, SEASONS_ASIN) if not found: if ASIN_ADD([title]): SEASON_COUNT += 1 if title['ancestorTitles']: SERIES_KEY = title['ancestorTitles'][0]['titleId'] else: SERIES_KEY = title['titleId'] if SERIES_KEY not in ALL_SERIES_ASINS and 'bbl test' not in title['title'].lower(): SERIES_COUNT += 1 SERIES_ASINS += SERIES_KEY + ',' ALL_SERIES_ASINS += SERIES_KEY + ',' season_size = int(title['childTitles'][0]['size']) if season_size < 1: season_size = MAX parsed = urlparse.urlparse(title['childTitles'][0]['feedUrl']) EPISODE_ASINS.append(urlparse.parse_qs(parsed.query)['SeasonASIN']) EPISODE_NUM.append(season_size) if len(titles) < MAX: goAhead = 0 if SERIES_ASINS: ASIN_ADD(0, asins=SERIES_ASINS) if full_update: DialogPG.update(int(EPISODE_COUNT * 100.0 / EPI_TOTAL), common.getString(30132) % SERIES_COUNT, common.getString(30133) % SEASON_COUNT, common.getString(30134) % EPISODE_COUNT) episodes = 0 AsinList = '' EPISODE_NUM.append(MAX + 1) for index, item in enumerate(EPISODE_ASINS): episodes += EPISODE_NUM[index] AsinList += ','.join(item) + ',' if (episodes + EPISODE_NUM[index + 1]) > MAX: json = appfeed.getList('TVEpisode', 0, isPrime=prime, NumberOfResults=MAX, AsinList=AsinList) titles = json['message']['body']['titles'] if titles: EPISODE_COUNT += ASIN_ADD(titles) if full_update and DialogPG.iscanceled(): goAhead = -1 break episodes = 0 AsinList = '' if full_update: DialogPG.update(int(EPISODE_COUNT * 100.0 / EPI_TOTAL), common.getString(30132) % SERIES_COUNT, common.getString(30133) % SEASON_COUNT, common.getString(30134) % EPISODE_COUNT) else: goAhead = 0 if goAhead == 0: if not libasins: updatePop() removed_seasons = [] for item in ALL_SEASONS_ASINS: if item[1] == 0: removed_seasons.append(item[0]) delShows, delSeasons, delEpisodes = deleteremoved(removed_seasons) UpdateDialog(SERIES_COUNT, SEASON_COUNT, EPISODE_COUNT, delShows, delSeasons, delEpisodes) addTVdb(False, 'full') fixDBLShows() fixYears() fixStars() fixHDshows() updateEpisodes() fixTitles() if full_update: setNewest() DialogPG.close() updateFanart() tvDB.commit() common.addon.setSetting("EpisodesTotal", str(countDB('episodes')))
def addMoviesdb(full_update=True): try: if common.args.url == 'u': full_update = False except Exception: pass dialog = xbmcgui.DialogProgress() if full_update: if common.updateRunning(): return dialog.create(common.getString(30120)) dialog.update(0, common.getString(30121)) createMoviedb() MOVIE_ASINS = [] full_update = True else: MOVIE_ASINS = getMoviedbAsins(returnlist=True) page = 1 goAhead = 1 endIndex = 0 new_mov = 0 tot_mov = 0 MAX = 120 while goAhead == 1: json = appfeed.getList('Movie', endIndex, NumberOfResults=MAX)['message']['body'] titles = json['titles'] if json['approximateSize'] == 0: MAX = MAX - 20 if MAX < 1: MAX = 120 continue endIndex = json['endIndex'] if titles: for title in titles: if full_update and dialog.iscanceled(): goAhead = -1 break if 'titleId' in title: asin = title['titleId'] if '_duplicate_' not in title['title']: found, MOVIE_ASINS = common.compasin(MOVIE_ASINS, asin) if not found: new_mov += ASIN_ADD(title) tot_mov += 1 updateMoviedb(asin, 'popularity', tot_mov) if endIndex == 0: goAhead = 0 page += 1 if full_update: dialog.update(int((tot_mov) * 100.0 / MOV_TOTAL), common.getString(30122) % page, common.getString(30123) % new_mov) if full_update and dialog.iscanceled(): goAhead = -1 if goAhead == 0: updateLibrary() common.addon.setSetting("MoviesTotal", str(tot_mov)) common.Log('Movie Update: New %s Deleted %s Total %s' % (new_mov, deleteremoved(MOVIE_ASINS), tot_mov)) if full_update: setNewest() dialog.close() updateFanart() xbmc.executebuiltin("XBMC.Container.Refresh") MovieDB.commit()
def addMoviesdb(full_update=True, cj=True): MOV_TOTAL = int('0' + common.addon.getSetting("MoviesTotal")) dialog = xbmcgui.DialogProgress() if isinstance(cj, bool): cj = common.mechanizeLogin() if not cj: return if full_update: if common.updateRunning(): return dialog.create(common.getString(30120)) dialog.update(0, common.getString(30121)) createMoviedb() MOVIE_ASINS = [] else: MOVIE_ASINS = getMoviedbAsins(retlist=True) page = 1 goAhead = 1 endIndex = 0 new_mov = 0 approx = 0 while goAhead == 1: jsondata = appfeed.getList('Movie', endIndex, NumberOfResults=MAX, OrderBy='Title')['message']['body'] approx = jsondata.get('approximateSize', approx) titles = jsondata['titles'] del jsondata if titles: for pos, title in enumerate(titles): if full_update and dialog.iscanceled(): goAhead = -1 break if 'titleId' in title.keys(): asin = title['titleId'] if '_duplicate_' not in title['title']: found, MOVIE_ASINS = common.compasin(MOVIE_ASINS, asin) if not found: new_mov += ASIN_ADD(title) endIndex += len(titles) if (approx and endIndex + 1 >= approx) or (not approx and len(titles) == 0): goAhead = 0 page += 1 if full_update: if approx: MOV_TOTAL = approx if not MOV_TOTAL: MOV_TOTAL = 6000 dialog.update(int(endIndex * 100.0 / MOV_TOTAL), common.getString(30122) % page, common.getString(30123) % new_mov) if full_update and dialog.iscanceled(): goAhead = -1 if goAhead == 0: updateLibrary(cj=cj) updatePop() common.addon.setSetting("MoviesTotal", str(endIndex + 20)) common.Log('Movie Update: New %s Deleted %s Total %s' % (new_mov, deleteremoved(MOVIE_ASINS), endIndex + 20)) if full_update: setNewest() dialog.close() updateFanart() xbmc.executebuiltin("XBMC.Container.Refresh") MovieDB.commit()