def furk_tfile_video(): params = dict(parse_qsl(sys.argv[2].replace('?',''))) t_files = [i for i in Furk.t_files(params.get('id')) if 'video' in i['ct'] and 'bitrate' in i] for count, item in enumerate(t_files, 1): try: cm = [] url_params = {'mode': 'media_play', 'url': item['url_dl'], 'rootname': 'video'} url = build_url(url_params) name = clean_file_name(item['name']).upper() if 1200 < int(item['height']) > 2100: display_res = '2160p' elif 1000 < int(item['height']) < 1200: display_res = '1080p' elif 680 < int(item['height']) < 1000: display_res = 'HD' else: display_res = 'SD' display_name = '%02d | [B]%s[/B] | [B]%.2f GB[/B] | %smbps | [I]%s[/I]' % \ (count, display_res, float(item['size'])/1073741824, str(round(float(item['bitrate'])/1000, 2)), name) listitem = xbmcgui.ListItem(display_name) down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': item['url_dl'], 'db_type': 'furk_file', 'image': default_furk_icon} cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem.addContextMenuItems(cm) listitem.setArt({'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def furk_easynews_direct_search_choice(suggestion, from_results, list_name): from modules.nav_utils import build_url direct_search_furk_params = {'mode': 'furk.search_furk', 'db_type': 'video', 'suggestion': suggestion} direct_search_easynews_params = {'mode': 'easynews.search_easynews', 'suggestion': suggestion} choices = [('SEARCH FURK', direct_search_furk_params), ('SEARCH EASYNEWS', direct_search_easynews_params)] choice = selection_dialog([i[0] for i in choices], [i[1] for i in choices], 'Choose Direct Search Provider') if not choice: xbmc.executebuiltin('RunPlugin(%s)' % build_url({'mode': 'playback_menu', 'from_results': from_results, 'suggestion': suggestion, 'list_name': list_name})) else: xbmc.executebuiltin('XBMC.Container.Update(%s)' % build_url(choice))
def ad_torrent_cloud(folder_id=None): cloud_files = [] cloud_dict = AllDebrid.user_cloud() try: for k, v in cloud_dict.iteritems(): if isinstance(v, dict): cloud_files.append(v) except: for k, v in cloud_dict.items(): if isinstance(v, dict): cloud_files.append(v) cloud_files = [i for i in cloud_files if i['statusCode'] == 4] for count, item in enumerate(cloud_files, 1): try: cm = [] folder_name = item['filename'] name = clean_file_name(folder_name).upper() display = '%02d | [B]FOLDER[/B] | [I]%s [/I]' % (count, name) url_params = { 'mode': 'alldebrid.browse_ad_cloud', 'folder': json.dumps(item) } link_folders_add = { 'mode': 'debrid_link_folders', 'debrid_service': 'AD', 'folder_name': normalize(folder_name), 'action': 'add' } link_folders_remove = { 'mode': 'debrid_link_folders', 'debrid_service': 'AD', 'folder_name': normalize(folder_name), 'action': 'remove' } url = build_url(url_params) cm.append(("[B]Link TV Show[/B]", 'XBMC.RunPlugin(%s)' % build_url(link_folders_add))) cm.append(("[B]Clear TV Show Link[/B]", 'XBMC.RunPlugin(%s)' % build_url(link_folders_remove))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({ 'icon': default_ad_icon, 'poster': default_ad_icon, 'thumb': default_ad_icon, 'fanart': fanart, 'banner': default_ad_icon }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def rd_downloads(): from modules.utils import jsondate_to_datetime try: my_downloads = RealDebrid.downloads() except: my_downloads = None if not my_downloads: return extensions = supported_video_extensions() my_downloads = [ i for i in my_downloads if i['download'].lower().endswith(tuple(extensions)) ] for count, item in enumerate(my_downloads, 1): try: cm = [] datetime_object = jsondate_to_datetime(item['generated'], "%Y-%m-%dT%H:%M:%S.%fZ", remove_time=True) filename = item['filename'] name = clean_file_name(filename).upper() size = float(int(item['filesize'])) / 1073741824 display = '%02d | %.2f GB | %s | [I]%s [/I]' % ( count, size, datetime_object, name) url_link = item['download'] url_params = { 'mode': 'media_play', 'url': url_link, 'rootname': 'video' } down_file_params = { 'mode': 'download_file', 'name': name, 'url': url_link, 'db_type': 'realdebrid_direct_file', 'image': default_rd_icon } cm.append(("[B]Download File[/B]", 'XBMC.RunPlugin(%s)' % build_url(down_file_params))) url = build_url(url_params) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({ 'icon': default_rd_icon, 'poster': default_rd_icon, 'thumb': default_rd_icon, 'fanart': fanart, 'banner': default_rd_icon }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def rd_torrent_cloud(): try: my_cloud_files = RealDebrid.user_cloud() except: my_cloud_files = None if not my_cloud_files: return my_cloud_files = [i for i in my_cloud_files if i['status'] == 'downloaded'] for count, item in enumerate(my_cloud_files, 1): try: cm = [] folder_name = item['filename'] name = clean_file_name(folder_name).upper() display = '%02d | [B]FOLDER[/B] | [I]%s [/I]' % (count, name) url_params = { 'mode': 'real_debrid.browse_rd_cloud', 'id': item['id'] } link_folders_add = { 'mode': 'debrid_link_folders', 'debrid_service': 'RD', 'folder_name': normalize(folder_name), 'action': 'add' } link_folders_remove = { 'mode': 'debrid_link_folders', 'debrid_service': 'RD', 'folder_name': normalize(folder_name), 'action': 'remove' } url = build_url(url_params) cm.append(("[B]Link TV Show[/B]", 'XBMC.RunPlugin(%s)' % build_url(link_folders_add))) cm.append(("[B]Clear TV Show Link[/B]", 'XBMC.RunPlugin(%s)' % build_url(link_folders_remove))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({ 'icon': default_rd_icon, 'poster': default_rd_icon, 'thumb': default_rd_icon, 'fanart': fanart, 'banner': default_rd_icon }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def build_list_object(): try: cm = [] url_params = {'mode': 'media_play', 'url': item['url_dl'], 'rootname': 'music'} url = build_url(url_params) track_name = clean_file_name(batch_replace(to_utf8(item['name']), formats)).upper() listitem = xbmcgui.ListItem(track_name) down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': item['url_dl'], 'image': default_furk_icon, 'db_type': 'audio'} cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem.addContextMenuItems(cm) listitem.setArt({'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
def history(self, db_type=None, display=True): try: from sqlite3 import dbapi2 as database except ImportError: from pysqlite2 import dbapi2 as database cache_file = os.path.join(__addon_profile__, "fen_cache.db") db_type = db_type if db_type else self.db_type string = 'fen_discover_%s_%%' % self.db_type settings.check_database(cache_file) dbcon = database.connect(cache_file) dbcur = dbcon.cursor() dbcur.execute("SELECT id, data FROM fencache WHERE id LIKE ? ORDER BY rowid DESC", (string,)) history = dbcur.fetchall() if not display: return [i[0] for i in history] data = [eval(i[1]) for i in history] for count, item in enumerate(data): try: cm = [] data_id = history[count][0] name = item['name'] url_params = {'mode': item['mode'], 'action': item['action'], 'query': item['query'], 'name': name, 'iconImage': self.icon} display = '%s | %s' % (count+1, name) url = build_url(url_params) remove_single_params = {'mode': 'discover.remove_from_history', 'data_id': data_id} remove_all_params = {'mode': 'discover.remove_all_history', 'db_type': db_type} export_params = {'mode': 'navigator.adjust_main_lists', 'method': 'add_external', 'list_name': name, 'menu_item': json.dumps(url_params)} listitem = xbmcgui.ListItem(display) listitem.setArt({'icon': self.icon, 'poster': self.icon, 'thumb': self.icon, 'fanart': self.fanart, 'banner': self.icon}) cm.append(("[B]Export List[/B]",'XBMC.RunPlugin(%s)'% self._build_url(export_params))) cm.append(("[B]Remove From History[/B]",'XBMC.RunPlugin(%s)'% self._build_url(remove_single_params))) cm.append(("[B]Clear All %s History[/B]" % db_type.capitalize(),'XBMC.RunPlugin(%s)'% self._build_url(remove_all_params))) listitem.addContextMenuItems(cm) xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, isFolder=True) except: pass self._end_directory()
def build_add_to_remove_from_list(meta='', media_type='', orig_mode='', from_search=''): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl import json from modules.settings import trakt_list_subscriptions, watched_indicators from modules.nav_utils import build_url params = dict(parse_qsl(sys.argv[2].replace('?',''))) media_type = params.get('media_type', '') orig_mode = params.get('orig_mode', '') from_search = params.get('from_search', '') meta = json.loads(params.get('meta', None)) main_listing = [('Add to...', 'add'), ('Remove from...', 'remove')] mlc = selection_dialog([i[0] for i in main_listing], [i[1] for i in main_listing], 'Choose Add to or Remove from...') if mlc == None: return string = "Choose Selection to Add Item To" if mlc == 'add' else "Choose Selection to Remove Item From" heading = 'Add to ' if mlc == 'add' else 'Remove from ' listing = [(heading + 'Trakt List', 'trakt'), (heading + 'Fen Favourites', 'favourites')] if not trakt_list_subscriptions(): listing.append((heading + 'Fen Subscriptions', 'subscriptions')) if media_type == 'tvshow' and watched_indicators() == 0: listing.append((heading + 'Fen Next Episode', 'unwatched_next_episode')) if mlc == 'remove': listing.append((heading + 'Cache (Re-cache %s Info)' % ('Movie' if media_type == 'movie' else 'TV Show'), 'refresh')) choice = selection_dialog([i[0] for i in listing], [i[1] for i in listing], string) if choice == None: return elif choice == 'trakt': url = {'mode': ('trakt.trakt_add_to_list' if mlc == 'add' else 'trakt.trakt_remove_from_list'), 'tmdb_id': meta["tmdb_id"], 'imdb_id': meta["imdb_id"], 'tvdb_id': meta["tvdb_id"], 'db_type': media_type} elif choice == 'favourites': url = {'mode': ('add_to_favourites' if mlc == 'add' else 'remove_from_favourites'), 'db_type': media_type, 'tmdb_id': meta["tmdb_id"], 'title': meta['title']} elif choice == 'subscriptions': url = {'mode': 'subscriptions_add_remove', 'action': mlc, 'db_type': media_type, 'tmdb_id': meta["tmdb_id"], 'orig_mode': orig_mode} elif choice == 'unwatched_next_episode': url = {'mode': 'add_next_episode_unwatched', 'action': mlc, 'title': meta["title"], 'tmdb_id': meta["tmdb_id"], 'imdb_id': meta["imdb_id"]} elif choice == 'refresh': url = {'mode': 'refresh_cached_data', 'db_type': media_type, 'id_type': 'tmdb_id', 'media_id': meta['tmdb_id']} xbmc.executebuiltin('XBMC.RunPlugin(%s)' % build_url(url))
def add_dir(self, url_params, list_name='Next Page >>', info='Navigate to Next Page...', iconImage='item_next.png'): icon = os.path.join(settings.get_theme(), iconImage) url = build_url(url_params) listitem = xbmcgui.ListItem(list_name) listitem.setArt({'icon': icon, 'fanart': __addon__.getAddonInfo('fanart')}) listitem.setInfo('video', {'title': list_name, 'plot': info}) if url_params['mode'] == 'build_navigate_to_page': listitem.addContextMenuItems([("[B]Switch Jump To Action[/B]","XBMC.RunPlugin(%s)" % build_url({'mode': 'toggle_jump_to'}))]) xbmcplugin.addDirectoryItem(handle=__handle__, url=url, listitem=listitem, isFolder=True)
def furk_file_browser(files, params, display_mode): files_num = 'files_num_video' if (params.get('list_type') == 'file_get_video' or params.get('db_type') == 'video') else 'files_num_audio' orig_mode = 'furk.furk_tfile_video' if (params.get('list_type') == 'file_get_video' or params.get('db_type') == 'video') else 'furk.furk_tfile_audio' for count, item in enumerate(files, 1): try: uncached = True if not 'url_dl' in item else False if uncached: active_downloads = get_active_downloads() mode = 'furk.add_uncached_file' if item['info_hash'] in active_downloads: info = '%02d | [COLOR=green][B]ACTIVE[/B][/COLOR] |' % count else: info = '%02d | [COLOR=red][B]UNCACHED[/B][/COLOR] |' % count else: mode = orig_mode name = clean_file_name(item['name']).upper() item_id = item['id'] if not uncached else item['info_hash'] url_dl = item['url_dl'] if not uncached else item['info_hash'] size = item['size'] if not uncached: is_protected = item.get('is_protected') display_size = str(round(float(size)/1048576000, 1)) info_unprotected = '[B] %s GB | %s files | [/B]' % (display_size, item[files_num]) info_protected = '[COLOR=green]%s[/COLOR]' % info_unprotected info_search = '%02d | [B]%s GB[/B] | [B]%s files[/B] |' % (count, display_size, item[files_num]) info = info_search if display_mode == 'search' else info_protected if is_protected == '1' else info_unprotected if is_protected == '0' else None display = '%s [I] %s [/I]' % (info, name) url_params = {'mode': mode, 'name': name, 'id': item_id} url = build_url(url_params) cm = [] if not uncached: con_download_archive = {'mode': 'download_file', 'name': item.get("name"), 'url': url_dl, 'db_type': 'archive', 'image': default_furk_icon} con_remove_files = {'mode': 'furk.remove_from_files', 'name': name, 'item_id': item_id} con_protect_files = {'mode': 'furk.myfiles_protect_unprotect', 'action': 'protect', 'name': name, 'item_id': item_id} con_unprotect_files = {'mode': 'furk.myfiles_protect_unprotect', 'action': 'unprotect', 'name': name, 'item_id': item_id} con_add_to_files = {'mode': 'furk.add_to_files', 'name': name, 'item_id': item_id} if display_mode == 'search': cm.append(("[B]Add to My Files[/B]",'XBMC.RunPlugin(%s)' % build_url(con_add_to_files))) cm.append(("[B]Download Archive[/B]",'XBMC.RunPlugin(%s)' % build_url(con_download_archive))) cm.append(("[B]Remove from My Files[/B]",'XBMC.RunPlugin(%s)' % build_url(con_remove_files))) if is_protected == '0': cm.append(("[B]Protect File[/B]",'XBMC.RunPlugin(%s)' % build_url(con_protect_files))) if is_protected == '1': cm.append(("[B]Unprotect File[/B]",'XBMC.RunPlugin(%s)' % build_url(con_unprotect_files))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
def resolve_ad(url, play=True): resolved_link = AllDebrid.unrestrict_link(url) if not play: return resolved_link url_params = { 'mode': 'media_play', 'url': resolved_link, 'rootname': 'video' } return xbmc.executebuiltin('XBMC.RunPlugin(%s)' % build_url(url_params))
def _build(item, item_position=None): try: cm = [] overview = item['overview'] name = item['name'] poster_path = item['poster_path'] season_number = item['season_number'] episode_count = item['episode_count'] plot = overview if overview != '' else show_plot title = name if use_season_title and name != '' else 'Season %s' % str(season_number) season_poster = poster_path if poster_path is not None else show_poster playcount, overlay, watched, unwatched = get_watched_status_season(watched_info, use_trakt, tmdb_id, season_number, episode_count) watched_params = {"mode": "mark_season_as_watched_unwatched", "action": 'mark_as_watched', "title": show_title, "year": show_year, "media_id": tmdb_id, "imdb_id": imdb_id, "tvdb_id": tvdb_id, "season": season_number, "meta_user_info": meta_user_info} unwatched_params = {"mode": "mark_season_as_watched_unwatched", "action": 'mark_as_unwatched', "title": show_title, "year": show_year, "media_id": tmdb_id, "imdb_id": imdb_id, "tvdb_id": tvdb_id, "season": season_number, "meta_user_info": meta_user_info} playback_menu_params = {'mode': 'playback_menu'} cm.append(("[B]Mark Watched %s[/B]" % watched_title,'XBMC.RunPlugin(%s)' % build_url(watched_params))) cm.append(("[B]Mark Unwatched %s[/B]" % watched_title,'XBMC.RunPlugin(%s)' % build_url(unwatched_params))) cm.append(("[B]Options[/B]",'XBMC.RunPlugin(%s)' % build_url(playback_menu_params))) cm.append(("[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedtvinfo,id=%s)' % tmdb_id)) url_params = {'mode': 'build_episode_list', 'tmdb_id': tmdb_id, 'season': season_number} url = build_url(url_params) listitem = xbmcgui.ListItem() listitem.setLabel(title) try: listitem.setProperties({'watchedepisodes': str(watched), 'unwatchedepisodes': str(unwatched), 'totalepisodes': str(episode_count)}) except: listitem.setProperty('watchedepisodes', str(watched)) listitem.setProperty('unwatchedepisodes', str(unwatched)) listitem.setProperty('totalepisodes', str(episode_count)) listitem.addContextMenuItems(cm) listitem.setArt({'poster': season_poster, 'fanart': fanart, 'banner': banner, 'clearart': clearart, 'clearlogo': clearlogo, 'landscape': landscape}) listitem.setCast(cast) listitem.setUniqueIDs({'imdb': str(imdb_id), 'tmdb': str(tmdb_id), 'tvdb': str(tvdb_id)}) listitem.setInfo( 'video', {'mediatype': 'tvshow', 'trailer': trailer, 'title': show_title, 'size': '0', 'duration': episode_run_time, 'plot': plot, 'rating': rating, 'premiered': premiered, 'studio': studio, 'year': show_year,'genre': genre, 'mpaa': mpaa, 'tvshowtitle': show_title, 'imdbnumber': imdb_id,'votes': votes, 'episode': str(episode_count),'playcount': playcount, 'overlay': overlay}) if use_threading: item_list.append({'list_item': (url, listitem, True), 'item_position': item_position}) else: xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
def _add_dir(self, list_name, mode, url_params, isFolder=True): url_params['mode'] = mode actor_id = url_params['actor_id'] actor_name = url_params['actor_name'] actor_image = url_params['actor_image'] list_name = '[B]%s :[/B] %s' % (actor_name.upper(), list_name) info = url_params.get('info', '') url = build_url(url_params) listitem = xbmcgui.ListItem(list_name, iconImage=actor_image) listitem.setArt({'fanart': fanart}) listitem.setInfo('video', {'title': list_name, 'plot': info}) xbmcplugin.addDirectoryItem(handle=__handle__, url=url, listitem=listitem, isFolder=isFolder)
def pm_transfers(): extensions = supported_video_extensions() transfer_files = Premiumize.transfers_list()['transfers'] for count, item in enumerate(transfer_files, 1): try: cm = [] file_type = 'folder' if item['file_id'] is None else 'file' name = clean_file_name(item['name']).upper() status = item['status'] progress = item['progress'] if status == 'finished': progress = 100 else: try: progress = re.findall('\.(\d+)', str(progress))[0] progress = progress[:2] except: progress = '' if file_type == 'folder': display = '%02d | %s%% | [B]%s[/B] | [I]%s [/I]' % (count, str(progress), file_type.upper(), name) url_params = {'mode': 'premiumize.pm_torrent_cloud', 'id': item['folder_id'], 'folder_name': normalize(item['name'])} else: details = Premiumize.get_item_details(item['file_id']) url_link = details['link'] if url_link.startswith('/'): url_link = 'https' + url_link size = details['size'] display_size = float(int(size))/1073741824 display = '%02d | %s%% | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (count, str(progress), file_type.upper(), display_size, name) url_params = {'mode': 'media_play', 'url': url_link, 'rootname': 'video'} down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': url_link, 'db_type': 'premiumize_file', 'image': default_pm_icon} cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params))) url = build_url(url_params) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({'icon': default_pm_icon, 'poster': default_pm_icon, 'thumb': default_pm_icon, 'fanart': fanart, 'banner': default_pm_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def pm_torrent_cloud(folder_id=None, folder_name=None): try: extensions = supported_video_extensions() cloud_files = Premiumize.user_cloud(folder_id)['content'] cloud_files = [i for i in cloud_files if ('link' in i and i['link'].lower().endswith(tuple(extensions))) or i['type'] == 'folder'] cloud_files = sorted(cloud_files, key=lambda k: k['name']) cloud_files = sorted(cloud_files, key=lambda k: k['type'], reverse=True) except: return for count, item in enumerate(cloud_files, 1): try: cm = [] file_type = item['type'] name = clean_file_name(item['name']).upper() rename_params = {'mode': 'premiumize.rename', 'file_type': file_type, 'id': item['id'], 'name': item['name']} if file_type == 'folder': size = 0 display = '%02d | [B]%s[/B] | [I]%s [/I]' % (count, file_type.upper(), name) url_params = {'mode': 'premiumize.pm_torrent_cloud', 'id': item['id'], 'folder_name': normalize(item['name'])} else: url_link = item['link'] if url_link.startswith('/'): url_link = 'https' + url_link size = item['size'] display_size = float(int(size))/1073741824 display = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (count, file_type.upper(), display_size, name) url_params = {'mode': 'media_play', 'url': url_link, 'rootname': 'video'} down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': url_link, 'db_type': 'premiumize_file', 'image': default_pm_icon} cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params))) cm.append(("[B]Rename %s[/B]" % file_type.capitalize(),'XBMC.RunPlugin(%s)' % build_url(rename_params))) url = build_url(url_params) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({'icon': default_pm_icon, 'poster': default_pm_icon, 'thumb': default_pm_icon, 'fanart': fanart, 'banner': default_pm_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def easynews_file_browser(files): for count, item in enumerate(files, 1): try: cm = [] name = clean_file_name(item['name']).upper() url_dl = item['url_dl'] size = str(round(float(int(item['rawSize'])) / 1048576000, 1)) display = '%02d | [B]%s GB[/B] | [I]%s [/I]' % (count, size, name) url_params = { 'mode': 'media_play', 'url': item['url_dl'], 'rootname': 'video' } url = build_url(url_params) down_file_params = { 'mode': 'download_file', 'name': item['name'], 'url': item['url_dl'], 'db_type': 'easynews_file', 'image': default_easynews_icon } cm.append(("[B]Download File[/B]", 'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({ 'icon': default_easynews_icon, 'poster': default_easynews_icon, 'thumb': default_easynews_icon, 'fanart': fanart, 'banner': default_easynews_icon }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
def image_results(self): results = TMDb.tmdb_people_pictures(self.actor_id) for item in results['profiles']: thumb_url = self.image_base % ('h632', item['file_path']) image_url = self.image_base % ('original', item['file_path']) name = '%sx%s' % (item['height'], item['width']) url_params = {'mode': 'show_image', 'image_url': image_url} url = build_url(url_params) listitem = xbmcgui.ListItem(name) listitem.setArt({'icon': thumb_url, 'poster': thumb_url, 'thumb': thumb_url, 'fanart': fanart, 'banner': thumb_url}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.main')
def make_stream(self, stream_file, params): if not xbmcvfs.exists(stream_file): from modules.nav_utils import build_url file = xbmcvfs.File(stream_file, 'w') content = build_url(params) file.write(str(content)) file.close() if self.add_release_date: try: premiered = params['premiered'] adjusted_time = settings.date_to_timestamp(premiered) os.utime(stream_file, (adjusted_time, adjusted_time)) except Exception as e: logger('make_stream Exception', e) pass
def torrent_status_browser(files): from datetime import timedelta from modules import fen_cache for count, item in enumerate(files, 1): try: display = '%02d | %s | [COLOR=grey][I]%s | %sGB | %s %% | SPEED: %s kB/s | (S:%s P:%s)[/I][/COLOR]' % (count, item['name'].replace('magnet:', '').upper(), item['dl_status'].upper(), str(round(float(item['size'])/1048576000, 1)), item['have'], str(round(float(item['speed'])/1024, 1)), item['seeders'], item['peers']) url_params = {'mode': 'furk.remove_from_downloads', 'name': item['name'], 'id': item['id']} url = build_url(url_params) listitem = xbmcgui.ListItem(display) listitem.setArt({'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass fen_cache.FenCache().set('furk_active_downloads', [i['info_hash'] for i in files], expiration=timedelta(hours=1)) xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def build_next_episode_play(): ep_data = [ i['episodes_data'] for i in seasons_data if i['season_number'] == season ][0] ep_data = [i for i in ep_data if i['airedEpisodeNumber'] == episode][0] airdate = ep_data['firstAired'] d = airdate.split('-') episode_date = date(int(d[0]), int(d[1]), int(d[2])) if current_adjusted_date < episode_date: return {'pass': True} query = meta['title'] + ' S%.2dE%.2d' % (int(season), int(episode)) display_name = '%s - %dx%.2d' % (meta['title'], int(season), int(episode)) meta.update({ 'vid_type': 'episode', 'rootname': display_name, "season": season, 'ep_name': ep_data['episodeName'], "episode": episode, 'premiered': airdate, 'plot': ep_data['overview'] }) meta_json = json.dumps(meta) url_params = { 'mode': 'play_media', 'background': 'true', 'vid_type': 'episode', 'tmdb_id': meta['tmdb_id'], 'query': query, 'tvshowtitle': meta['rootname'], 'season': season, 'episode': episode, 'meta': meta_json, 'ep_name': ep_data['episodeName'] } if from_library: url_params.update({'library': 'True', 'plot': ep_data['overview']}) return build_url(url_params)
def furk_tfile_audio(): window.clearProperty('furk_t_files_json') params = dict(parse_qsl(sys.argv[2].replace('?',''))) excludes = ['', 'cover', 'covers', 'scan', 'scans', 'playlists'] t_files = Furk.t_files(params.get('id')) item_path_list = sorted(list(set([clean_file_name(i['path']) for i in t_files if clean_file_name(i['path']).lower() not in excludes]))) if not item_path_list: if dialog.yesno("Fen Music Player", 'Browse Songs or Play Full Album?', '', '', 'Play Now','Browse'): return browse_audio_album(t_files, params.get('name')) from modules.player import FenPlayer FenPlayer().playAudioAlbum(t_files, params.get('name')) return browse_audio_album(t_files, params.get('name')) for x in item_path_list: url_params = {'mode': 'furk.browse_audio_album', 'item_path': x} url = build_url(url_params) listitem = xbmcgui.ListItem(x.upper()) listitem.setArt({'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) t_files_json = json.dumps(t_files) window.setProperty('furk_t_files_json', str(t_files_json)) xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def search_history(): import xbmc, xbmcgui, xbmcplugin import sys, os try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl try: from urllib import unquote except ImportError: from urllib.parse import unquote from modules.nav_utils import build_url, setView from modules.settings import get_theme try: params = dict(parse_qsl(sys.argv[2].replace('?', ''))) (search_setting, display_title) = ('movie_queries', 'MOVIE') if params['action'] == 'movie' \ else ('tvshow_queries', 'TVSHOW') if params['action'] == 'tvshow' \ else ('people_queries', 'PEOPLE') if params['action'] == 'people' \ else ('furk_video_queries', 'FURK VIDEO') if params['action'] == 'furk_video' \ else ('furk_audio_queries', 'FURK AUDIO') if params['action'] == 'furk_audio' \ else ('easynews_video_queries', 'EASYNEWS VIDEO') if params['action'] == 'easynews_video' \ else '' history = _cache.get(search_setting) if not history: return except: return icon = os.path.join(get_theme(), 'search.png') fanart = os.path.join(xbmc.translatePath(__addon__.getAddonInfo('path')), 'fanart.png') for h in history: try: cm = [] name = unquote(h) url_params = {'mode': 'build_movie_list', 'action': 'tmdb_movies_search', 'query': name} if params['action'] == 'movie' \ else {'mode': 'build_tvshow_list', 'action': 'tmdb_tv_search', 'query': name} if params['action'] == 'tvshow' \ else {'mode': 'people_search.search', 'actor_name': name} if params['action'] == 'people' \ else {'mode': 'furk.search_furk', 'db_type': 'video', 'query': name} if params['action'] == 'furk_video' \ else {'mode': 'furk.search_furk', 'db_type': 'audio', 'music': True, 'query': name} if params['action'] == 'furk_audio' \ else {'mode': 'easynews.search_easynews', 'query': name} if params['action'] == 'easynews_video' \ else '' display = '[B]%s SEARCH : [/B]' % display_title + name url = build_url(url_params) cm.append(("[B]Remove from history[/B]",'XBMC.RunPlugin(%s?mode=%s&setting_id=%s&name=%s)' \ % (sys.argv[0], 'remove_from_history', search_setting, name))) listitem = xbmcgui.ListItem(display) listitem.setArt({ 'icon': icon, 'poster': icon, 'thumb': icon, 'fanart': fanart, 'banner': icon }) listitem.addContextMenuItems(cm) xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, isFolder=True) except: pass xbmcplugin.setContent(int(sys.argv[1]), 'addons') xbmcplugin.endOfDirectory(int(sys.argv[1])) setView('view.main')
def _build(item): try: cm = [] item_no = item['item_no'] tmdb_id = item['tmdb_id'] tvdb_id = item['tvdb_id'] imdb_id = item['imdb_id'] title = item['title'] year = item['year'] trailer = item['trailer'] if not 'rootname' in item: item['rootname'] = '{0} ({1})'.format(title, year) meta_json = json.dumps(item) openinfo_params = {'mode': 'extended_info_open', 'db_type': 'tvshow', 'tmdb_id': tmdb_id} season_params = {'mode': 'build_season_list', 'meta': meta_json, 'tmdb_id': tmdb_id} all_episodes_params = {'mode': 'build_episode_list', 'tmdb_id': tmdb_id, 'season': 'all', 'meta': meta_json} browse_params = all_episodes_params if all_episodes else season_params url_params = openinfo_params if default_openinfo else all_episodes_params if all_episodes else season_params url = build_url(url_params) hide_recommended_params = {'mode': 'trakt.hide_recommendations', 'db_type': 'shows', 'imdb_id': imdb_id} playback_menu_params = {'mode': 'playback_menu', 'list_name': list_name} watched_params = {"mode": "mark_tv_show_as_watched_unwatched", "action": 'mark_as_watched', "title": title, "year": year, "media_id": tmdb_id, "imdb_id": imdb_id, "tvdb_id": tvdb_id, "meta_user_info": meta_user_info} unwatched_params = {"mode": "mark_tv_show_as_watched_unwatched", "action": 'mark_as_unwatched', "title": title, "year": year, "media_id": tmdb_id, "imdb_id": imdb_id, "tvdb_id": tvdb_id, "meta_user_info": meta_user_info} add_remove_params = {"mode": "build_add_to_remove_from_list", "media_type": "tvshow", "meta": meta_json, "orig_mode": self.action} sim_recom_params = {"mode": "similar_recommendations_choice", "db_type": "tv", 'sim_recom_name': item['rootname'] , "sim_recom_tmdb": tmdb_id, "meta_user_info": meta_user_info} (trailer_params, trailer_title) = ({'mode': 'play_trailer', 'url': trailer, 'all_trailers': json.dumps(item['all_trailers'])}, 'Choose Trailer') if (all_trailers and item.get('all_trailers', False)) else ({'mode': 'play_trailer', 'url': trailer}, 'Trailer') cm.append(("[B]Mark Watched %s[/B]" % watched_title, "XBMC.RunPlugin(%s)" % build_url(watched_params))) cm.append(("[B]Mark Unwatched %s[/B]" % watched_title, "XBMC.RunPlugin(%s)" % build_url(unwatched_params))) cm.append(("[B]Options[/B]",'XBMC.RunPlugin(%s)' % build_url(playback_menu_params))) if default_openinfo: cm.append(("[B]Browse...[/B]",'XBMC.Container.Update(%s)' % build_url(browse_params))) cm.append(("[B]Add/Remove[/B]", "XBMC.RunPlugin(%s)" % build_url(add_remove_params))) cm.append(("[B]Similar/Recommended[/B]", "XBMC.RunPlugin(%s)" % build_url(sim_recom_params))) if self.action in ('tmdb_tv_similar', 'tmdb_tv_recommendations'): sim_recom_title = 'Similar to' if self.action == 'tmdb_tv_similar' else 'Recommended based on' export_sim_recom_params = {'mode': 'navigator.adjust_main_lists', 'method': 'add_sim_recom_external', 'end_mode': 'build_tvshow_list', 'end_action': self.action, 'db_type': 'tvshow', 'sim_recom_name': '[B]TV Shows[/B] | %s %s' % (sim_recom_title, self.sim_recom_name), 'sim_recom_tmdb': self.sim_recom_tmdb} cm.append(("[B]Export %s List[/B]" % sim_recom_title.split(' ')[0], "XBMC.RunPlugin(%s)" % build_url(export_sim_recom_params))) if trailer: cm.append(("[B]%s[/B]" % trailer_title,"XBMC.RunPlugin(%s)" % build_url(trailer_params))) if self.action == 'trakt_recommendations': cm.append(("[B]Hide from Recommendations[/B]", "XBMC.RunPlugin(%s)" % build_url(hide_recommended_params))) cm.append(("[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedtvinfo,id=%s)' % tmdb_id)) cm.append(("[B]Exit TV Show List[/B]","XBMC.Container.Refresh(%s)" % build_url(exit_list_params))) listitem = xbmcgui.ListItem() listitem.setLabel(title) try: listitem.setProperties({'watchedepisodes': item['total_watched'], 'unwatchedepisodes': item['total_unwatched'], 'totalepisodes': str(item['total_episodes']), 'totalseasons': str(item['total_seasons'])}) except: listitem.setProperty('watchedepisodes', item['total_watched']) listitem.setProperty('unwatchedepisodes', item['total_unwatched']) listitem.setProperty('totalepisodes', str(item['total_episodes'])) listitem.setProperty('totalseasons', str(item['total_seasons'])) listitem.addContextMenuItems(cm) listitem.setCast(item['cast']) listitem.setUniqueIDs({'imdb': str(imdb_id), 'tmdb': str(tmdb_id), 'tvdb': str(tvdb_id)}) listitem.setArt({'poster': item['poster'], 'fanart': item['fanart'], 'icon': item['poster'], 'banner': item['banner'], 'clearart': item['clearart'], 'clearlogo': item['clearlogo'], 'landscape': item['landscape']}) listitem.setInfo('video', remove_unwanted_info_keys(item)) if is_widget: listitem.setProperty("fen_widget", 'true') if use_threading: item_list.append({'list_item': (url, listitem, True), 'item_position': item_no}) else: xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
def next_episode_context_choice(): from modules.utils import selection_dialog from modules.nav_utils import toggle_setting, build_url params = dict(parse_qsl(sys.argv[2].replace('?', ''))) content_settings = settings.nextep_content_settings() display_settings = settings.nextep_display_settings() airdate_replacement = [('%d-%m-%Y', 'Day-Month-Year'), ('%Y-%m-%d', 'Year-Month-Day'), ('%m-%d-%Y', 'Month-Day-Year')] sort_type_status = ('Recently Watched', 'Airdate', 'Title')[content_settings['sort_type']] sort_order_status = ('Descending', 'Ascending')[content_settings['sort_order']] toggle_sort_order_SETTING = ('nextep.sort_order', ('0' if sort_order_status == 'Ascending' else '1')) cache_to_disk_status = str(content_settings['cache_to_disk']) toggle_cache_to_disk_SETTING = ('nextep.cache_to_disk', ('true' if cache_to_disk_status == 'False' else 'false')) unaired_status = str(content_settings['include_unaired']) toggle_unaired_SETTING = ('nextep.include_unaired', ('true' if unaired_status == 'False' else 'false')) unwatched_status = str(content_settings['include_unwatched']) toggle_unwatched_SETTING = ('nextep.include_unwatched', ('true' if unwatched_status == 'False' else 'false')) airdate_status = str(display_settings['include_airdate']) toggle_airdate_SETTING = ('nextep.include_airdate', ('true' if airdate_status == 'False' else 'false')) airdate_format = settings.nextep_airdate_format() airdate_format_status = [ airdate_format.replace(i[0], i[1]) for i in airdate_replacement if i[0] == airdate_format ][0] airdate_highlight = display_settings['airdate_colour'].capitalize() unaired_highlight = display_settings['unaired_colour'].capitalize() unwatched_highlight = display_settings['unwatched_colour'].capitalize() choices = [ ('MANAGE IN PROGRESS SHOWS', 'manage_in_progress'), ('SORT TYPE: [I]Currently [B]%s[/B][/I]' % sort_type_status, 'Sort Type'), ('SORT ORDER: [I]Currently [B]%s[/B][/I]' % sort_order_status, 'toggle_cache_to_disk'), ('CACHE TO DISK: [I]Currently [B]%s[/B][/I]' % cache_to_disk_status, 'toggle_cache_to_disk'), ('INCLUDE UNAIRED EPISODES: [I]Currently [B]%s[/B][/I]' % unaired_status, 'toggle_unaired'), ('INCLUDE WATCHLIST/UNWATCHED TV: [I]Currently [B]%s[/B][/I]' % unwatched_status, 'toggle_unwatched'), ('INCLUDE AIRDATE: [I]Currently [B]%s[/B][/I]' % airdate_status, 'toggle_airdate'), ('AIRDATE FORMAT: [I]Currently [B]%s[/B][/I]' % airdate_format_status, 'Airdate Format'), ('AIRDATE HIGHLIGHT: [I]Currently [B]%s[/B][/I]' % airdate_highlight, 'Airdate'), ('UNAIRED HIGHLIGHT: [I]Currently [B]%s[/B][/I]' % unaired_highlight, 'Unaired'), ('UNWATCHED HIGHLIGHT: [I]Currently [B]%s[/B][/I]' % unwatched_highlight, 'Unwatched') ] if settings.watched_indicators() == 0: choices.append(('MANAGE UNWATCHED TV SHOWS', 'manage_unwatched')) if settings.watched_indicators() in (1, 2): choices.append(('CLEAR TRAKT CACHE', 'clear_cache')) string = 'Next Episode Manager' dialog_list = [i[0] for i in choices] function_list = [i[1] for i in choices] choice = selection_dialog(dialog_list, function_list, string) if not choice: return if choice in ('toggle_sort_order', 'toggle_cache_to_disk', 'toggle_unaired', 'toggle_unwatched', 'toggle_airdate'): setting = eval(choice + '_SETTING') toggle_setting(setting[0], setting[1]) elif choice == 'clear_cache': from modules.nav_utils import clear_cache clear_cache('trakt') else: if choice in ('manage_in_progress', 'manage_unwatched'): xbmc.executebuiltin('Container.Update(%s)' % build_url({ 'mode': 'build_next_episode_manager', 'action': choice })) return elif choice in ('Airdate', 'Unaired', 'Unwatched'): function = next_episode_color_choice else: function = next_episode_options_choice function(choice) xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin('RunPlugin(%s)' % build_url({'mode': 'next_episode_context_choice'}))
def build_next_episode_manager(): from modules.nav_utils import add_dir from modules.indicators_bookmarks import get_watched_status_tvshow, get_watched_info_tv def _process(tmdb_id, action): try: meta = tvshow_meta('tmdb_id', tmdb_id, meta_user_info) title = meta['title'] if action == 'manage_unwatched': action, display = 'remove', '[COLOR=%s][UNWATCHED][/COLOR] %s' % ( NEXT_EP_UNWATCHED, title) url_params = { 'mode': 'add_next_episode_unwatched', 'action': 'remove', 'tmdb_id': tmdb_id, 'title': title } elif action == 'trakt_and_fen': action, display = 'unhide' if tmdb_id in exclude_list else 'hide', '[COLOR=red][EXCLUDED][/COLOR] %s' % title if tmdb_id in exclude_list else '[COLOR=green][INCLUDED][/COLOR] %s' % title url_params = { "mode": "hide_unhide_trakt_items", "action": action, "media_type": "shows", "media_id": meta['imdb_id'], "section": "progress_watched" } else: action, display = 'remove' if tmdb_id in exclude_list else 'add', '[COLOR=red][EXCLUDED][/COLOR] %s' % title if tmdb_id in exclude_list else '[COLOR=green][INCLUDED][/COLOR] %s' % title url_params = { 'mode': 'add_to_remove_from_next_episode_excludes', 'action': action, 'title': title, 'media_id': tmdb_id } sorted_list.append({ 'tmdb_id': tmdb_id, 'display': display, 'url_params': url_params, 'meta': json.dumps(meta) }) except: pass check_meta_database() clear_all_trakt_cache_data(confirm=False) sync_watched_trakt_to_fen() params = dict(parse_qsl(sys.argv[2].replace('?', ''))) NEXT_EP_UNWATCHED = __addon__.getSetting('nextep.unwatched_colour') if not NEXT_EP_UNWATCHED or NEXT_EP_UNWATCHED == '': NEXT_EP_UNWATCHED = 'red' threads = [] sorted_list = [] action = params['action'] if action == 'manage_unwatched': tmdb_list = [i['tmdb_id'] for i in get_unwatched_next_episodes()] heading = 'Select Show to remove from Fen Next Episode:' elif settings.watched_indicators() in (1, 2): from apis.trakt_api import trakt_get_next_episodes tmdb_list, exclude_list = trakt_get_next_episodes(include_hidden=True) heading = 'Select Show to Hide/Unhide from Trakt Progress:' action = 'trakt_and_fen' else: settings.check_database(WATCHED_DB) dbcon = database.connect(WATCHED_DB) dbcur = dbcon.cursor() dbcur.execute( '''SELECT media_id FROM watched_status WHERE db_type=? GROUP BY media_id''', ('episode', )) rows = dbcur.fetchall() tmdb_list = [row[0] for row in rows] exclude_list = check_for_next_episode_excludes() heading = 'Select Show to Include/Exclude in Fen Next Episode:' add_dir({'mode': 'nill'}, '[I][COLOR=grey][B]INFO:[/B][/COLOR] [COLOR=grey2]%s[/COLOR][/I]' % heading, iconImage='settings.png') if not tmdb_list: from modules.nav_utils import notification return notification('No Shows Present', time=5000) meta_user_info = retrieve_user_info() window.setProperty('fen_fanart_error', 'true') for tmdb_id in tmdb_list: threads.append(Thread(target=_process, args=(tmdb_id, action))) [i.start() for i in threads] [i.join() for i in threads] sorted_items = sorted(sorted_list, key=lambda k: k['display']) watched_info, use_trakt = get_watched_info_tv() for i in sorted_items: try: cm = [] meta = json.loads(i['meta']) playcount, overlay, total_watched, total_unwatched = get_watched_status_tvshow( watched_info, use_trakt, meta['tmdb_id'], meta.get('total_episodes')) meta.update({ 'playcount': playcount, 'overlay': overlay, 'total_watched': str(total_watched), 'total_unwatched': str(total_unwatched) }) url = build_url(i['url_params']) browse_url = build_url({ 'mode': 'build_season_list', 'meta': i['meta'] }) cm.append( ("[B]Browse...[/B]", 'XBMC.Container.Update(%s)' % browse_url)) listitem = xbmcgui.ListItem(i['display']) listitem.setProperty('watchedepisodes', str(total_watched)) listitem.setProperty('unwatchedepisodes', str(total_unwatched)) listitem.setProperty('totalepisodes', str(meta['total_episodes'])) listitem.setProperty('totalseasons', str(meta['total_seasons'])) listitem.addContextMenuItems(cm) listitem.setArt({ 'poster': meta['poster'], 'fanart': meta['fanart'], 'banner': meta['banner'], 'clearart': meta['clearart'], 'clearlogo': meta['clearlogo'], 'landscape': meta['landscape'] }) listitem.setCast(meta['cast']) listitem.setInfo('video', remove_unwanted_info_keys(meta)) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'tvshows') xbmcplugin.endOfDirectory(__handle__, cacheToDisc=False) setView('view.main', 'tvshows')
def fetch_list(self): try: params = dict(parse_qsl(sys.argv[2].replace('?',''))) worker = True mode = params.get('mode') cache_page = settings.cache_page() try: page_no = int(params.get('new_page', '1')) except ValueError: page_no = params.get('new_page') if cache_page: if self.action == 'tmdb_tv_discover': self.cache_page_string = params['name'] if not 'new_page' in params: silent = True if is_widget else False retrieved_page = cached_page(self.cache_page_string, silent=silent) if retrieved_page: page_no = retrieved_page letter = params.get('new_letter', 'None') content_type = 'tvshows' var_module = 'tmdb_api' if 'tmdb' in self.action else 'trakt_api' if 'trakt' in self.action else 'imdb_api' if 'imdb' in self.action else None if var_module: try: module = 'apis.%s' % (var_module) function = getattr(importlib.import_module(module), self.action) except: pass if self.action in ('tmdb_tv_popular','tmdb_tv_top_rated', 'tmdb_tv_premieres','tmdb_tv_upcoming', 'tmdb_tv_airing_today','tmdb_tv_on_the_air','trakt_tv_anticipated','trakt_tv_trending'): data = function(page_no) if 'tmdb' in self.action: for item in data['results']: self.list.append(item['id']) else: for item in data: self.list.append(get_trakt_tvshow_id(item['show']['ids'])) self.new_page = {'mode': mode, 'action': self.action, 'new_page': str((data['page'] if 'tmdb' in self.action else page_no) + 1), 'foldername': self.action} elif self.action == 'tmdb_tv_discover': from modules.discover import set_history name = params['name'] query = params['query'] if page_no == 1: set_history('tvshow', name, query) data = function(query, page_no) for item in data['results']: self.list.append(item['id']) if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'query': query, 'name': name, 'new_page': str(data['page'] + 1), 'foldername': self.action} elif self.action in ('trakt_collection', 'trakt_watchlist', 'trakt_collection_widgets'): data, total_pages = function('shows', page_no, letter) self.list = [i['media_id'] for i in data] if total_pages > 2: self.total_pages = total_pages if total_pages > page_no: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'new_letter': letter, 'foldername': self.action} elif self.action == ('trakt_tv_mosts'): for item in function(params['period'], params['duration'], page_no): self.list.append((get_trakt_tvshow_id(item['show']['ids']))) self.new_page = {'mode': mode, 'action': self.action, 'period': params['period'], 'duration': params['duration'], 'new_page': str(page_no + 1), 'foldername': self.action} elif self.action == 'tmdb_tv_genres': genre_id = params['genre_id'] if 'genre_id' in params else self.multiselect_genres(params.get('genre_list')) if not genre_id: return data = function(genre_id, page_no) self.list = [i['id'] for i in data['results']] if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(data['page'] + 1), 'genre_id': genre_id, 'foldername': genre_id} elif self.action == 'tmdb_tv_languages': language = params['language'] if not language: return data = function(language, page_no) self.list = [i['id'] for i in data['results']] if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(data['page'] + 1), 'language': language, 'foldername': language} elif self.action == 'tmdb_tv_networks': data = function(params['network_id'], page_no) self.list = [i['id'] for i in data['results']] if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(data['page'] + 1), 'network_id': params['network_id'], 'foldername': params['network_id']} elif self.action == 'trakt_tv_certifications': for item in function(params['certification'], page_no): self.list.append((get_trakt_tvshow_id(item['show']['ids']))) self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'foldername': params['certification'], 'certification': params['certification']} elif self.action == 'tmdb_tv_year': data = function(params['year'], page_no) self.list = [i['id'] for i in data['results']] if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'year': params['year'], 'foldername': params['year']} elif self.action in ('in_progress_tvshows', 'favourites_tvshows', 'subscriptions_tvshows', 'kodi_library_tvshows', 'watched_tvshows'): (var_module, import_function) = ('in_progress', 'in_progress_tvshow') if 'in_progress' in self.action else ('favourites', 'retrieve_favourites') if 'favourites' in self.action else ('subscriptions', 'retrieve_subscriptions') if 'subscriptions' in self.action else ('indicators_bookmarks', 'get_watched_items') if 'watched' in self.action else ('kodi_library', 'retrieve_kodi_library') if 'library' in self.action else '' try: module = 'modules.%s' % (var_module) function = getattr(importlib.import_module(module), import_function) except: pass if self.action == 'kodi_library_tvshows': self.id_type = 'tvdb_id' data, total_pages = function('tvshow', page_no, letter) self.list = [i['media_id'] for i in data] if total_pages > 2: self.total_pages = total_pages if total_pages > page_no: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'new_letter': letter, 'foldername': self.action} elif self.action in ('tmdb_tv_similar', 'tmdb_tv_recommendations'): self.sim_recom_name = params['sim_recom_name'] self.sim_recom_tmdb = params['sim_recom_tmdb'] data = function(self.sim_recom_tmdb, page_no) self.list = [i['id'] for i in data['results']] if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(data['page'] + 1), 'sim_recom_name': self.sim_recom_name, 'sim_recom_tmdb': self.sim_recom_tmdb, 'foldername': self.action} elif self.action == 'trakt_recommendations': for item in function('shows'): self.list.append(get_trakt_tvshow_id(item['ids'])) elif self.action == 'tmdb_popular_people': import os worker = False icon_directory = settings.get_theme() data = function(page_no) content_type = 'addons' fanart = __addon__.getAddonInfo('fanart') for item in data['results']: cm = [] actor_poster = "http://image.tmdb.org/t/p/original%s" % item['profile_path'] if item['profile_path'] else os.path.join(icon_directory, 'genre_family.png') url_params = {'mode': 'people_search.main', 'actor_id': item['id'], 'actor_name': item['name'], 'actor_image': actor_poster.replace('w185', 'h632')} cm.append(("[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedactorinfo,id=%s)' % item['id'])) url = build_url(url_params) listitem = xbmcgui.ListItem(item['name']) listitem.setArt({'icon': actor_poster, 'poster': actor_poster, 'thumb': actor_poster, 'fanart': fanart, 'banner': actor_poster}) listitem.addContextMenuItems(cm) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) if data['page'] < data['total_pages']: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(int(data['page']) + 1), 'foldername': self.action} elif self.action == 'tmdb_tv_search': try: from urllib import unquote except ImportError: from urllib.parse import unquote if params.get('query') == 'NA': search_title = dialog.input("Search Fen", type=xbmcgui.INPUT_ALPHANUM) search_name = unquote(search_title) else: search_name = unquote(params.get('query')) if not search_name: return params['search_name'] = search_name data = function(search_name, page_no) total_pages = data['total_pages'] if total_pages > page_no: self.new_page = {'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'query': search_name, 'foldername': search_name} self.list = [i['id'] for i in data['results']] if self.total_pages and not is_widget: url_params = {'mode': 'build_navigate_to_page', 'db_type': 'TV Shows', 'current_page': page_no, 'total_pages': self.total_pages, 'transfer_mode': mode, 'transfer_action': self.action, 'foldername': self.action, 'query': params.get('search_name', ''), 'actor_id': params.get('actor_id', '')} self.add_dir(url_params, 'Jump To...', 'Jump To a Certain Page/Letter...', 'item_jump.png') if cache_page: cached_page(self.cache_page_string, page_no=page_no) if worker: self.worker() if self.new_page: self.add_dir(self.new_page) except: pass xbmcplugin.setContent(__handle__, content_type) xbmcplugin.endOfDirectory(__handle__) if params.get('refreshed') == 'true': xbmc.sleep(1500) setView('view.tvshows', content_type)
def _build(item): try: cm = [] season = item['season'] episode = item['episode'] ep_name = item['title'] premiered = item['premiered'] playcount, overlay = get_watched_status(watched_info, use_trakt, 'episode', tmdb_id, season, episode) resumetime = get_resumetime('episode', tmdb_id, season, episode) query = title + ' S%.2dE%.2d' % (int(season), int(episode)) display_name = '%s - %dx%.2d' % (title, season, episode) thumb = item['thumb'] if 'episodes' in item['thumb'] else fanart meta.update({'vid_type': 'episode', 'rootname': display_name, 'season': season, 'episode': episode, 'premiered': premiered, 'ep_name': ep_name, 'plot': item['plot']}) item.update({'trailer': trailer, 'tvshowtitle': title, 'genre': genre, 'duration': duration, 'mpaa': mpaa, 'studio': studio, 'playcount': playcount, 'overlay': overlay}) meta_json = json.dumps(meta) url_params = {'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': tmdb_id, 'query': query, 'tvshowtitle': meta['rootname'], 'season': season, 'episode': episode, 'meta': meta_json} url = build_url(url_params) try: d = premiered.split('-') episode_date = date(int(d[0]), int(d[1]), int(d[2])) except: episode_date = date(2000,1,1) if season == 0 else None unaired = False display = ep_name if not episode_date or current_adjusted_date < episode_date: unaired = True display = '[I][COLOR %s]%s[/COLOR][/I]' % (UNAIRED_EPISODE_COLOUR, ep_name) item['title'] = display item['sortseason'] = season item['sortepisode'] = episode (state, action) = ('Watched', 'mark_as_watched') if playcount == 0 else ('Unwatched', 'mark_as_unwatched') playback_menu_params = {'mode': 'playback_menu', 'suggestion': query, 'play_params': json.dumps(url_params)} if not unaired: watched_unwatched_params = {"mode": "mark_episode_as_watched_unwatched", "action": action, "media_id": tmdb_id, "imdb_id": imdb_id, "tvdb_id": tvdb_id, "season": season, "episode": episode, "title": title, "year": year} cm.append(("[B]Mark %s %s[/B]" % (state, watched_title),'RunPlugin(%s)' % build_url(watched_unwatched_params))) cm.append(("[B]Options[/B]",'RunPlugin(%s)' % build_url(playback_menu_params))) if not unaired and resumetime != '0': cm.append(("[B]Clear Progress[/B]", 'RunPlugin(%s)' % build_url({"mode": "watched_unwatched_erase_bookmark", "db_type": "episode", "media_id": tmdb_id, "season": season, "episode": episode, "refresh": "true"}))) cm.append(("[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedtvinfo,id=%s)' % tmdb_id)) listitem = xbmcgui.ListItem() listitem.setLabel(display) listitem.setProperty("resumetime", resumetime) listitem.addContextMenuItems(cm) listitem.setArt({'poster': show_poster, 'fanart': fanart, 'thumb': thumb, 'banner': banner, 'clearart': clearart, 'clearlogo': clearlogo, 'landscape': landscape}) listitem.setCast(cast) listitem.setUniqueIDs({'imdb': str(imdb_id), 'tmdb': str(tmdb_id), 'tvdb': str(tvdb_id)}) listitem.setInfo('video', remove_unwanted_info_keys(item)) if is_widget: try: listitem.setProperties({'fen_widget': 'true', 'fen_playcount': str(playcount), 'fen_playback_menu_params': json.dumps(playback_menu_params)}) except: listitem.setProperty("fen_widget", 'true') listitem.setProperty("fen_playcount", str(playcount)) listitem.setProperty("fen_playback_menu_params", json.dumps(playback_menu_params)) if use_threading: item_list.append((url, listitem, False)) else: xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=False) except: pass
def build_episode(item, watched_info, use_trakt, meta_user_info): from modules.utils import make_day def check_for_unaired(): if item.get('ignore_unaired', False): return False try: d = first_aired.split('-') episode_date = date(int(d[0]), int(d[1]), int(d[2])) except: episode_date = None current_adjusted_date = settings.adjusted_datetime() unaired = False if not episode_date or current_adjusted_date < episode_date: unaired = True return unaired def build_display(): if nextep_info: display_first_aired = make_day(first_aired) airdate = '[[COLOR %s]%s[/COLOR]] ' % (nextep_info['airdate_colour'], display_first_aired) if nextep_info['include_airdate'] else '' highlight_color = nextep_info['unwatched_colour'] if item.get('unwatched', False) else nextep_info['unaired_colour'] if unaired else '' italics_open, italics_close = ('[I]', '[/I]') if highlight_color else ('', '') if highlight_color: episode_info = '%s[COLOR %s]%dx%.2d - %s[/COLOR]%s' % (italics_open, highlight_color, info['season'], info['episode'], info['title'], italics_close) else: episode_info = '%s%dx%.2d - %s%s' % (italics_open, info['season'], info['episode'], info['title'], italics_close) display = '%s%s: %s' % (airdate, title, episode_info) elif trakt_calendar: display_first_aired = make_day(first_aired) display = '[%s] %s: %dx%.2d - %s' % (display_first_aired, title.upper(), info['season'], info['episode'], info['title']) if unaired: UNAIRED_EPISODE_COLOUR = settings.unaired_episode_colour() if not UNAIRED_EPISODE_COLOUR or UNAIRED_EPISODE_COLOUR == '': UNAIRED_EPISODE_COLOUR = 'red' displays = display.split(']') display = '[COLOR %s]' % UNAIRED_EPISODE_COLOUR + displays[0] + '][/COLOR]' + displays[1] else: UNAIRED_EPISODE_COLOUR = settings.unaired_episode_colour() if not UNAIRED_EPISODE_COLOUR or UNAIRED_EPISODE_COLOUR == '': UNAIRED_EPISODE_COLOUR = 'red' color_tags = ('[COLOR %s]' % UNAIRED_EPISODE_COLOUR, '[/COLOR]') if unaired else ('', '') display = '%s: %s%dx%.2d - %s%s' % (title.upper(), color_tags[0], info['season'], info['episode'], info['title'], color_tags[1]) return display try: cm = [] nextep_info = item.get('nextep_display_settings', None) trakt_calendar = item.get('trakt_calendar', False) watched_indicators = settings.watched_indicators() action = item.get('action', '') meta = item['meta'] tmdb_id = meta['tmdb_id'] tvdb_id = meta['tvdb_id'] imdb_id = meta["imdb_id"] title = meta['title'] year = meta['year'] episodes_data = tikimeta.season_episodes_meta(tmdb_id, tvdb_id, item['season'], meta['tvdb_summary']['airedSeasons'], meta['season_data'], meta_user_info) info = [i for i in episodes_data if i['episode'] == item['episode']][0] first_aired = info['premiered'] season = info['season'] episode = info['episode'] unaired = check_for_unaired() if unaired and not item.get('include_unaired', False): return thumb = info['thumb'] if 'episodes' in info['thumb'] else meta['fanart'] playcount, overlay = get_watched_status(watched_info, use_trakt, 'episode', tmdb_id, season, episode) resumetime = get_resumetime('episode', tmdb_id, season, episode) info.update({'trailer': str(meta.get('trailer')), 'tvshowtitle': title, 'genre': meta.get('genre'), 'duration': meta.get('duration'), 'mpaa': meta.get('mpaa'), 'studio': meta.get('studio'), 'playcount': playcount, 'overlay': overlay}) query = title + ' S%.2dE%.2d' % (season, episode) display = build_display() rootname = '{0} ({1})'.format(title, year) meta.update({'vid_type': 'episode', 'rootname': rootname, 'season': season, 'episode': episode, 'premiered': first_aired, 'ep_name': info['title'], 'plot': info['plot']}) meta_json = json.dumps(meta) url_params = {'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': tmdb_id, 'query': query, 'tvshowtitle': meta['rootname'], 'season': season, 'episode': episode, 'meta': meta_json} url = build_url(url_params) browse_url = build_url({'mode': 'build_season_list', 'meta': meta_json}) playback_menu_params = {'mode': 'playback_menu', 'suggestion': query, 'play_params': json.dumps(url_params)} (wstate, waction) = ('Watched', 'mark_as_watched') if playcount == 0 else ('Unwatched', 'mark_as_unwatched') watched_title = 'Trakt' if watched_indicators in (1, 2) else "Fen" watched_params = {"mode": "mark_episode_as_watched_unwatched", "action": waction, "media_id": tmdb_id, "imdb_id": imdb_id, "tvdb_id": tvdb_id, "season": season, "episode": episode, "title": title, "year": year} if action == 'next_episode': nextep_manage_params = {"mode": "next_episode_context_choice"} if not unaired: cm.append(("[B]Mark %s %s[/B]" % (wstate, watched_title),'RunPlugin(%s)' % build_url(watched_params))) cm.append(("[B]Options[/B]",'RunPlugin(%s)' % build_url(playback_menu_params))) if action == 'next_episode': cm.append(("[B]Next Episode Manager[/B]",'RunPlugin(%s)'% build_url(nextep_manage_params))) if nextep_info['cache_to_disk']: cm.append(("[B]Refresh...[/B]",'Container.Refresh()')) cm.append(("[B]Browse...[/B]",'Container.Update(%s)' % browse_url)) cm.append(("[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedtvinfo,id=%s)' % tmdb_id)) if not unaired and resumetime != '0': cm.append(("[B]Clear Progress[/B]", 'RunPlugin(%s)' % build_url({"mode": "watched_unwatched_erase_bookmark", "db_type": "episode", "media_id": tmdb_id, "season": season, "episode": episode, "refresh": "true"}))) listitem = xbmcgui.ListItem() listitem.setLabel(display) listitem.setProperty("resumetime", resumetime) listitem.setArt({'poster': meta['poster'], 'fanart': meta['fanart'], 'thumb':thumb, 'banner': meta['banner'], 'clearart': meta['clearart'], 'clearlogo': meta['clearlogo'], 'landscape': meta['landscape']}) listitem.addContextMenuItems(cm) listitem.setCast(meta['cast']) listitem.setUniqueIDs({'imdb': str(imdb_id), 'tmdb': str(tmdb_id), 'tvdb': str(tvdb_id)}) info['title'] = display listitem.setInfo('video', remove_unwanted_info_keys(info)) if is_widget: try: listitem.setProperties({'fen_widget': 'true', 'fen_playcount': str(playcount), 'fen_playback_menu_params': json.dumps(playback_menu_params)}) except: listitem.setProperty("fen_widget", 'true') listitem.setProperty("fen_playcount", str(playcount)) listitem.setProperty("fen_playback_menu_params", json.dumps(playback_menu_params)) return {'listitem': (url, listitem, False), 'curr_last_played_parsed': item.get('curr_last_played_parsed', ''), 'label': display, 'order': item.get('order', ''), 'name': query, 'first_aired': first_aired} except: pass
def browse_ad_cloud(folder): final_files = [] extensions = supported_video_extensions() torrent_folder = json.loads(folder) links = torrent_folder['links'] total_size = torrent_folder['size'] try: links_count = len([ v for k, v in links.items() if v.lower().endswith(tuple(extensions)) ]) for k, v in links.items(): if v.lower().endswith(tuple(extensions)): size = total_size / links_count final_files.append({'name': v, 'down_url': k, 'size': size}) except: links_count = len([ v for k, v in links.iteritems() if v.lower().endswith(tuple(extensions)) ]) for k, v in links.iteritems(): if v.lower().endswith(tuple(extensions)): size = total_size / links_count final_files.append({'name': v, 'down_url': k, 'size': size}) for count, item in enumerate(final_files, 1): try: cm = [] url_link = item['down_url'] name = clean_file_name(item['name']).upper() size = item['size'] display_size = float(int(size)) / 1073741824 display = '%02d | %.2f GB | [I]%s [/I]' % (count, display_size, name) url_params = {'mode': 'alldebrid.resolve_ad', 'url': url_link} url = build_url(url_params) down_file_params = { 'mode': 'download_file', 'name': name, 'url': url_link, 'db_type': 'alldebrid_file', 'image': default_ad_icon } cm.append(("[B]Download File[/B]", 'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({ 'icon': default_ad_icon, 'poster': default_ad_icon, 'thumb': default_ad_icon, 'fanart': fanart, 'banner': default_ad_icon }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')
def browse_rd_cloud(folder_id): try: torrent_files = RealDebrid.user_cloud_info(folder_id) except: return extensions = supported_video_extensions() try: file_info = [ i for i in torrent_files['files'] if i['path'].lower().endswith(tuple(extensions)) ] file_urls = torrent_files['links'] for c, i in enumerate(file_info): try: i.update({'url_link': file_urls[c]}) except: pass pack_info = sorted(file_info, key=lambda k: k['path']) except: return xbmcgui.Dialog().ok('Fen - Real Debrid', 'Cannot display Malformed Pack.') for count, item in enumerate(pack_info, 1): try: cm = [] name = item['path'] if name.startswith('/'): name = name.split('/')[-1] name = clean_file_name(name).upper() url_link = item['url_link'] if url_link.startswith('/'): url_link = 'http' + url_link size = float(int(item['bytes'])) / 1073741824 display = '%02d | [B]FILE[/B] | %.2f GB | [I]%s [/I]' % ( count, size, name) url_params = {'mode': 'real_debrid.resolve_rd', 'url': url_link} url = build_url(url_params) down_file_params = { 'mode': 'download_file', 'name': name, 'url': url_link, 'db_type': 'realdebrid_file', 'image': default_rd_icon } cm.append(("[B]Download File[/B]", 'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setArt({ 'icon': default_rd_icon, 'poster': default_rd_icon, 'thumb': default_rd_icon, 'fanart': fanart, 'banner': default_rd_icon }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.premium')