def getMovieTypes(col): common.waitforDB('movie') c = MovieDB.cursor() items = c.execute('select distinct %s from movies' % col) list = common.getTypes(items, col) c.close() return list
def getMovieTypes(col): common.waitforDB('movie') c = MovieDB.cursor() items = c.execute('select distinct %s from movies' % col) types = common.getTypes(items, col) c.close() return types
def getShowTypes(col): common.waitforDB('tv') c = tvDB.cursor() items = c.execute('select distinct %s from shows' % col) types = common.getTypes(items, col) c.close() return types
def getMovieTypes(col): common.waitforDB('movie') c = MovieDB.cursor() items = c.execute('select distinct %s from movies' % col) list = [] lowlist = [] for data in items: data = data[0] if type(data) == type(str()): if 'Rated' in data: item = data.split('for')[0] if item not in list and item <> '' and item <> 0 and item <> 'Inc.' and item <> 'LLC.': list.append(item) else: if 'genres' in col: data = data.split('/') else: data = re.split(r'[,;/]', data) for item in data: item = item.strip() if item.lower() not in lowlist and item <> '' and item <> 0 and item <> 'Inc.' and item <> 'LLC.': list.append(item) lowlist.append(item.lower()) elif data <> 0: if data is not None: list.append(str(data)) c.close() return list
def lookupMoviedb(value, rvalue='distinct *', name='asin', single=True, exact=False, table='movies'): common.waitforDB('movie') c = MovieDB.cursor() if not c.execute( 'SELECT count(*) FROM sqlite_master WHERE type="table" AND name=(?)', (table, )).fetchone()[0]: return '' sqlstring = 'select %s from %s where %s ' % (rvalue, table, name) retlen = len(rvalue.split(',')) if not exact: value = '%' + value + '%' sqlstring += 'like (?)' else: sqlstring += '= (?)' if c.execute(sqlstring, (value, )).fetchall(): result = c.execute(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
def getShowTypes(col): common.waitforDB('tv') c = tvDB.cursor() items = c.execute('select distinct %s from shows' % col) l = common.getTypes(items, col) c.close() return l
def loadMoviedb(filter=False,value=False,sortcol=False): common.waitforDB('movie') c = MovieDB.cursor() if filter: value = '%' + value + '%' return c.execute('select distinct * from movies where %s like (?)' % filter, (value,)) elif sortcol: return c.execute('select distinct * from movies where %s is not null order by %s asc' % (sortcol,sortcol)) else: return c.execute('select distinct * from movies')
def loadTVShowdb(filter=False, value=False, sortcol=False): common.waitforDB('tv') c = tvDB.cursor() if filter: value = '%' + value + '%' return c.execute('select distinct * from shows where %s like (?)' % filter, (value,)) elif sortcol: return c.execute('select distinct * from shows where %s is not null order by %s asc' % (sortcol, sortcol)) else: return c.execute('select distinct * from shows')
def loadTVShowdb(filterobj=None, value=None, sortcol=None): common.waitforDB('tv') c = tvDB.cursor() if filterobj: value = '%' + value + '%' return c.execute('select distinct * from shows where %s like (?)' % filterobj, (value,)) elif sortcol: return c.execute('select distinct * from shows where %s is not null order by %s asc' % (sortcol, sortcol)) else: return c.execute('select distinct * from shows')
def loadTVSeasonsdb(seriesasin=None, sortcol=None, seasonasin=None): common.waitforDB('tv') c = tvDB.cursor() if seriesasin: return c.execute('select distinct * from seasons where seriesasin = (?)', (seriesasin,)) if seasonasin: seasonasin = '%' + seasonasin + '%' return c.execute('select distinct * from seasons where asin like (?)', (seasonasin,)) elif sortcol: return c.execute('select distinct * from seasons where %s is not null order by %s asc' % (sortcol, sortcol)) else: return c.execute('select distinct * from seasons')
def loadTVSeasonsdb(seriesasin=False, sortcol=False, seasonasin=False): common.waitforDB('tv') c = tvDB.cursor() if seriesasin: return c.execute('select distinct * from seasons where seriesasin = (?)', (seriesasin,)) if seasonasin: seasonasin = '%' + seasonasin + '%' return c.execute('select distinct * from seasons where asin like (?)', (seasonasin,)) elif sortcol: return c.execute('select distinct * from seasons where %s is not null order by %s asc' % (sortcol, sortcol)) else: return c.execute('select distinct * from seasons')
def loadMoviedb(movie_filter=False, value=False, sortcol=False): common.waitforDB('movie') c = MovieDB.cursor() if movie_filter: value = '%' + value + '%' return c.execute( 'select distinct * from movies where %s like (?)' % movie_filter, (value, )) elif sortcol: return c.execute( 'select distinct * from movies where %s is not null order by %s asc' % (sortcol, sortcol)) else: return c.execute('select distinct * from movies')
def getShowTypes(col): common.waitforDB('tv') c = tvDB.cursor() items = c.execute('select distinct %s from shows' % col) list = [] lowlist = [] for data in items: if data and data[0] <> None: data = data[0] if type(data) == type(str()): if 'genres' in col: data = data.split('/') else: data = re.split(r'[,;/]', data) for item in data: item = item.strip() if item.lower() not in lowlist and item <> '' and item <> 0 and item <> 'Inc.' and item <> 'LLC.': list.append(item) lowlist.append(item.lower()) else: list.append(str(data)) c.close() return list
def lookupMoviedb(value, rvalue='distinct *', name='asin', single=True, exact=False): common.waitforDB('movie') c = MovieDB.cursor() sqlstring = 'select %s from movies where %s ' % (rvalue, name) retlen = len(rvalue.split(',')) if not exact: value = '%' + value + '%' sqlstring += 'like (?)' else: sqlstring += '= (?)' if c.execute(sqlstring, (value,)).fetchall(): result = c.execute(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
def lookupTVdb(value, rvalue='distinct *', tbl='episodes', name='asin', single=True, exact=False): common.waitforDB('tv') c = tvDB.cursor() if not c.execute('SELECT count(*) FROM sqlite_master WHERE type="table" AND name=(?)', (tbl,)).fetchone()[0]: return '' sqlstring = 'select %s from %s where %s ' % (rvalue, tbl, name) retlen = len(rvalue.split(',')) if not exact: value = '%' + value + '%' sqlstring += 'like (?)' else: sqlstring += '= (?)' if c.execute(sqlstring, (value,)).fetchall(): result = c.execute(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
def loadTVEpisodesdb(seriestitle): common.waitforDB('tv') c = tvDB.cursor() return c.execute('select distinct * from episodes where seasonasin = (?) order by episode', (seriestitle,))