Esempio n. 1
0
def getIMDbID(asins, title):
    url = imdbid = None
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    for asin in asins.split(','):
        asin = '%' + asin + '%'
        url = db.cur_exec(c, 'select imdburl from seasons where seriesasin like (?) and imdburl is not null',
                          (asin,)).fetchone()
        if url:
            url = url[0]
            break
    if not url:
        while not imdbid:
            data = getURL('http://www.omdbapi.com/?type=series&t=' + urllib.quote_plus(title.encode('utf-8')))
            if data['Response'] == 'True':
                imdbid = data['imdbID']
            else:
                oldtitle = title
                if title.count(' - '):
                    title = title.split(' - ')[0]
                elif title.count(': '):
                    title = title.split(': ')[0]
                elif title.count('?'):
                    title = title.replace('?', '')
                if title == oldtitle:
                    imdbid = na
    else:
        imdbid = re.compile('/title/(.+?)/', re.DOTALL).findall(url)
    Log(imdbid + asins.split(',')[0])
    return imdbid
Esempio n. 2
0
def getShowTypes(col):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    items = db.cur_exec(c, 'select distinct %s from shows' % col)
    l = getTypes(items, col)
    c.close()
    return l
Esempio n. 3
0
def lookupTVdb(value, rvalue='distinct *', tbl='episodes', name='asin', single=True, exact=False):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    value = value.decode('utf-8')
    if not db.cur_exec(c, 'counttables', (tbl,)).fetchone():
        return '' if single else []

    sqlstring = 'select %s from %s where %s ' % (rvalue, tbl, name)
    retlen = len(rvalue.split(','))
    if not exact:
        value = "%{0}%".format(value)
        sqlstring += 'like (?)'
    else:
        sqlstring += '= (?)'
    if db.cur_exec(c, sqlstring, (value,)).fetchall():
        result = db.cur_exec(c, sqlstring, (value,)).fetchall()
        if single:
            if len(result[0]) > 1:
                return result[0]
            return result[0][0]
        else:
            return result
    if (retlen < 2) and single:
        return None
    return (None,) * retlen
Esempio n. 4
0
def loadTVShowdb(filterobj=None, value=None, sortcol=None):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    if filterobj:
        value = "%{0}%".format(value.decode('utf-8'))
        return db.cur_exec(c, 'select distinct * from shows where %s like (?)' % filterobj, (value,))
    elif sortcol:
        return db.cur_exec(c, 'select distinct * from shows where %s is not null order by %s asc' % (sortcol, sortcol))
    else:
        return db.cur_exec(c, 'select distinct * from shows order by seriestitle asc')
Esempio n. 5
0
def loadTVSeasonsdb(seriesasin=None, sortcol=None, seasonasin=None):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    if seriesasin:
        return db.cur_exec(c, 'select distinct * from seasons where seriesasin = (?)', (seriesasin,))
    if seasonasin:
        seasonasin = '%' + seasonasin + '%'
        return db.cur_exec(c, 'select distinct * from seasons where asin like (?)', (seasonasin,))
    elif sortcol:
        return db.cur_exec(c, 'select distinct * from seasons where %s is not null order by %s asc' % (sortcol, sortcol))
    else:
        return db.cur_exec(c, 'select distinct * from seasons')
Esempio n. 6
0
def updateFanart():
    if var.tvdb_art == '0':
        return

    seasons = False
    c = tvDB.cursor()
    sqlstring = "select asin, seriestitle, fanart, poster from shows where fanart is null"
    Log('TV Update: Updating Fanart')
    if var.tvdb_art == '2':
        sqlstring += " or fanart like '%images-amazon.com%'"
    if var.tvdb_art == '3':
        sqlstring += " or poster like '%images-amazon.com%'"
        seasons = True
    db.waitforDB(tvDB)
    for asin, title, oldfanart, oldposter in db.cur_exec(c, sqlstring).fetchall():
        title = title.lower().replace('[ov]', '').replace('[ultra hd]', '').replace('?', '') \
                .replace('omu', '').split('(')[0].strip()
        tvid, poster, fanart = appfeed.getTVDBImages(title, seasons=seasons)

        if not fanart:
            fanart = appfeed.getTMDBImages(title, content='tv')

        if oldfanart and not fanart:
            fanart = oldfanart

        if oldposter and not poster:
            poster = oldposter

        if tvid:
            if not fanart:
                fanart = na

            if not poster:
                fanart = na

        db.cur_exec(c, 'update shows set fanart=? where asin = (?)', (fanart, asin))
        if var.tvdb_art == '3':
            db.cur_exec(c, 'update shows set poster=? where asin = (?)', (poster, asin))
            if tvid:
                for season, url in tvid.items():
                    for singleasin in asin.split(','):
                        singleasin = '%' + singleasin + '%'
                        db.cur_exec(c, 'update seasons set poster=? where seriesasin like (?) and season = (?)',
                                    (url, singleasin, int(season)))
    tvDB.commit()
    Log('TV Update: Updating Fanart Finished')
Esempio n. 7
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
Esempio n. 8
0
File: tv.py Progetto: versable/xbmc
def loadTVSeasonsdb(seriesasin=None, sortcol=None, seasonasin=None):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    if seriesasin:
        return db.cur_exec(
            c, 'select distinct * from seasons where seriesasin = (?)',
            (seriesasin, ))
    if seasonasin:
        seasonasin = '%' + seasonasin + '%'
        return db.cur_exec(
            c, 'select distinct * from seasons where asin like (?)',
            (seasonasin, ))
    elif sortcol:
        return db.cur_exec(
            c,
            'select distinct * from seasons where %s is not null order by %s asc'
            % (sortcol, sortcol))
    else:
        return db.cur_exec(c, 'select distinct * from seasons')
Esempio n. 9
0
def updateFanart():
    if tmdb_art == '0':
        return

    sqlstring = "select asin, movietitle, year, fanart from movies where fanart is null"
    c = MovieDB.cursor()
    Log('Movie Update: Updating Fanart')
    if tmdb_art == '2':
        sqlstring += " or fanart like '%images-amazon.com%'"

    db.waitforDB(MovieDB)
    for asin, movie, year, oldfanart in db.cur_exec(c, sqlstring):
        movie = movie.lower().replace('[ov]', '').replace('omu', '').replace(
            '[ultra hd]', '').split('(')[0].strip()
        result = appfeed.getTMDBImages(movie, year=year)
        if oldfanart:
            if result == na or not result:
                result = oldfanart
        updateMoviedb(asin, 'fanart', result)
    MovieDB.commit()
    Log('Movie Update: Updating Fanart Finished')
Esempio n. 10
0
def setNewest(compList=False):
    if not compList:
        compList = getCategories()
    catList = compList['movies']
    db.waitforDB(MovieDB)
    c = MovieDB.cursor()
    db.cur_exec(c, 'drop table if exists categories')
    db.cur_exec(
        c, '''create table categories(
                 title TEXT,
    asins TEXT);''')
    db.cur_exec(c, 'update movies set recent=null')
    count = 1
    for catid in catList:
        if catid == 'PrimeMovieRecentlyAdded':
            for asin in catList[catid]:
                updateMoviedb(asin, 'recent', count)
                count += 1
        else:
            db.cur_exec(c, 'insert ignore into categories values (?,?)',
                        [catid, catList[catid]])
    MovieDB.commit()
Esempio n. 11
0
def setNewest(compList=False):
    Log('updating new seasons', xbmc.LOGDEBUG)
    if not compList:
        compList = getCategories()
    catList = compList['tv_shows']
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    db.cur_exec(c, 'drop table if exists categories')
    db.cur_exec(c, 'create table categories(title TEXT, asins TEXT)')
    db.cur_exec(c, 'update seasons set recent=null')
    count = 1
    for catid in catList:
        if catid == 'PrimeTVRecentlyAdded':
            for asin in catList[catid]:
                seasonasin = lookupTVdb(asin, rvalue='seasonasin')
                if not seasonasin:
                    seasonasin = asin

                db.cur_exec(c, "update seasons set recent=? where asin like (?)", (count, '%' + seasonasin + '%'))
                count += 1
        else:
            db.cur_exec(c, 'insert ignore into categories values (?,?)', [catid, catList[catid]])
    tvDB.commit()
Esempio n. 12
0
def setNewest(compList=False):
    Log('updating new seasons', xbmc.LOGDEBUG)
    if not compList:
        compList = getCategories()
    catList = compList['tv_shows']
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    db.cur_exec(c, 'drop table if exists categories')
    db.cur_exec(c, 'create table categories(title TEXT, asins TEXT)')
    db.cur_exec(c, 'update seasons set recent=null')
    count = 1
    for catid in catList:
        if catid == 'PrimeTVRecentlyAdded':
            for asin in catList[catid]:
                seasonasin = lookupTVdb(asin, rvalue='seasonasin')
                if not seasonasin:
                    seasonasin = asin

                db.cur_exec(c, "update seasons set recent=? where asin like (?)", (count, '%' + seasonasin + '%'))
                count += 1
        else:
            db.cur_exec(c, 'insert ignore into categories values (?,?)', [catid, catList[catid]])
    tvDB.commit()
Esempio n. 13
0
def lookupTVdb(value, rvalue='distinct *', tbl='episodes', name='asin', single=True, exact=False):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    if not db.cur_exec(c, 'counttables', (tbl,)).fetchone():
        return '' if single else []

    sqlstring = 'select %s from %s where %s ' % (rvalue, tbl, name)
    retlen = len(rvalue.split(','))
    if not exact:
        value = '%' + value + '%'
        sqlstring += 'like (?)'
    else:
        sqlstring += '= (?)'
    if db.cur_exec(c, sqlstring, (value,)).fetchall():
        result = db.cur_exec(c, sqlstring, (value,)).fetchall()
        if single:
            if len(result[0]) > 1:
                return result[0]
            return result[0][0]
        else:
            return result
    if (retlen < 2) and single:
        return None
    return (None,) * retlen
Esempio n. 14
0
def loadTVEpisodesdb(seriestitle):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    return db.cur_exec(c, 'select distinct * from episodes where seasonasin = (?) order by episode', (seriestitle,))
Esempio n. 15
0
def loadTVEpisodesdb(seriestitle):
    db.waitforDB(tvDB)
    c = tvDB.cursor()
    return db.cur_exec(c, 'select distinct * from episodes where seasonasin = (?) order by episode', (seriestitle,))