def unhide_show():
	series_title, mode, submode, url = args.url.split('<join>')
	command = 'update shows set hide = 0 where tvdb_series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	_database.execute_command(command, values, commit = True)
	_common.args.name = series_title
	refresh_menu(mode, submode)
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = 'select series_title, mode, submode, url, favor, hide from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for series_title, mode, sitemode, url, favor, hide in shows:
		if _addoncompat.get_setting(mode) != 'true':
			continue
		elif hide is 1:
			continue
		elif favored and not favor:
			continue
		add_show(series_title, mode, sitemode, url, favor = favor, hide = hide)	
Ejemplo n.º 3
0
def unhide_show():
    series_title, mode, submode, url = args.url.split('<join>')
    command = 'update shows set hide = 0 where series_title = ? and mode = ? and submode = ?;'
    values = (series_title, mode, submode)
    _database.execute_command(command, values, commit=True)
    _common.args.name = series_title
    refresh_menu(mode, submode)
Ejemplo n.º 4
0
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = 'select series_title, mode, submode, url, favor, hide from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for series_title, mode, sitemode, url, favor, hide in shows:
		if _addoncompat.get_setting(mode) == False:
			continue
		elif hide is 1:
			continue
		elif favored and not favor:
			continue
		add_show(series_title, mode, sitemode, url, favor = favor, hide = hide)	
Ejemplo n.º 5
0
def get_plot_by_tvdbid(tvdb_id):
    command = 'select * from shows where tvdb_id = ?;'
    values = (tvdb_id, )
    showdata = _database.execute_command(command, values, fetchone=True)
    prefixplot = ''
    if showdata:
        series_title, mode, sitemode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, has_full_episodes, favor, hide, tvdb_series_title = showdata
        if network is not None:
            prefixplot += smart_utf8(
                xbmcaddon.Addon(
                    id=ADDONID).getLocalizedString(39013)) + network + '\n'
        if (airs_dayofweek is not None) and (airs_time is not None):
            prefixplot += smart_utf8(
                xbmcaddon.Addon(id=ADDONID).getLocalizedString(
                    39014)) + airs_dayofweek + '@' + airs_time + '\n'
        if status is not None:
            prefixplot += smart_utf8(
                xbmcaddon.Addon(
                    id=ADDONID).getLocalizedString(39015)) + status + '\n'
        if prefixplot is not '':
            prefixplot += '\n'
        if plot is not None:
            prefixplot = smart_unicode(prefixplot) + smart_unicode(
                replace_signs(plot))
    return prefixplot
def get_plot_by_tvdbid(tvdb_id):
    command = "select * from shows where tvdb_id = ?;"
    values = (tvdb_id,)
    showdata = _database.execute_command(command, values, fetchone=True)
    prefixplot = ""
    if showdata:
        series_title, mode, sitemode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, has_full_episodes, favor, hide, tvdb_series_title = (
            showdata
        )
        if network is not None:
            prefixplot += smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39013)) + network + "\n"
        if (airs_dayofweek is not None) and (airs_time is not None):
            prefixplot += (
                smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39014))
                + airs_dayofweek
                + "@"
                + airs_time
                + "\n"
            )
        if status is not None:
            prefixplot += smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39015)) + status + "\n"
        if prefixplot is not "":
            prefixplot += "\n"
        if plot is not None:
            prefixplot = smart_unicode(prefixplot) + smart_unicode(replace_signs(plot))
    return prefixplot
def get_serie(series_title, mode, submode, url, forceRefresh = False):
	command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
	values = (series_title.lower(), mode, submode)
	checkdata = _database.execute_command(command, values, fetchone = True)
	empty_values = [series_title, mode,submode, url, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, True, False, False, series_title]
	try:
		tvdb_setting = int(_addoncompat.get_setting('strict_names'))
	except:
		tvdb_setting = 0
	if checkdata and not forceRefresh and checkdata[24]  is not None:
		if checkdata[3] != url: 
			command = 'update shows set url = ? where series_title = ? and mode = ? and submode = ?;'
			values = (url, series_title, mode, submode)
			_database.execute_command(command, values, commit = True)
			command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
			values = (series_title.lower(), mode, submode)
			return _database.execute_command(command, values, fetchone = True)
		else:
			return checkdata
	elif tvdb_setting != 1 or forceRefresh:
		tvdb_data = get_tvdb_series(series_title, manualSearch = forceRefresh, site = get_network(mode).NAME)
		if tvdb_data:
			tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, tvdb_series_title = tvdb_data
			values = [series_title, mode, submode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, True, False, False, tvdb_series_title]
		else:
			values = empty_values
		command = 'insert or replace into shows values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'
		_database.execute_command(command, values, commit = True)
		command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
		values = (series_title, mode, submode)
		return _database.execute_command(command, values, fetchone = True)
	else:
		return empty_values
def get_serie(series_title, mode, submode, url, forceRefresh = False):
	command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	checkdata = _database.execute_command(command, values, fetchone = True)
	if checkdata and not forceRefresh:
		if checkdata[3] is not url:
			command = 'update shows set url = ? where series_title = ? and mode = ? and submode = ?;'
			values = (url, series_title, mode, submode)
			_database.execute_command(command, values, commit = True)
			command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
			values = (series_title, mode, submode)
			return _database.execute_command(command, values, fetchone = True)
		else:
			return checkdata
	else:
		tvdb_data = get_tvdb_series(series_title, manualSearch = forceRefresh, site = get_network(mode).NAME)
		if tvdb_data:
			tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, tvdb_series_title = tvdb_data
			values = [series_title, mode, submode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, True, False, False, tvdb_series_title]
		else:
			values = [series_title, mode,submode, url, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, True, False, False, series_title]
		command = 'insert or replace into shows values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'
		_database.execute_command(command, values, commit = True)
		command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
		values = (series_title, mode, submode)
		return _database.execute_command(command, values, fetchone = True)
Ejemplo n.º 9
0
def get_serie(series_title, mode, submode, url, forceRefresh = False):
	command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
	values = (series_title.lower(), mode, submode)
	checkdata = _database.execute_command(command, values, fetchone = True)
	empty_values = [series_title, mode,submode, url, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, True, False, False, series_title]
	try:
		tvdb_setting = int(_addoncompat.get_setting('strict_names'))
	except:
		tvdb_setting = 0
	if checkdata and not forceRefresh and checkdata[24]  is not None:
		if checkdata[3] != url: 
			command = 'update shows set url = ? where series_title = ? and mode = ? and submode = ?;'
			values = (url, series_title, mode, submode)
			_database.execute_command(command, values, commit = True)
			command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
			values = (series_title.lower(), mode, submode)
			return _database.execute_command(command, values, fetchone = True)
		else:
			return checkdata
	elif tvdb_setting != 1 or forceRefresh:
		tvdb_data = get_tvdb_series(series_title, manualSearch = forceRefresh, site = get_network(mode).NAME)
		if tvdb_data:
			tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, tvdb_series_title = tvdb_data
			values = [series_title, mode, submode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, True, False, False, tvdb_series_title]
		else:
			values = empty_values
		command = 'insert or replace into shows values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'
		_database.execute_command(command, values, commit = True)
		command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
		values = (series_title, mode, submode)
		return _database.execute_command(command, values, fetchone = True)
	else:
		return empty_values
Ejemplo n.º 10
0
def get_serie(series_title, mode, submode, url, forceRefresh = False):
	command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	checkdata = _database.execute_command(command, values, fetchone = True)
	if checkdata and not forceRefresh:
		if checkdata[3] is not url:
			command = 'update shows set url = ? where series_title = ? and mode = ? and submode = ?;'
			values = (url, series_title, mode, submode)
			_database.execute_command(command, values, commit = True)
			command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
			values = (series_title, mode, submode)
			return _database.execute_command(command, values, fetchone = True)
		else:
			return checkdata
	else:
		tvdb_data = get_tvdb_series(series_title, manualSearch = forceRefresh, site = get_network(mode).NAME)
		if tvdb_data:
			tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, tvdb_series_title = tvdb_data
			values = [series_title, mode, submode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, True, False, False, tvdb_series_title]
		else:
			values = [series_title, mode,submode, url, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, True, False, False, series_title]
		command = 'insert or replace into shows values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'
		_database.execute_command(command, values, commit = True)
		command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
		values = (series_title, mode, submode)
		return _database.execute_command(command, values, fetchone = True)
Ejemplo n.º 11
0
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = "select * from shows  where url <> '' and hide <> 1 and favor = ? order by series_title"
	shows = _database.execute_command(command, fetchall = True, values = [favored]) 
	for show in shows:
		add_show( masterList = True, showdata = show)	
Ejemplo n.º 12
0
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = "select * from shows  where url <> '' and hide <> 1 and favor = ? order by series_title"
	shows = _database.execute_command(command, fetchall = True, values = [favored]) 
	for show in shows:
		add_show( masterList = True, showdata = show)	
Ejemplo n.º 13
0
def refresh_db():
	if not os.path.isfile(_database.DBFILE):
		print "Creating db"
		_database.create_db()
	networks = get_networks()
	dialog = xbmcgui.DialogProgress()
	dialog.create(smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39016)))
	total_stations = len(networks)
	current = 0
	increment = 100.0 / total_stations
	all_shows = []
	for network in networks:
		network_name = network.NAME
		if _addoncompat.get_setting(network.SITE) == 'true':
			percent = int(increment * current)
			dialog.update(percent, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39017)) + network.NAME, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39018)))
			showdata = network.masterlist()
			for show in showdata:
				series_title, mode, submode, url = show
				all_shows.append((smart_unicode(series_title.lower().strip()), smart_unicode(mode), smart_unicode(submode)))
			total_shows = len(showdata)
			current_show = 0
			for show in showdata:
				percent = int((increment * current) + (float(current_show) / total_shows) * increment)
				dialog.update(percent, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39017)) + network.NAME, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39005)) + show[0])
				get_serie(show[0], show[1], show[2], show[3], forceRefresh = False)
				current_show += 1
				if (dialog.iscanceled()):
					return False
		current += 1
	command = 'select tvdb_series_title , series_title, mode, submode, url from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for show in shows:
		tvdb_series_title, series_title, mode, submode, url = show
		if ((smart_unicode(series_title.lower().strip()),smart_unicode(mode), smart_unicode(submode)) not in all_shows and (smart_unicode(tvdb_series_title.lower().strip()),smart_unicode(mode), smart_unicode(submode)) not in all_shows):
			command = 'delete from shows where series_title = ? and mode = ? and submode = ? and url = ?;'
			values = (series_title, mode, submode, url)
			print "Deleting - " + series_title + " " + mode + " " + submode + " " + url
			_database.execute_command(command, values, fetchone = True, commit = True)
Ejemplo n.º 14
0
def refresh_db():
	if not os.path.isfile(_database.DBFILE):
		print "Creating db"
		_database.create_db()
	networks = get_networks()
	dialog = xbmcgui.DialogProgress()
	dialog.create(smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39016)))
	total_stations = len(networks)
	current = 0
	increment = 100.0 / total_stations
	all_shows = []
	for network in networks:
		network_name = network.NAME
		if _addoncompat.get_setting(network.SITE) == 'true':
			percent = int(increment * current)
			dialog.update(percent, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39017)) + network.NAME, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39018)))
			showdata = network.masterlist()
			for show in showdata:
				series_title, mode, submode, url = show
				all_shows.append((smart_unicode(series_title.lower().strip()), smart_unicode(mode), smart_unicode(submode)))
			total_shows = len(showdata)
			current_show = 0
			for show in showdata:
				percent = int((increment * current) + (float(current_show) / total_shows) * increment)
				dialog.update(percent, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39017)) + network.NAME, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39005)) + show[0])
				get_serie(show[0], show[1], show[2], show[3], forceRefresh = False)
				current_show += 1
				if (dialog.iscanceled()):
					return False
		current += 1
	command = 'select tvdb_series_title , series_title, mode, submode, url from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for show in shows:
		tvdb_series_title, series_title, mode, submode, url = show
		if ((smart_unicode(series_title.lower().strip()),smart_unicode(mode), smart_unicode(submode)) not in all_shows and (smart_unicode(tvdb_series_title.lower().strip()),smart_unicode(mode), smart_unicode(submode)) not in all_shows):
			command = 'delete from shows where series_title = ? and mode = ? and submode = ? and url = ?;'
			values = (series_title, mode, submode, url)
			print "Deleting - " + series_title + " " + mode + " " + submode + " " + url
			_database.execute_command(command, values, fetchone = True, commit = True)
Ejemplo n.º 15
0
def episodes(episode_url = _common.args.url):
	try:
		shutil.rmtree(os.path.join(_common.CACHEPATH,'thumbs'))
	except:
		pass
	episode_data = _connection.getURL(VIDEOLIST % episode_url.split('#')[0])
	episode_menu = simplejson.loads(episode_data)['videos']
	os.mkdir(os.path.join(_common.CACHEPATH,'thumbs'))
	for episode_item in episode_menu:
		if int(episode_item['fullep']) == int(episode_url.split('#')[1]):
			show_name = episode_item['series_name']
			url = episode_item['guid']
			episode_duration = int(episode_item['duration_secs'])
			episode_plot = episode_item['description_long']
			episode_name = episode_item['title']
			season_number = int(episode_item['season'])
			episode_thumb = episode_item['large_thumbnail']
			thumb_file = episode_thumb.split('/')[-1]
			thumb_path = os.path.join(_common.CACHEPATH, 'thumbs', thumb_file)
			dbpath = xbmc.translatePath(_database.DBPATH)
			thumbcount = 0
			for name in glob.glob(os.path.join(dbpath, 'textures[0-9]*.db')):
				thumbcount = thumbcount+ _database.execute_command('select count(1) from texture where url = ?', [thumb_path,], fetchone = True, dbfile = name)[0]
			if thumbcount == 0:
				thumb_data = _connection.getURL(episode_thumb)
				file = open(thumb_path, 'wb')
				file.write(thumb_data)
				file.close()
			try:
				episode_number = int(episode_item['episode'][len(str(season_number)):])
			except:
				episode_number = -1
			try:
				episode_airdate = _common.format_date(episode_item['airdate'],'%Y-%b-%d', '%d.%m.%Y')
			except:
				episode_airdate = -1
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate,
							'tvshowtitle': show_name }
			_common.add_video(u, episode_name, thumb_path, infoLabels = infoLabels)
	_common.set_view('episodes')
def delete_show():
	series_title, mode, submode, url = args.url.split('<join>')
	command = 'delete from shows where tvdb_series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	_database.execute_command(command, values, commit = True)
def unfavor_show():
	series_title, mode, submode, url = args.url.split('<join>')
	command = 'update shows set favor = 0 where tvdb_series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	_database.execute_command(command, values, commit = True)
Ejemplo n.º 18
0
def hide_show():
    series_title, mode, submode, url = args.url.split('<join>')
    command = 'update shows set hide = 1 where series_title = ? and mode = ? and submode = ?;'
    values = (series_title, mode, submode)
    _database.execute_command(command, values, commit=True)
Ejemplo n.º 19
0
def delete_show():
    series_title, mode, submode, url = args.url.split('<join>')
    command = 'delete from shows where series_title = ? and mode = ? and submode = ?;'
    values = (series_title, mode, submode)
    _database.execute_command(command, values, commit=True)
def unfavor_show():
	series_title, mode, submode, url = args.url.split('<join>')
	command = 'update shows set favor = 0 where tvdb_series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	_database.execute_command(command, values, commit = True)
Ejemplo n.º 21
0
def hide_show():
	series_title, mode, submode, url = args.url.split('<join>')
	series_title = urllib.unquote_plus(series_title)
	command = 'update shows set hide = 1 where tvdb_series_title = ? and mode = ? and submode = ?;'
	values = (series_title, mode, submode)
	_database.execute_command(command, values, commit = True)