Пример #1
0
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()
Пример #2
0
def updatePop():
    c = tvDB.cursor()
    c.execute("update shows set popularity=null")
    Index = 0
    
    while Index != -1:
        json = appfeed.getList('TVEpisode&RollupToSeries=T', Index, NumberOfResults=MAX)
        titles = json['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin: c.execute("update shows set popularity=? where asin like (?) and popularity is null", (Index, '%' + asin + '%'))
        if len(titles) == 0: Index = -1
Пример #3
0
def updatePop():
    c = MovieDB.cursor()
    c.execute("update movies set popularity=null")
    Index = 0

    while -1 < Index < 240:
        jsondata = appfeed.getList('Movie', Index, NumberOfResults=MAX)
        titles = jsondata['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                updateMoviedb(asin, 'popularity', Index)
        if len(titles) == 0:
            Index = -1
Пример #4
0
def updatePop():
    c = tvDB.cursor()
    c.execute("update shows set popularity=null")
    Index = 0

    while Index != -1:
        json = appfeed.getList('tvepisode,tvseason,tvseries&RollupToSeries=T', Index, NumberOfResults=MAX)
        titles = json['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                c.execute("update shows set popularity=? where asin like (?) and popularity is null", (Index, '%' + asin + '%'))
        if len(titles) == 0:
            Index = -1
Пример #5
0
def updatePop():
    waitforDB('movie')
    c = MovieDB.cursor()
    c.execute("update movies set popularity=null")
    Index = 0

    while -1 < Index < 240:
        jsondata = appfeed.getList('Movie', Index, NumberOfResults=MAX)
        titles = jsondata['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                updateMoviedb(asin, 'popularity', Index)
        if len(titles) == 0:
            Index = -1
Пример #6
0
def updatePop():
    db.waitforDB(MovieDB)
    c = MovieDB.cursor()
    db.cur_exec(c, "update movies set popularity=null")
    Index = 0
    maxIndex = MAX * 3

    while -1 < Index < maxIndex:
        jsondata = appfeed.getList('Movie', Index, NumberOfResults=MAX)
        titles = jsondata['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                updateMoviedb(asin, 'popularity', Index)
        if len(titles) == 0:
            Index = -1
Пример #7
0
def updatePop():
    Log('updating popular titles', xbmc.LOGDEBUG)
    c = tvDB.cursor()
    db.cur_exec(c, "update shows set popularity=null")
    Index = 0
    maxIndex = MAX * 3

    while -1 < Index < maxIndex:
        jsondata = appfeed.getList('tvepisode,tvseason,tvseries&RollupToSeries=T', Index, NumberOfResults=MAX)
        titles = jsondata['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                db.cur_exec(c, "update shows set popularity=? where asin like (?) and popularity is null",
                            (Index, '%' + asin + '%'))
        if len(titles) == 0:
            Index = -1
Пример #8
0
def updatePop():
    Log('updating popular titles', xbmc.LOGDEBUG)
    c = tvDB.cursor()
    db.cur_exec(c, "update shows set popularity=null")
    Index = 0
    maxIndex = MAX * 3

    while -1 < Index < maxIndex:
        jsondata = appfeed.getList('TVSeason', Index, NumberOfResults=MAX)
        titles = jsondata['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                seriesasin = lookupTVdb(asin, rvalue='seriesasin', tbl='seasons')
                if seriesasin:
                    db.cur_exec(c, "update shows set popularity=? where asin like (?) and popularity is null", (Index, '%' + seriesasin + '%'))
        if len(titles) == 0:
            Index = -1
Пример #9
0
Файл: tv.py Проект: roboot8/xbmc
def updatePop():
    Log('updating popular titles', xbmc.LOGDEBUG)
    c = tvDB.cursor()
    db.cur_exec(c, "update shows set popularity=null")
    Index = 0
    maxIndex = MAX_RES * 3

    while -1 < Index < maxIndex:
        MAX = randint(5, MAX_RES)
        jsondata = appfeed.getList('TVSeason', Index, NumberOfResults=MAX)
        titles = jsondata['message']['body']['titles']
        for title in titles:
            Index += 1
            asin = title['titleId']
            if asin:
                seriesasin = lookupTVdb(asin, rvalue='seriesasin', tbl='seasons')
                if seriesasin:
                    db.cur_exec(c, "update shows set popularity=? where asin like (?) and popularity is null", (Index, '%' + seriesasin + '%'))
        if len(titles) == 0:
            Index = -1
Пример #10
0
def addMoviesdb(isPrime=True):
    dialog = xbmcgui.DialogProgress()
    dialog.create('Building Prime Movie Database')
    dialog.update(0,'Initializing Movie Scan')
    page = 1
    goAhead = True
    endIndex=0
    while goAhead:
        page+=1
        json = appfeed.getList('Movie',endIndex)
        titles = json['message']['body']['titles']
        ASINLIST = ''
        for title in titles:
            ASINLIST += title['titleId']+','
        ASIN_ADD(ASINLIST)
        endIndex+=250
        #endIndex = json['message']['body']['endIndex']
        if (dialog.iscanceled()):
            goAhead = False
        elif endIndex > 14000:
            goAhead = False
        dialog.update(int(page*100.0/56),'Scanning Page %s' % str(page),'Scanned %s Movies' % str(endIndex) )
Пример #11
0
def addMoviesdb(isPrime=True):
    dialog = xbmcgui.DialogProgress()
    dialog.create('Building Prime Movie Database')
    dialog.update(0, 'Initializing Movie Scan')
    page = 1
    goAhead = True
    endIndex = 0
    while goAhead:
        page += 1
        json = appfeed.getList('Movie', endIndex)
        titles = json['message']['body']['titles']
        ASINLIST = ''
        for title in titles:
            ASINLIST += title['titleId'] + ','
        ASIN_ADD(ASINLIST)
        endIndex += 250
        #endIndex = json['message']['body']['endIndex']
        if (dialog.iscanceled()):
            goAhead = False
        elif endIndex > 14000:
            goAhead = False
        dialog.update(int(page * 100.0 / 56), 'Scanning Page %s' % str(page),
                      'Scanned %s Movies' % str(endIndex))
Пример #12
0
Файл: tv.py Проект: roboot8/xbmc
def addTVdb(full_update=True, libasins=None, cj=True):
    if isinstance(cj, bool):
        cj = MechanizeLogin()
        if not cj:
            return

    prime = True
    new_libasins = False
    endIndex = 0
    goAhead = 1
    SERIES_COUNT = 0
    SEASON_COUNT = 0
    EPISODE_COUNT = 0
    approx = 0
    retrycount = 0
    retrystart = 0

    if full_update and not libasins:
        if updateRunning():
            return

        if not Dialog.yesno(getString(30136), getString(30137), getString(30138) % '30'):
            return
        DialogPG.create(getString(30130))
        DialogPG.update(0, getString(30131))
        db.createDatabase(tvDB, 'tv')
        ALL_SERIES_ASINS = ''
        ALL_SEASONS_ASINS = []
    else:
        cleanDB()
        ALL_SEASONS_ASINS = getTVdbAsins('seasons', retlist=True, value='asin,episodetotal')
        ALL_SERIES_ASINS = getTVdbAsins('shows')

    if libasins:
        prime = False
        ALL_SEASONS_ASINS = []
        new_libasins = checkLibraryAsins(libasins, cj)
        if not new_libasins:
            return
    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)
        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

        if titles:
            retrycount = 0
            retrystart = 0
            SERIES_ASINS = ''
            EPISODE_ASINS = []
            EPISODE_NUM = []
            for title in titles:
                if full_update and DialogPG.iscanceled():
                    goAhead = -1
                    break
                SEASONS_ASIN = title['titleId']

                if var.onlyGer and not libasins and re.compile(regex_ovf).search(title['title']):
                    Log('Season Ignored: %s' % title['title'], xbmc.LOGDEBUG)
                    found = True
                else:
                    season_size = int(title['childTitles'][0]['size'])
                    found, ALL_SEASONS_ASINS = compasin(ALL_SEASONS_ASINS, SEASONS_ASIN, season_size)

                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 + ','
                        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 (approx and endIndex + 1 >= approx) or (not approx and len(titles) < 1):
                goAhead = 0

            del titles

            if SERIES_ASINS:
                ASIN_ADD(0, asins=SERIES_ASINS)
            if full_update:
                DialogPG.update(int(SEASON_COUNT * 100.0 / approx), getString(30132) % SERIES_COUNT,
                                getString(30133) % SEASON_COUNT, 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(SEASON_COUNT * 100.0 / approx), getString(30132) % SERIES_COUNT,
                                        getString(30133) % SEASON_COUNT, getString(30134) % EPISODE_COUNT)
                    del titles
        else:
            retrycount += 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 %s times a empty response. Waiting %s sec' % (retrycount, wait_time))
            sleep(wait_time)
            retrycount = 0

    if goAhead == 0:
        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

    return False
Пример #13
0
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()
Пример #14
0
def addMoviesdb(full_update=True, cj=True):
    MOV_TOTAL = int(getConfig('MoviesTotal', '6000'))
    dialog = xbmcgui.DialogProgress()

    if isinstance(cj, bool):
        cj = MechanizeLogin()
        if not cj:
            return

    if full_update:
        if updateRunning():
            return

        dialog.create(getString(30120))
        dialog.update(0, getString(30121))
        db.createDatabase(MovieDB, 'movie')
        MOVIE_ASINS = []
    else:
        MOVIE_ASINS = getMoviedbAsins(retlist=True)

    page = 1
    goAhead = 1
    endIndex = 0
    new_mov = 0
    retrycount = 0
    approx = 0

    while not approx:
        jsondata = appfeed.getList('Movie', randint(1, 20), NumberOfResults=1)
        approx = jsondata['message']['body'].get('approximateSize', 0)
        xbmc.sleep(randint(500, 1000))

    while goAhead == 1:
        jsondata = appfeed.getList('Movie',
                                   endIndex,
                                   NumberOfResults=MAX,
                                   OrderBy='Title')
        if not jsondata:
            goAhead = -1
            break

        titles = jsondata['message']['body']['titles']
        del jsondata

        if titles:
            for title in titles:
                if full_update and dialog.iscanceled():
                    goAhead = -1
                    break
                if 'titleId' in title.keys():
                    asin = title['titleId']
                    if '_duplicate_' not in title['title']:
                        if onlyGer and re.compile(regex_ovf).search(
                                title['title']):
                            Log('Movie Ignored: %s' % title['title'],
                                xbmc.LOGDEBUG)
                            found = True
                        else:
                            found, MOVIE_ASINS = compasin(MOVIE_ASINS, asin)

                        if not found:
                            new_mov += ASIN_ADD(title)
        else:
            retrycount += 1

        if retrycount > 3:
            Log('Waiting 5min')
            sleep(300)
            appfeed.getList('Movie',
                            endIndex - randint(1, MAX - 1),
                            NumberOfResults=randint(1, 10))
            retrycount = 0

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

        page += 1
        if full_update:
            if approx:
                MOV_TOTAL = approx
            dialog.update(int(endIndex * 100.0 / MOV_TOTAL),
                          getString(30122) % page,
                          getString(30123) % new_mov)
        if full_update and dialog.iscanceled():
            goAhead = -1

        if len(titles) > 9:
            endIndex -= 10

    if goAhead == 0:
        endIndex += 10
        updateLibrary(cj=cj)
        updatePop()
        writeConfig("MoviesTotal", endIndex)
        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()
        return True

    return False
Пример #15
0
def addTVdb():
    dialog = xbmcgui.DialogProgress()
    dialog.create('Building Prime Television Database')
    dialog.update(0, 'Initializing Television Scan')
    page = 1
    endIndex = 0
    goAhead = True
    SERIES_COUNT = 0
    SEASON_COUNT = 0
    EPISODE_COUNT = 0
    ALL_SERIES_ASINS = ''
    while goAhead:
        #json = appfeed.getList('TVSeries',0)
        json = appfeed.getList('TVSeason', endIndex)
        titles = json['message']['body']['titles']
        SERIES_ASINS = ''
        SEASONS_ASINS = ''
        EPISODE_FEEDS = []
        for title in titles:
            SEASON_COUNT += 1
            asin = title['titleId']
            hdasin = False
            SEASONS_ASINS += title['titleId'] + ','
            for format in title['formats']:
                if format['videoFormatType'] == 'HD':
                    for offer in format['offers']:
                        if offer['offerType'] == 'SEASON_PURCHASE':
                            hdasin = offer['asin']
                            SEASONS_ASINS.replace(asin, hdasin)
            if title['ancestorTitles'][0]['titleId'] not in ALL_SERIES_ASINS:
                SERIES_COUNT += 1
                SERIES_ASINS += title['ancestorTitles'][0]['titleId'] + ','
                ALL_SERIES_ASINS += title['ancestorTitles'][0]['titleId'] + ','
            EPISODE_FEEDS.append(title['childTitles'][0]['feedUrl'] +
                                 '&NumberOfResults=400')
            if hdasin:
                EPISODE_FEEDS.append(
                    title['childTitles'][0]['feedUrl'].replace(asin, hdasin) +
                    '&NumberOfResults=400')
        del titles
        ASIN_ADD(SERIES_ASINS)
        dialog.update(int(page * 100.0 / 9), '%s Shows' % str(SERIES_COUNT),
                      '%s Seasons' % str(SEASON_COUNT),
                      '%s Episodes' % str(EPISODE_COUNT))
        ASIN_ADD(SEASONS_ASINS)
        dialog.update(int(page * 100.0 / 9), '%s Shows' % str(SERIES_COUNT),
                      '%s Seasons' % str(SEASON_COUNT),
                      '%s Episodes' % str(EPISODE_COUNT))
        for url in EPISODE_FEEDS:
            titles = appfeed.URL_LOOKUP(url)['message']['body']['titles']
            EPISODE_ASINS = ''
            for title in titles:
                EPISODE_COUNT += 1
                EPISODE_ASINS += title['titleId'] + ','
                for format in title['formats']:
                    if format['videoFormatType'] == 'HD':
                        for offer in format['offers']:
                            if offer['offerType'] == 'PURCHASE':
                                EPISODE_ASINS += offer['asin'] + ','
            if EPISODE_ASINS <> '':
                ASIN_ADD(EPISODE_ASINS)
            dialog.update(int(page * 100.0 / 9),
                          '%s Shows' % str(SERIES_COUNT),
                          '%s Seasons' % str(SEASON_COUNT),
                          '%s Episodes' % str(EPISODE_COUNT))
        #endIndex = json['message']['body']['endIndex']
        endIndex += 250
        if (dialog.iscanceled()):
            goAhead = False
        elif endIndex > 2500:
            goAhead = False
        dialog.update(int(page * 100.0 / 9), 'Scanning Page %s' % str(page),
                      'Scanned %s Seasons' % str(endIndex))
        page += 1
    print 'TOTALS'
    print SERIES_COUNT
    print SEASON_COUNT
    print EPISODE_COUNT
    fixHDshows()
Пример #16
0
def addTVdb(full_update=True, libasins=None, cj=True):
    if isinstance(cj, bool):
        cj = MechanizeLogin()
        if not cj:
            return

    prime = True
    new_libasins = False
    endIndex = 0
    goAhead = 1
    SERIES_COUNT = 0
    SEASON_COUNT = 0
    EPISODE_COUNT = 0
    approx = 0
    retrycount = 0

    if full_update and not libasins:
        if updateRunning():
            return

        if not Dialog.yesno(getString(30136), getString(30137), getString(30138) % '30'):
            return
        DialogPG.create(getString(30130))
        DialogPG.update(0, getString(30131))
        db.createDatabase(tvDB, 'tv')
        ALL_SERIES_ASINS = ''
        ALL_SEASONS_ASINS = []
    else:
        cleanDB()
        ALL_SEASONS_ASINS = getTVdbAsins('seasons', retlist=True, value='asin,episodetotal')
        ALL_SERIES_ASINS = getTVdbAsins('shows')

    if libasins:
        prime = False
        ALL_SEASONS_ASINS = []
        new_libasins = checkLibraryAsins(libasins, cj)
        if not new_libasins:
            return
    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:
        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

        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']

                if var.onlyGer and not libasins and re.compile(regex_ovf).search(title['title']):
                    Log('Season Ignored: %s' % title['title'], xbmc.LOGDEBUG)
                    found = True
                else:
                    season_size = int(title['childTitles'][0]['size'])
                    found, ALL_SEASONS_ASINS = compasin(ALL_SEASONS_ASINS, SEASONS_ASIN, season_size)

                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 + ','
                        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 (approx and endIndex + 1 >= approx) or (not approx and len(titles) < 1):
                goAhead = 0

            del titles

            if SERIES_ASINS:
                ASIN_ADD(0, asins=SERIES_ASINS)
            if full_update:
                DialogPG.update(int(SEASON_COUNT * 100.0 / approx), getString(30132) % SERIES_COUNT,
                                getString(30133) % SEASON_COUNT, 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(SEASON_COUNT * 100.0 / approx), getString(30132) % SERIES_COUNT,
                                        getString(30133) % SEASON_COUNT, getString(30134) % EPISODE_COUNT)
                    del titles
        else:
            retrycount += 1

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

        if retrycount > 3:
            Log('Waiting 5min')
            sleep(300)
            appfeed.getList('TVEpisode&RollUpToSeason=T', endIndex-randint(1, MAX-1), isPrime=prime,
                            NumberOfResults=randint(1, 10), AsinList=new_libasins)
            retrycount = 0

    if goAhead == 0:
        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

    return False
Пример #17
0
def addTVdb():
    dialog = xbmcgui.DialogProgress()
    dialog.create('Building Prime Television Database')
    dialog.update(0,'Initializing Television Scan')
    page = 1
    endIndex = 0
    goAhead = True    
    SERIES_COUNT = 0
    SEASON_COUNT = 0
    EPISODE_COUNT = 0
    ALL_SERIES_ASINS = ''
    while goAhead:
        #json = appfeed.getList('TVSeries',0)
        json = appfeed.getList('TVSeason',endIndex)
        titles = json['message']['body']['titles']
        SERIES_ASINS = ''
        SEASONS_ASINS = ''
        EPISODE_FEEDS = []
        for title in titles:
            SEASON_COUNT += 1
            asin=title['titleId']
            hdasin=False
            SEASONS_ASINS += title['titleId']+','
            for format in title['formats']:
                if format['videoFormatType'] == 'HD':
                    for offer in format['offers']:
                        if offer['offerType'] == 'SEASON_PURCHASE':
                            hdasin=offer['asin']
                            SEASONS_ASINS.replace(asin,hdasin)            
            if title['ancestorTitles'][0]['titleId'] not in ALL_SERIES_ASINS:
                SERIES_COUNT += 1
                SERIES_ASINS += title['ancestorTitles'][0]['titleId']+','
                ALL_SERIES_ASINS += title['ancestorTitles'][0]['titleId']+','
            EPISODE_FEEDS.append(title['childTitles'][0]['feedUrl']+'&NumberOfResults=400')
            if hdasin:
                EPISODE_FEEDS.append(title['childTitles'][0]['feedUrl'].replace(asin,hdasin)+'&NumberOfResults=400')
        del titles
        ASIN_ADD(SERIES_ASINS)
        dialog.update(int(page*100.0/9),'%s Shows' % str(SERIES_COUNT),'%s Seasons' % str(SEASON_COUNT),'%s Episodes' % str(EPISODE_COUNT) )
        ASIN_ADD(SEASONS_ASINS)
        dialog.update(int(page*100.0/9),'%s Shows' % str(SERIES_COUNT),'%s Seasons' % str(SEASON_COUNT),'%s Episodes' % str(EPISODE_COUNT) )
        for url in EPISODE_FEEDS:
            titles = appfeed.URL_LOOKUP(url)['message']['body']['titles']
            EPISODE_ASINS=''
            for title in titles:
                EPISODE_COUNT += 1
                EPISODE_ASINS += title['titleId']+','
                for format in title['formats']:
                    if format['videoFormatType'] == 'HD':
                        for offer in format['offers']:
                            if offer['offerType'] == 'PURCHASE':
                                EPISODE_ASINS += offer['asin']+','
            if EPISODE_ASINS <> '':
                ASIN_ADD(EPISODE_ASINS)
            dialog.update(int(page*100.0/9),'%s Shows' % str(SERIES_COUNT),'%s Seasons' % str(SEASON_COUNT),'%s Episodes' % str(EPISODE_COUNT) )
        #endIndex = json['message']['body']['endIndex']
        endIndex+=250
        if (dialog.iscanceled()):
            goAhead = False
        elif endIndex > 2500:
            goAhead = False
        dialog.update(int(page*100.0/9),'Scanning Page %s' % str(page),'Scanned %s Seasons' % str(endIndex) )
        page+=1
    print 'TOTALS'
    print SERIES_COUNT
    print SEASON_COUNT
    print EPISODE_COUNT
    fixHDshows()
Пример #18
0
Файл: tv.py Проект: WhileE/xbmc
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')))
Пример #19
0
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')))
Пример #20
0
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()
Пример #21
0
def addTVdb(full_update=True, libasins=None, cj=True):
    if isinstance(cj, bool):
        cj = mechanizeLogin()
        if not cj:
            return

    prime = True
    new_libasins = False
    endIndex = 0
    goAhead = 1
    SERIES_COUNT = 0
    SEASON_COUNT = 0
    EPISODE_COUNT = 0
    approx = 0

    if full_update and not libasins:
        if updateRunning():
            return

        if not Dialog.yesno(getString(30136), getString(30137),
                            getString(30138) % '30'):
            return
        DialogPG.create(getString(30130))
        DialogPG.update(0, getString(30131))
        createTVdb()
        ALL_SERIES_ASINS = ''
        ALL_SEASONS_ASINS = []
    else:
        cleanDB()
        ALL_SEASONS_ASINS = getTVdbAsins('seasons',
                                         retlist=True,
                                         value='asin,episodetotal')
        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&RollUpToSeason=T',
                                   endIndex,
                                   isPrime=prime,
                                   OrderBy='Title',
                                   NumberOfResults=MAX,
                                   AsinList=new_libasins)
        if not jsondata:
            goAhead = -1
            break

        titles = jsondata['message']['body']['titles']
        approx = jsondata['message']['body'].get('approximateSize', approx)
        endI = jsondata['message']['body']['endIndex']
        if endI:
            endIndex = endI
        else:
            endIndex += len(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']

                if onlyGer and re.compile('(?i)\[(ov|omu)[(\W|omu|ov)]*\]'
                                          ).search(title['title']):
                    Log('Season Ignored: %s' % title['title'], xbmc.LOGDEBUG)
                    found = True
                else:
                    season_size = int(title['childTitles'][0]['size'])
                    found, ALL_SEASONS_ASINS = compasin(
                        ALL_SEASONS_ASINS, SEASONS_ASIN, season_size)

                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 + ','
                        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 (approx and endIndex + 1 >= approx) or (not approx
                                                       and len(titles) < 1):
                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),
                                getString(30132) % SERIES_COUNT,
                                getString(30133) % SEASON_COUNT,
                                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),
                                        getString(30132) % SERIES_COUNT,
                                        getString(30133) % SEASON_COUNT,
                                        getString(30134) % EPISODE_COUNT)
                    del titles
        else:
            goAhead = 0

    if goAhead == 0:
        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()
        writeConfig("EpisodesTotal", countDB('episodes'))
        return True

    return False
Пример #22
0
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()