def site_list(): custom_listitems = favorites.get_custom_listitems() custom_listitems_dict = {} for x in custom_listitems: custom_listitems_dict[x[0]] = x[1] for x in sorted(AdultSite.get_sites(), key=lambda y: y.get_clean_title().lower(), reverse=False): if x.custom: utils.kodilog('{0}: {1}'.format(utils.i18n('list_custom'), x.title), xbmc.LOGDEBUG) title = x.title if title in custom_listitems_dict.keys(): title = '{} [COLOR red]{}[/COLOR]'.format(title, ''.ljust(custom_listitems_dict[title], '*')) url_dispatcher.add_dir(title, x.url, x.default_mode, x.image, about=x.about, custom=x.custom) utils.eod(basics.addon_handle, False)
def List(): favorder = utils.addon.getSetting("favorder") or 'date added' basics.addDir( '[COLOR violet]Sort by: [/COLOR] [COLOR orange]{0}[/COLOR]'.format( favorder), '', 'favorites.Favorder', '', Folder=False) if utils.addon.getSetting("chaturbate") == "true": for f in AdultSite.clean_functions: f(False) conn = sqlite3.connect(favoritesdb) conn.text_factory = str c = conn.cursor() try: if 'folders' in favorder: if basics.addon.getSetting('custom_sites') == 'true': c.execute( "SELECT f.mode, COUNT(*) count FROM (SELECT * FROM favorites) f LEFT JOIN custom_sites cs on 'custom_' || cs.name || '_by_' || cs.author = substr(f.mode, 1, instr(f.mode, '.') - 1) WHERE IFNULL(cs.enabled, 1) = 1 GROUP BY 1 ORDER BY 1" ) else: c.execute( "SELECT f.mode, COUNT(*) count FROM (SELECT * FROM favorites) f LEFT JOIN custom_sites cs on 'custom_' || cs.name || '_by_' || cs.author = substr(f.mode, 1, instr(f.mode, '.') - 1) WHERE cs.name IS NULL GROUP BY 1 ORDER BY 1" ) for (mode, count) in c.fetchall(): site = mode.split('.')[0] img = '' for s in AdultSite.get_sites(): if s.name == site: name = s.title img = s.image break name = '{} [COLOR thistle][{} favorites][/COLOR]'.format( name, count) basics.addDir(name, mode, 'favorites.FavListSite', img) else: if basics.addon.getSetting('custom_sites') == 'true': c.execute( "SELECT f.* FROM (SELECT * FROM favorites ORDER BY {}) f LEFT JOIN custom_sites cs on 'custom_' || cs.name || '_by_' || cs.author = substr(f.mode, 1, instr(f.mode, '.') - 1) WHERE IFNULL(cs.enabled, 1) = 1" .format(orders[favorder])) else: c.execute( "SELECT f.* FROM (SELECT * FROM favorites ORDER BY {}) f LEFT JOIN custom_sites cs on 'custom_' || cs.name || '_by_' || cs.author = substr(f.mode, 1, instr(f.mode, '.') - 1) WHERE cs.name IS NULL" .format(orders[favorder])) for (name, url, mode, img, duration, quality) in c.fetchall(): duration = '' if duration is None else duration quality = '' if quality is None else quality if 'site' in favorder: site = mode.split('.')[0] for s in AdultSite.get_sites(): if s.name == site: site = s.title break name = '[COLOR hotpink][{}][/COLOR] {}'.format(site, name) basics.addDownLink(name, url, mode, img, desc='', stream='', fav='del', duration=duration, quality=quality) conn.close() utils.eod(utils.addon_handle) except: conn.close() utils.notify('No Favorites', 'No Favorites found') return