def _collect_results(self): if 'local' in self.active_scrapers: if self.check_library or self.autoplay: if self._check_library_before_search(): window.setProperty('fen_search_results', json.dumps(self.sources)) if self.background: return xbmc.executebuiltin(self.action % build_url({'mode': 'play_auto_nextep'})) return xbmc.executebuiltin(self.action % build_url({'mode': 'play_display_results'})) else: self.providers.append(('local', LocalLibrarySource())) if 'downloads' in self.active_scrapers: if self.check_downloads or self.autoplay: if self._check_downloads_before_search(): window.setProperty('fen_search_results', json.dumps(self.sources)) if self.background: return xbmc.executebuiltin(self.action % build_url({'mode': 'play_auto_nextep'})) return xbmc.executebuiltin(self.action % build_url({'mode': 'play_display_results'})) else: self.providers.append(('downloads', DownloadsSource())) if 'furk' in self.active_scrapers: from resources.lib.sources.furk import FurkSource self.providers.append(('furk', FurkSource())) if 'easynews' in self.active_scrapers: from resources.lib.sources.easynews import EasyNewsSource self.providers.append(('easynews', EasyNewsSource())) if 'external' in self.active_scrapers: from resources.lib.sources.external import ExternalSource self.providers.append(('external', ExternalSource())) for i in range(len(self.providers)): self.threads.append(Thread(self._activate_providers, self.providers[i][1])) self.starting_providers.append((self.threads[i].getName(), self.providers[i][0])) [i.start() for i in self.threads] if 'external' in self.active_scrapers or self.background: [i.join() for i in self.threads] else: self._internal_scrapers_dialog() return self._filter_results(self.sources)
def _build_directory(item, item_no): try: uncached = item.get('uncached', False) external = item.get('external', False) mode = 'furk.add_uncached_file' if uncached else 'play_file' url = build_url({'mode': mode, 'title': item.get('title'), 'source': json.dumps([item])}) cm = [] if external: display_name = item.get("label") else: display_name = item.get("display_name") display = '%02d | %s' % (item_no+1, display_name) listitem = xbmcgui.ListItem(display) listitem.setArt({'poster': meta['poster'], 'fanart': meta['fanart'], 'thumb': meta['poster']}) playback_params = {'mode': 'playback_menu', 'from_results': True} cm.append(("[B]Options[/B]",'XBMC.RunPlugin(%s)' % build_url(playback_params))) if not uncached: if item['scrape_provider'] == 'furk': add_files_params = {'mode': 'furk.add_to_files', 'name': item.get("name"), 'item_id': item.get("id")} cm.append(("[B]Add to My Files[/B]",'XBMC.RunPlugin(%s)' % build_url(add_files_params))) if 'PACK' in display: down_archive_params = {'mode': 'download_file', 'name': item.get("name"), 'url': item.get("url_dl"), 'db_type': 'archive', 'image': default_furk_icon} cm.append(("[B]Download Archive[/B]",'XBMC.RunPlugin(%s)' % build_url(down_archive_params))) if item['scrape_provider'] not in ('local', 'downloads'): down_file_params = {'mode': 'download_file', 'name': meta.get('rootname'), 'url': item.get("url_dl"), 'image': meta.get('poster', ''), 'source': json.dumps([item]), 'meta': meta_json} if item['scrape_provider'] == 'furk': down_file_params['archive'] = True cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem.addContextMenuItems(cm) if meta['vid_type'] == 'movie': listitem.setInfo('video', {'title': meta.get('title', ''), 'year': meta.get('year', ''), 'plot': meta.get('plot', '')}) elif meta['vid_type'] == 'episode': listitem.setInfo('video', {'title': meta.get('rootname', ''), 'plot': meta.get('plot', '')}) item_list.append({'url': url, 'list_item': listitem, 'item_no': item_no}) except: pass
def furk_easynews_direct_search_choice(suggestion, from_results): from resources.lib.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})) else: xbmc.executebuiltin('XBMC.Container.Update(%s)' % build_url(choice))
def next_episode_context_choice(): from urlparse import parse_qsl from resources.lib.modules.utils import selection_dialog from resources.lib.modules.nav_utils import toggle_setting, build_url import settings params = dict(parse_qsl(sys.argv[2].replace('?',''))) content_settings = settings.nextep_content_settings() display_settings = settings.nextep_display_settings() force_display_status = str(display_settings['force_display']) toggle_force_display_SETTING = ('nextep.force_display', ('true' if force_display_status == 'False' else 'false')) 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')) 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_sort_order'), ('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'), ('ATTEMPT TO MAKE SKIN HONOR FULL LABEL: [I]Currently [B]%s[/B][/I]' % force_display_status, 'toggle_force_display'), ('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_unaired', 'toggle_unwatched', 'toggle_airdate', 'toggle_force_display'): setting = eval(choice + '_SETTING') toggle_setting(setting[0], setting[1]) elif choice == 'clear_cache': from resources.lib.modules.nav_utils import clear_cache clear_cache('trakt') else: if choice in ('manage_in_progress', 'manage_unwatched'): xbmc.executebuiltin('XBMC.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 my_furk_audio_favourites(): from resources.lib.modules.favourites import retrieve_favourites results = retrieve_favourites('audio', '', '') for item in results: try: cm = [] name = item.split('<>')[0] item_id = item.split('<>')[1] url_dl = item.split('<>')[2] size = item.split('<>')[3] display_size = str(round(float(size) / 1048576000, 1)) display = '[B]%sGB[/B] | [I]%s[/I]' % (display_size, name) url_params = { 'mode': 'furk.furk_tfile_audio', 'name': name, 'id': item_id } url = build_url(url_params) con_remove_favs = { 'mode': 'remove_from_favourites', 'db_type': 'audio', 'tmdb_id': item } con_download_archive = { 'mode': 'download_file', 'name': name, 'url': url_dl, 'image': default_furk_icon, 'db_type': 'archive' } cm.append(("[B]Remove from Fen Favourites[/B]", 'XBMC.RunPlugin(%s)' % build_url(con_remove_favs))) cm.append(("[B]Download Archive[/B]", 'XBMC.RunPlugin(%s)' % build_url(con_download_archive))) listitem = xbmcgui.ListItem(display) listitem.addContextMenuItems(cm) listitem.setThumbnailImage(default_furk_icon) listitem.setArt({'fanart': fanart}) listitem.setInfo(type='video', infoLabels={ 'title': display, 'size': int(size) }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.furk_files')
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': 'nill' } 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.setThumbnailImage(default_furk_icon) listitem.setArt({'fanart': fanart}) listitem.setInfo( 'video', { 'title': display_name, 'size': int(item['size']), 'duration': item['length'] }) listitem.setProperty("IsPlayable", "true") xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.furk_files')
def _return_results(self, results): if not results: return self._no_results() if self.autoplay: return self._filter_autoplay(results) if self.include_uncached_results: results += self.uncached_results window.setProperty('fen_search_results', json.dumps(results)) xbmc.sleep(200) hide_busy_dialog() if self.background: return xbmc.executebuiltin(self.action % build_url({'mode': 'play_display_results'})) if self.use_dialog or self.from_library: return self.dialog_results() return xbmc.executebuiltin(self.action % build_url({'mode': 'play_display_results'}))
def _filter_autoplay(self, results): local_file = [i for i in results if i.get("local")] downloads_file = [i for i in results if i.get("downloads")] if local_file: results = local_file elif downloads_file: results = downloads_file else: if self.prefer_hevc: hevc_list = [dict(i, **{'hevc':self._get_hevc_status(i.get("display_name", ""))}) for i in results] hevc_list = [i for i in hevc_list if i.get("hevc")] if hevc_list: results = hevc_list results = [dict(i, **{'autoplay':True}) for i in results] window.setProperty('fen_search_results', json.dumps(results)) if self.background: return xbmc.executebuiltin(self.action % build_url({'mode': 'play_auto_nextep'})) if self.use_dialog or self.from_library: return self.dialog_results() return xbmc.executebuiltin(self.action % build_url({'mode': 'play_display_results'}))
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 resources.lib.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.setThumbnailImage(default_furk_icon) listitem.setArt({'fanart': fanart}) 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.furk_files')
def torrent_status_browser(files): from datetime import timedelta from resources.lib.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) 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.furk_files')
def build_add_to_remove_from_list(meta='', media_type='', orig_mode='', from_search=''): from urlparse import parse_qsl import json from resources.lib.modules.nav_utils import build_url from resources.lib.modules.settings import watched_indicators 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'), (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')) if mlc == 'remove' and watched_indicators() == 1: listing.append(('Remove Fen/Trakt Watched Sync (ReSync Watched Info)', 'resync')) 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"], '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']} elif choice == 'resync': url = {'mode': 'trakt_sync_watched_to_fen', 'refresh': True} xbmc.executebuiltin('XBMC.RunPlugin(%s)' % build_url(url))
def make_stream(self, stream_file, params): if not xbmcvfs.exists(stream_file): from resources.lib.modules.nav_utils import build_url file = xbmcvfs.File(stream_file, 'w') content = build_url(params) file.write(str(content)) file.close()
def furkTFile(self, file_id): from resources.lib.modules.furk_api import FurkAPI from resources.lib.indexers.furk import get_release_quality hide_busy_dialog() close_all_dialog() t_files = FurkAPI().t_files(file_id) t_files = [i for i in t_files if 'video' in i['ct'] and 'bitrate' in i] meta = json.loads(window.getProperty('fen_media_meta')) from_library = meta.get('from_library', False) not_widget = xbmc.getInfoLabel('Container.PluginName') use_dialog = True if from_library or not not_widget else settings.use_dialog() display_list = [] if use_dialog: display_list = ['%02d | [B]%s[/B] | [B]%.2f GB[/B] | [I]%s[/I]' % \ (count, get_release_quality(i['name'], i['url_dl'], t_file='yep')[0], float(i['size'])/1073741824, clean_file_name(i['name']).upper()) for count, i in enumerate(t_files, 1)] chosen = dialog.select("Fen Results", display_list) if chosen < 0: return None chosen_result = t_files[chosen] url_dl = chosen_result['url_dl'] from resources.lib.modules.player import FenPlayer return FenPlayer().run(url_dl) for count, item in enumerate(t_files, 1): try: cm = [] url_params = {'mode': 'media_play', 'url': item['url_dl']} url = build_url(url_params) name = clean_file_name(item['name']) video_quality, video_type = get_release_quality(item['name'], item['url_dl'], t_file='yep') json_meta = json.dumps(meta) display_name = '%02d | [B]%s[/B] | [B]%s[/B] | [B]%.2f GB[/B] | [I]%s[/I]' % (count, video_quality, video_type, float(item['size'])/1073741824, name.upper()) listitem = xbmcgui.ListItem(display_name) listitem.setArt({'poster': meta.get('poster', ''), 'thumb': meta.get('poster', ''), 'fanart': meta.get('fanart')}) playback_params = {'mode': 'playback_menu', 'from_results': True} down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': item['url_dl'], 'meta': json_meta} cm.append(("[B]Options[/B]",'XBMC.RunPlugin(%s)' % build_url(playback_params))) cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem.addContextMenuItems(cm) if meta.get('vid_type') == 'movie': listitem.setInfo('video', {'title': meta.get('title', ''), 'year': meta.get('year', ''), 'plot': meta.get('plot', '')}) else: listitem.setInfo('video', {'title': meta['rootname'], 'plot': meta.get('plot', '')}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'files') xbmcplugin.endOfDirectory(__handle__) setView('view.pack_results')
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': 'nill'} 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({'thumb': default_easynews_icon, 'fanart': fanart}) listitem.setInfo(type='video', infoLabels={'title': display, 'size': int(item['rawSize'])}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
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, iconImage=icon) listitem.setArt({'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 build_list_object(): try: cm = [] url_params = { 'mode': 'media_play', 'url': item['url_dl'], 'rootname': 'nill' } 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': 'furk_file' } cm.append(("[B]Download File[/B]", 'XBMC.RunPlugin(%s)' % build_url(down_file_params))) listitem.addContextMenuItems(cm) listitem.setThumbnailImage(default_furk_icon) listitem.setArt({'fanart': fanart}) listitem.setInfo(type='music', infoLabels={ 'title': track_name, 'size': int(item['size']), 'album': item['path'], 'duration': item['length'] }) listitem.setProperty("IsPlayable", "true") xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=False) except: pass
def build_next_episode_play(): infoLabels = season_episodes_meta(tmdb_id, season) ep_data = infoLabels['episodes'] ep_data = [i for i in ep_data if int(i['season_number']) == int(season) and int(i['episode_number']) == int(episode)][0] 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['name'], "episode": episode, 'premiered': ep_data['air_date'], '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['name']} if from_library: url_params.update({'library': 'True', 'plot': ep_data['overview']}) return build_url(url_params)
def search_history(): import xbmc, xbmcgui, xbmcplugin import sys, os from urlparse import parse_qsl import urllib from resources.lib.modules.nav_utils import build_url, setView from resources.lib.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 ('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 for h in history: try: cm = [] name = urllib.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': '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, iconImage=os.path.join( get_theme(), 'search.png')) listitem.setArt({ 'fanart': os.path.join( xbmc.translatePath(__addon__.getAddonInfo('path')), 'fanart.png') }) listitem.setInfo(type='video', infoLabels={'Title': name}) listitem.addContextMenuItems(cm) xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, isFolder=True) except: pass xbmcplugin.setContent(int(sys.argv[1]), 'files') xbmcplugin.endOfDirectory(int(sys.argv[1])) setView('view.main')
def playback_menu(from_results=False, suggestion=None): from urlparse import parse_qsl from resources.lib.modules.nav_utils import toggle_setting, build_url, open_settings, clear_cache from resources.lib.modules import settings content = xbmc.getInfoLabel('Container.Content') params = dict(parse_qsl(sys.argv[2].replace('?',''))) from_results = params.get('from_results', from_results) suggestion = params.get('suggestion', suggestion) autoplay_status, autoplay_toggle, filter_setting = ('On', 'false', 'autoplay_quality') if settings.auto_play() else ('Off', 'true', 'results_quality') autoplay_next_status, autoplay_next_toggle = ('On', 'false') if settings.autoplay_next_episode() else ('Off', 'true') results_display_status, results_display_toggle = ('Dialog', '0') if settings.use_dialog() else ('Directory', '1') prefer_hevc_status, prefer_hevc_toggle = ('On', 'false') if settings.prefer_hevc() else ('Off', 'true') auto_resolve_status, auto_resolve_toggle = ('On', 'false') if settings.auto_resolve() else ('Off', 'true') active_scrapers = settings.active_scrapers() current_scrapers_status = ', '.join([i.capitalize() for i in active_scrapers]) if len(active_scrapers) >= 1 else 'None Active' current_filter_status = ', '.join(settings.quality_filter(filter_setting)) indicators_status, indicators_toggle = ('Trakt', '0') if settings.watched_indicators() in (1, 2) else ('Fen', '1') string = 'Please choose Fen Setting to Change...' listing = [('AUTOPLAY: [I]Currently [B]%s[/B][/I]' % autoplay_status, 'toggle_autoplay')] if autoplay_status == 'On': listing += [('PREFER HEVC IN AUTOPLAY: [I]Currently [B]%s[/B][/I]' % prefer_hevc_status, 'toggle_prefer_hevc')] listing += [('AUTOPLAY NEXT EPISODE: [I]Currently [B]%s[/B][/I]' % autoplay_next_status, 'toggle_autoplay_next')] listing += [('ENABLE SCRAPERS: [I]Currently [B]%s[/B][/I]' % current_scrapers_status, 'enable_scrapers')] if autoplay_status == 'Off': listing += [('DISPLAY RESULTS: [I]Currently [B]%s[/B][/I]' % results_display_status, 'toggle_display_results')] listing += [('AUTO RESOLVE FURK PACKS: [I]Currently [B]%s[/B][/I]' % auto_resolve_status, 'toggle_auto_resolve')] listing += [('QUALITY FILTERS: [I]Currently [B]%s[/B][/I]' % current_filter_status, 'set_filters')] listing += [('SWITCH INDICATOR PROVIDER: [I]Currently [B]%s[/B][/I]' % indicators_status, 'toggle_indicators')] if settings.watched_indicators() in (1,2): listing += [('CLEAR TRAKT CACHE', 'clear_trakt_cache')] if content in ('movies', 'episodes'): listing += [('FURK/EASYNEWS SEARCH: [B][I]%s[/I][/B]' % params.get('suggestion', ''), 'search_directly')] listing += [('OPEN EXTERNAL SCRAPER SETTINGS', 'open_scraper_settings')] listing += [('OPEN FEN SETTINGS', 'open_fen_settings')] listing += [('[B]SAVE SETTINGS AND EXIT[/B]', 'save_and_exit')] xbmc.sleep(500) choice = selection_dialog([i[0] for i in listing], [i[1] for i in listing], string) if choice == 'toggle_autoplay': toggle_setting('auto_play', autoplay_toggle) elif choice == 'toggle_prefer_hevc': toggle_setting('prefer_hevc', prefer_hevc_toggle) elif choice == 'toggle_autoplay_next': toggle_setting('autoplay_next_episode', autoplay_next_toggle) elif choice == 'enable_scrapers': enable_scrapers() elif choice == 'toggle_display_results': toggle_setting('use_dialog', results_display_toggle) elif choice == 'toggle_auto_resolve': toggle_setting('auto_resolve', auto_resolve_toggle) elif choice == 'set_filters': set_autoplay_quality(action=True) if autoplay_status == 'On' else set_results_quality(action=True) elif choice == 'toggle_indicators': toggle_setting('watched_indicators', indicators_toggle) elif choice == 'clear_trakt_cache': clear_cache('trakt') elif choice == 'search_directly': furk_easynews_direct_search_choice(suggestion, from_results) elif choice == 'open_scraper_settings': xbmc.executebuiltin('Addon.OpenSettings(%s)' % 'script.module.tikiscrapers') elif choice == 'open_fen_settings': open_settings('0.0') if choice in ('toggle_indicators', 'clear_trakt_cache') and content in ('movies', 'tvshows', 'seasons', 'episodes'): xbmc.executebuiltin('Container.Refresh') if choice in (None, 'save_and_exit', 'toggle_indicators', 'clear_trakt_cache', 'search_directly', 'open_scraper_settings', 'open_fen_settings'): return xbmc.executebuiltin('RunPlugin(%s)' % build_url({'mode': 'playback_menu', 'from_results': from_results, 'suggestion': suggestion}))
def build_next_episode_manager(): from urlparse import parse_qsl from resources.lib.indexers.tvshows import aired_episode_number_tvshow from resources.lib.modules.nav_utils import add_dir from resources.lib.modules.indicators_bookmarks import get_watched_status_tvshow 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' VIEW_NEM = __addon__.getSetting('view.main') 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 resources.lib.modules.trakt 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:' 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 resources.lib.modules.nav_utils import notification notification('No Shows Present', time=5000) else: for tmdb_id in tmdb_list: try: meta = make_fresh_tvshow_meta('tmdb_id', tmdb_id) if action == 'manage_unwatched': action, display = 'remove', '[COLOR=%s][UNWATCHED][/COLOR] %s' % (NEXT_EP_UNWATCHED, meta['title']) url_params = {'mode': 'add_next_episode_unwatched', 'action': 'remove', 'tmdb_id': meta['tmdb_id'], 'title': meta['title']} elif settings.watched_indicators() in (1, 2): action, display = 'unhide' if str(meta['tmdb_id']) in exclude_list else 'hide', '[COLOR=red][EXCLUDED][/COLOR] %s' % meta['title'] if str(meta['tmdb_id']) in exclude_list else '[COLOR=green][INCLUDED][/COLOR] %s' % meta['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 str(meta['tmdb_id']) in exclude_list else 'add', '[COLOR=red][EXCLUDED][/COLOR] %s' % meta['title'] if str(meta['tmdb_id']) in exclude_list else '[COLOR=green][INCLUDED][/COLOR] %s' % meta['title'] url_params = {'mode': 'add_to_remove_from_next_episode_excludes', 'action': action, 'title': meta['title'], 'media_id': meta['tmdb_id']} sorted_list.append({'tmdb_id': tmdb_id, 'display': display, 'url_params': url_params, 'meta': json.dumps(meta)}) except: pass sorted_items = sorted(sorted_list, key=lambda k: k['display']) for i in sorted_items: try: cm = [] meta = json.loads(i['meta']) rootname = meta['title'] + " (" + str(meta['year']) + ")" meta['rootname'] = rootname aired_episodes = aired_episode_number_tvshow(meta) playcount, overlay, total_watched, total_unwatched = get_watched_status_tvshow(meta['tmdb_id'], aired_episodes) 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(aired_episodes)) listitem.setProperty('totalseasons', str(meta['number_of_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', { 'title': meta['title'], 'size': '0', 'duration': meta['duration'], 'plot': meta['plot'], 'rating': meta['rating'], 'premiered': meta['premiered'], 'studio': meta['studio'],'year': meta['year'], 'genre': meta['genre'],'imdbnumber': meta['imdb_id'], 'votes': meta['votes'], 'playcount': playcount, 'overlay': overlay}) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'tvshows') xbmcplugin.endOfDirectory(__handle__, cacheToDisc=False) setView(VIEW_NEM)
def build_movie_content(self): watched_indicators = settings.watched_indicators() all_trailers = settings.all_trailers() for i in sorted(self.items, key=lambda k: k['item_no']): try: cm = [] if not 'rootname' in i: i['rootname'] = '{0} ({1})'.format(i['title'], i['year']) meta_json = json.dumps(i) url_params = { 'mode': 'play_media', 'vid_type': 'movie', 'query': i['rootname'], 'tmdb_id': i['tmdb_id'], 'meta': meta_json } url = build_url(url_params) from_search = 'true' if self.action in ( 'tmdb_movies_search', 'tmdb_movies_people_search') else 'false' playback_params = { 'mode': 'playback_menu', 'suggestion': i['rootname'] } hide_recommended_params = { 'mode': 'trakt.hide_recommendations', 'db_type': 'movies', 'imdb_id': i['imdb_id'] } watched_title = 'Trakt' if watched_indicators in (1, 2) else "Fen" (state, action) = ('Watched', 'mark_as_watched') if i['playcount'] == 0 else ( 'Unwatched', 'mark_as_unwatched') (state2, action2) = ('Watched', 'mark_as_watched') if state == 'Unwatched' else ( 'Unwatched', 'mark_as_unwatched') watched_unwatched_params = { "mode": "mark_movie_as_watched_unwatched", "action": action, "media_id": i['tmdb_id'], "from_search": from_search, "title": i['title'], "year": i['year'] } add_remove_params = { "mode": "build_add_to_remove_from_list", "meta": meta_json, "media_type": "movie", "from_search": from_search, "orig_mode": self.action } sim_rel_params = { "mode": "similar_related_choice", "db_type": "movies", "tmdb_id": i['tmdb_id'], "imdb_id": i['imdb_id'], "from_search": from_search } (trailer_params, trailer_title) = ( { 'mode': 'play_trailer', 'url': i['trailer'], 'all_trailers': json.dumps(i['all_trailers']) }, 'Choose Trailer') if (all_trailers and i.get( 'all_trailers', False)) else ({ 'mode': 'play_trailer', 'url': i['trailer'] }, 'Trailer') exit_list_params = { "mode": "navigator.main", "action": "MovieList" } listitem = xbmcgui.ListItem(i['title']) listitem.setProperty("resumetime", get_resumetime('movie', i['tmdb_id'])) cm.append(("[B]Mark %s %s[/B]" % (state, watched_title), "XBMC.RunPlugin(%s)" % build_url(watched_unwatched_params))) if listitem.getProperty("resumetime") != '0.000000': cm.append(("[B]Mark %s %s[/B]" % (state2, watched_title), 'XBMC.RunPlugin(%s)' % build_url({ "mode": "mark_movie_as_watched_unwatched", "action": action2, "media_id": i['tmdb_id'], "from_search": from_search, "title": i['title'], "year": i['year'] }))) cm.append(("[B]Options[/B]", "XBMC.RunPlugin(%s)" % build_url(playback_params))) cm.append( ("[B]Add/Remove[/B]", "XBMC.RunPlugin(%s)" % build_url(add_remove_params))) cm.append(("[B]Similar/Related[/B]", "XBMC.RunPlugin(%s)" % build_url(sim_rel_params))) if i['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=extendedinfo,id=%s)' % i['tmdb_id'])) cm.append( ("[B]Exit Movie List[/B]", "XBMC.Container.Refresh(%s)" % build_url(exit_list_params))) listitem.addContextMenuItems(cm) listitem.setCast(i['cast']) listitem.setArt({ 'poster': i['poster'], 'fanart': i['fanart'], 'banner': i['banner'], 'clearlogo': i['clearlogo'], 'landscape': i['landscape'] }) listitem.setInfo('Video', remove_unwanted_info_keys(i)) if not not_widget: listitem.setProperty("fen_widget", 'true') listitem.setProperty("fen_playcount", str(i['playcount'])) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=False) except: pass
def fetch_list(self): try: params = dict(parse_qsl(sys.argv[2].replace('?', ''))) worker = True mode = params.get('mode') page_no = int(params.get('new_page', 1)) letter = params.get('new_letter', 'None') search_name = '' content_type = 'movies' var_module = 'tmdb' if 'tmdb' in self.action else 'trakt' if 'trakt' in self.action else 'imdb' if 'imdb' in self.action else '' try: exec('from resources.lib.modules.%s import %s as function' % (var_module, self.action)) except: pass if self.action in ('tmdb_movies_popular', 'tmdb_movies_blockbusters', 'tmdb_movies_in_theaters', 'tmdb_movies_top_rated', 'tmdb_movies_upcoming', 'tmdb_movies_latest_releases', 'tmdb_movies_premieres', 'trakt_movies_trending', 'trakt_movies_anticipated', 'trakt_movies_top10_boxoffice'): 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_movie_id(item)) if self.action not in ('trakt_movies_top10_boxoffice'): 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 in ('trakt_collection', 'trakt_watchlist'): data, passed_list, total_pages, limit = function( 'movies', page_no, letter, params.get('passed_list', '')) self.list = [i['media_id'] for i in data] if total_pages > 1: self.total_pages = total_pages if len(data) == limit: self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'new_letter': letter, 'passed_list': passed_list, 'foldername': self.action } elif self.action == 'imdb_movies_oscar_winners': self.id_type = 'imdb_id' self.list = function(page_no) self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'foldername': self.action } elif self.action == ('trakt_movies_mosts'): for item in (function(params['period'], params['duration'], page_no)): self.list.append(get_trakt_movie_id(item)) 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_movies_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_movies_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_movies_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(data['page'] + 1), 'year': params.get('year'), 'foldername': params.get('year') } elif self.action == 'tmdb_movies_certifications': data = function(params['certification'], 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), 'certification': params.get('certification'), 'foldername': params.get('certification') } elif self.action in ('favourites_movies', 'subscriptions_movies', 'kodi_library_movies', 'watched_movies'): (var_module, import_function) = ( '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: exec( 'from resources.lib.modules.%s import %s as function' % (var_module, import_function)) except: return if self.action == 'kodi_library_movies': self.id_type = 'imdb_id' data, passed_list, total_pages, limit = function( 'movie', page_no, letter, params.get('passed_list', '')) self.list = [i['media_id'] for i in data] if total_pages > 1: self.total_pages = total_pages if len(data) == limit: self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'new_letter': letter, 'passed_list': passed_list, 'foldername': self.action } elif self.action == 'in_progress_movies': from resources.lib.modules.in_progress import in_progress_movie as function self.list = function('movie') xbmcplugin.addSortMethod( __handle__, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) elif self.action == 'tmdb_movies_similar': data = function(params['tmdb_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), 'foldername': self.action, 'tmdb_id': params.get('tmdb_id') } elif self.action == 'trakt_movies_related': for item in function(params['imdb_id'], page_no): self.list.append(get_trakt_movie_id(item)) self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str( int((params.get('new_page') if 'new_page' in params else 1)) + 1), 'foldername': self.action, 'imdb_id': params.get('imdb_id') } elif self.action == 'trakt_recommendations': for item in function('movies'): self.list.append(item['ids']['tmdb']) elif self.action == 'tmdb_popular_people': import os worker = False icon_directory = settings.get_theme() data = function(page_no) 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, 'app_logo.png') url_params = { 'mode': 'build_movie_list', 'action': 'tmdb_movies_actor_roles', 'actor_id': item['id'] } url = build_url(url_params) cm.append(( "[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedactorinfo,id=%s)' % item['id'])) listitem = xbmcgui.ListItem(item['name']) listitem.setArt({ 'poster': actor_poster, 'fanart': __addon__.getAddonInfo('fanart') }) 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_movies_actor_roles': data, passed_list, total_pages, limit = function( params['actor_id'], page_no, letter, params.get('passed_list', '')) self.list = [i['media_id'] for i in data] if total_pages > 1: self.total_pages = total_pages if len(data) == limit: self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'new_letter': letter, 'passed_list': passed_list, 'actor_id': params['actor_id'], 'foldername': self.action } elif self.action in ('tmdb_movies_search', 'tmdb_movies_people_search'): import urllib if params.get('query') == 'NA': search_title = dialog.input("Search Fen", type=xbmcgui.INPUT_ALPHANUM) search_name = urllib.unquote(search_title) else: search_name = urllib.unquote(params.get('query')) if not search_name: return if self.action == 'tmdb_movies_people_search': data, passed_list, total_pages, limit = function( search_name, page_no, letter, params.get('passed_list', '')) if total_pages > 1: self.total_pages = total_pages if len(data) == limit: self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str(page_no + 1), 'new_letter': letter, 'passed_list': passed_list, 'query': search_name, 'foldername': search_name } else: data = function(search_name, page_no) if self.action == 'tmdb_movies_search': if data['page'] < data['total_pages']: self.new_page = { 'mode': mode, 'action': self.action, 'new_page': str(int(data['page']) + 1), 'query': search_name, 'foldername': search_name } self.list = [i['id'] for i in data['results'] ] if self.action == 'tmdb_movies_search' else [ i['media_id'] for i in data ] if self.total_pages: url_params = { 'mode': 'build_navigate_to_page', 'db_type': 'Movies', 'current_page': page_no, 'total_pages': self.total_pages, 'transfer_mode': mode, 'transfer_action': self.action, 'passed_list': passed_list, 'foldername': self.action, 'query': 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 worker: self.worker() if self.new_page: self.add_dir(self.new_page) except: pass xbmcplugin.setContent(__handle__, content_type) xbmcplugin.endOfDirectory(__handle__) setView('view.movies')
def build_episode(item): from resources.lib.modules.utils import make_day def check_for_unaired(): 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 display_info: display_first_aired = make_day(first_aired) airdate = '[[COLOR=%s]%s[/COLOR]] ' % ( display_info['airdate_colour'], display_first_aired) if display_info['include_airdate'] else '' highlight_color = display_info['unwatched_colour'] if item.get( 'unwatched', False) else display_info['unaired_colour'] if unaired else '' italics_open, italics_close = ('[I]', '[/I]') if highlight_color else ('', '') episode_info = '%s[COLOR=%s]%dx%.2d - %s[/COLOR]%s' % ( italics_open, highlight_color, info['season_number'], info['episode_number'], info['name'], italics_close) display = '%s%s: %s' % (airdate, meta['title'], episode_info) tvshow_display = display if display_info[ 'force_display'] else meta['title'] else: display = '%s: %dx%.2d - %s' % (meta['title'].upper( ), info['season_number'], info['episode_number'], info['name']) tvshow_display = meta['title'] return display, tvshow_display try: display_info = item.get('ne_display', None) thumb_path = 'http://image.tmdb.org/t/p/original%s' cm = [] watched_indicators = settings.watched_indicators() action = item.get('action', '') meta = item['meta'] info = [ i for i in tikimeta.season_episodes_meta( meta['tmdb_id'], item['season'])['episodes'] if i['episode_number'] == item['episode'] ][0] first_aired = info['air_date'] unaired = check_for_unaired() if unaired and not item.get('include_unaired', False): return guest_stars = get_guest_stars(info['guest_stars']) writer = ', '.join( [i['name'] for i in info['crew'] if i['job'] == 'Writer']) director = ', '.join( [i['name'] for i in info['crew'] if i['job'] == 'Director']) thumb = thumb_path % info['still_path'] if info.get( 'still_path', None) != None else meta['fanart'] playcount, overlay = get_watched_status('episode', meta['tmdb_id'], info['season_number'], info['episode_number']) query = meta['title'] + ' S%.2dE%.2d' % (info['season_number'], info['episode_number']) display, tvshow_display = build_display() listitem = xbmcgui.ListItem(display) listitem.setProperty( "resumetime", get_resumetime('episode', meta['tmdb_id'], info['season_number'], info['episode_number'])) rootname = '{0} ({1})'.format(meta['title'], meta['year']) meta.update({ 'vid_type': 'episode', 'rootname': rootname, 'season': info['season_number'], 'episode': info['episode_number'], 'premiered': first_aired, 'ep_name': info['name'], 'plot': info['overview'] }) meta_json = json.dumps(meta) url_params = { 'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': meta['tmdb_id'], 'query': query, 'tvshowtitle': meta['rootname'], 'season': info['season_number'], 'episode': info['episode_number'], '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} watched_title = 'Trakt' if watched_indicators in (1, 2) else "Fen" watched_params = { "mode": "mark_episode_as_watched_unwatched", "action": "mark_as_watched", "media_id": meta['tmdb_id'], "imdb_id": meta["imdb_id"], "tvdb_id": meta["tvdb_id"], "season": info['season_number'], "episode": info['episode_number'], "title": meta['title'], "year": meta['year'] } if action == 'next_episode': nextep_manage_params = {"mode": "next_episode_context_choice"} cm.append(("[B]Mark Watched %s[/B]" % watched_title, 'XBMC.RunPlugin(%s)' % build_url(watched_params))) if listitem.getProperty("resumetime") != '0.000000': cm.append(("[B]Mark Unwatched %s[/B]" % watched_title, 'XBMC.RunPlugin(%s)' % build_url({ "mode": "mark_episode_as_watched_unwatched", "action": "mark_as_unwatched", "media_id": meta['tmdb_id'], "imdb_id": meta["imdb_id"], "season": info['season_number'], "episode": info['episode_number'], "title": meta['title'], "year": meta['year'] }))) if action == 'next_episode': cm.append(("[B]Next Episode Manager[/B]", 'XBMC.RunPlugin(%s)' % build_url(nextep_manage_params))) cm.append(("[B]Refresh List[/B]", 'XBMC.Container.Refresh()')) cm.append( ("[B]Browse...[/B]", 'XBMC.Container.Update(%s)' % browse_url)) 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)' % meta['tmdb_id'])) listitem.setArt({ 'poster': meta['poster'], 'fanart': meta['fanart'], 'thumb': thumb, 'banner': meta['banner'], 'clearlogo': meta['clearlogo'], 'landscape': meta['landscape'] }) listitem.addContextMenuItems(cm) listitem.setCast(meta['cast'] + guest_stars) listitem.setInfo( 'video', { 'mediatype': 'episode', 'trailer': str(meta.get('trailer')), 'title': info['name'], 'tvshowtitle': tvshow_display, 'size': '0', 'plot': info['overview'], 'premiered': first_aired, 'writer': writer, 'director': director, 'season': info['season_number'], 'genre': meta.get('genre'), 'episode': info['episode_number'], 'rating': info['vote_average'], 'votes': info['vote_count'], 'duration': meta.get('episode_run_time'), 'playcount': playcount, 'overlay': overlay }) if not not_widget: listitem.setProperty("fen_widget", 'true') listitem.setProperty("fen_playcount", str(playcount)) return { 'listitem': (url, listitem, False), 'curr_last_played_parsed': item.get('curr_last_played_parsed', ''), 'order': item.get('order', ''), 'name': query, 'first_aired': first_aired } except: pass
def build_episode_list(): UNAIRED_EPISODE_COLOUR = settings.unaired_episode_colour() if not UNAIRED_EPISODE_COLOUR or UNAIRED_EPISODE_COLOUR == '': UNAIRED_EPISODE_COLOUR = 'red' params = dict(parse_qsl(sys.argv[2].replace('?', ''))) try: meta = json.loads(window.getProperty('fen_media_meta')) except: meta = tikimeta.tvshow_meta('tmdb_id', params.get('tmdb_id')) thumb_path = 'http://image.tmdb.org/t/p/original%s' cast = [] infoLabels = tikimeta.season_episodes_meta(meta['tmdb_id'], params.get('season')) watched_indicators = settings.watched_indicators() try: for item in infoLabels['credits']['cast']: cast_thumb = "http://image.tmdb.org/t/p/original%s" % item[ "profile_path"] if 'profile_path' in item else '' cast.append({ "name": item["name"], "role": item["character"], "thumbnail": cast_thumb }) except: pass for i in infoLabels['episodes']: try: cm = [] guest_stars = get_guest_stars(i['guest_stars']) first_aired = i['air_date'] if 'air_date' in i else None writer = ', '.join( [c['name'] for c in i['crew'] if c['job'] == 'Writer']) director = ', '.join( [c['name'] for c in i['crew'] if c['job'] == 'Director']) thumb = thumb_path % i['still_path'] if i.get( 'still_path', None) != None else meta['fanart'] playcount, overlay = get_watched_status('episode', meta['tmdb_id'], i['season_number'], i['episode_number']) query = meta['title'] + ' S%.2dE%.2d' % (int( i['season_number']), int(i['episode_number'])) display_name = '%s - %dx%.2d' % (meta['title'], int(i['season_number']), int(i['episode_number'])) meta.update({ 'vid_type': 'episode', 'rootname': display_name, 'season': i['season_number'], 'episode': i['episode_number'], 'premiered': first_aired, 'ep_name': i['name'], 'plot': i['overview'] }) meta_json = json.dumps(meta) url_params = { 'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': meta['tmdb_id'], 'query': query, 'tvshowtitle': meta['rootname'], 'season': i['season_number'], 'episode': i['episode_number'], 'meta': meta_json } url = build_url(url_params) try: d = first_aired.split('-') episode_date = date(int(d[0]), int(d[1]), int(d[2])) except: episode_date = date(2000, 01, 01) if i['season_number'] == 0 else None current_adjusted_date = settings.adjusted_datetime() display = '%dx%.2d - %s' % (i['season_number'], i['episode_number'], i['name']) cad = True if not episode_date or current_adjusted_date < episode_date: cad = False display = '[I][COLOR={}]{}[/COLOR][/I]'.format( UNAIRED_EPISODE_COLOUR, display) listitem = xbmcgui.ListItem(display) listitem.setProperty( "resumetime", get_resumetime('episode', meta['tmdb_id'], i['season_number'], i['episode_number'])) (state, action) = ('Watched', 'mark_as_watched') if playcount == 0 else ( 'Unwatched', 'mark_as_unwatched') (state2, action2) = ('Watched', 'mark_as_watched') if state == 'Unwatched' else ( 'Unwatched', 'mark_as_unwatched') playback_menu_params = { 'mode': 'playback_menu', 'suggestion': query } watched_title = 'Trakt' if watched_indicators in (1, 2) else "Fen" watched_unwatched_params = { "mode": "mark_episode_as_watched_unwatched", "action": action, "media_id": meta['tmdb_id'], "imdb_id": meta["imdb_id"], "tvdb_id": meta["tvdb_id"], "season": i['season_number'], "episode": i['episode_number'], "title": meta['title'], "year": meta['year'] } if cad: cm.append(("[B]Mark %s %s[/B]" % (state, watched_title), 'XBMC.RunPlugin(%s)' % build_url(watched_unwatched_params))) if cad and listitem.getProperty("resumetime") != '0.000000': cm.append(("[B]Mark %s %s[/B]" % (state2, watched_title), 'XBMC.RunPlugin(%s)' % build_url({ "mode": "mark_episode_as_watched_unwatched", "action": action2, "media_id": meta['tmdb_id'], "imdb_id": meta["imdb_id"], "season": i['season_number'], "episode": i['episode_number'], "title": meta['title'], "year": meta['year'] }))) 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)' % meta['tmdb_id'])) listitem.addContextMenuItems(cm) listitem.setArt({ 'poster': meta['poster'], 'fanart': meta['fanart'], 'thumb': thumb, 'banner': meta['banner'], 'clearlogo': meta['clearlogo'], 'landscape': meta['landscape'] }) listitem.setCast(cast + guest_stars) listitem.setInfo( 'video', { 'mediatype': 'episode', 'trailer': str(meta.get('trailer')), 'title': i['name'], 'tvshowtitle': meta.get('title'), 'size': '0', 'plot': i['overview'], 'premiered': first_aired, 'genre': meta.get('genre'), 'season': i['season_number'], 'episode': i['episode_number'], 'duration': meta.get('episode_run_time'), 'rating': i['vote_average'], 'votes': i['vote_count'], 'writer': writer, 'director': director, 'playcount': playcount, 'overlay': overlay }) if not not_widget: listitem.setProperty("fen_widget", 'true') listitem.setProperty("fen_playcount", str(playcount)) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=False) except:
def build_season_list(): params = dict(parse_qsl(sys.argv[2].replace('?', ''))) meta = json.loads( params.get('meta')) if 'meta' in params else tikimeta.tvshow_meta( 'tmdb_id', params.get('tmdb_id')) show_specials = settings.show_specials() use_season_title = settings.use_season_title() season_data = [i for i in meta['season_data'] if i['season_number'] > 0 ] if not show_specials else meta['season_data'] watched_indicators = settings.watched_indicators() for item in season_data: try: cm = [] plot = item['overview'] if item['overview'] != '' else meta['plot'] title = item['name'] if use_season_title else 'Season %s' % str( item['season_number']) season_poster = "http://image.tmdb.org/t/p/original%s" % item[ 'poster_path'] if item['poster_path'] is not None else meta[ 'poster'] aired_episodes = aired_episode_number_season( meta, item['season_number']) playcount, overlay, watched, unwatched = get_watched_status_season( meta['tmdb_id'], item['season_number'], aired_episodes) watched_title = 'Trakt' if watched_indicators in (1, 2) else "Fen" watched_params = { "mode": "mark_season_as_watched_unwatched", "action": 'mark_as_watched', "title": meta['title'], "year": meta['year'], "media_id": meta['tmdb_id'], "imdb_id": meta["imdb_id"], "tvdb_id": meta["tvdb_id"], "season": item['season_number'] } unwatched_params = { "mode": "mark_season_as_watched_unwatched", "action": 'mark_as_unwatched', "title": meta['title'], "year": meta['year'], "media_id": meta['tmdb_id'], "imdb_id": meta["imdb_id"], "tvdb_id": meta["tvdb_id"], "season": item['season_number'] } 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)' % meta['tmdb_id'])) url_params = { 'mode': 'build_episode_list', 'tmdb_id': meta['tmdb_id'], 'season': str(item['season_number']), 'season_id': item['id'] } url = build_url(url_params) listitem = xbmcgui.ListItem(title) listitem.setProperty('watchedepisodes', str(watched)) listitem.setProperty('unwatchedepisodes', str(unwatched)) listitem.setProperty('totalepisodes', str(item['episode_count'])) listitem.addContextMenuItems(cm) listitem.setArt({ 'poster': season_poster, 'fanart': meta['fanart'], 'banner': meta['banner'], 'clearlogo': meta['clearlogo'], 'landscape': meta['landscape'] }) listitem.setCast(meta['cast']) listitem.setInfo( 'video', { 'mediatype': 'tvshow', 'trailer': str(meta['trailer']), 'title': meta.get('title'), 'size': '0', 'duration': meta.get('episode_run_time'), 'plot': plot, 'rating': meta.get('rating'), 'premiered': meta.get('premiered'), 'studio': meta.get('studio'), 'year': meta.get('year'), 'genre': meta.get('genre'), 'code': meta.get('imdb_id'), 'tvshowtitle': meta.get('title'), 'imdbnumber': meta.get('imdb_id'), 'votes': meta.get('votes'), 'episode': str(item['episode_count']), 'playcount': playcount, 'overlay': overlay }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass xbmcplugin.setContent(__handle__, 'seasons') xbmcplugin.endOfDirectory(__handle__) setView('view.seasons') window.setProperty('fen_media_meta', json.dumps(meta))
def build_tvshow_content(self): watched_indicators = settings.watched_indicators() all_trailers = settings.all_trailers() for i in sorted(self.items, key=lambda k: k['item_no']): try: cm = [] item_no = i['item_no'] if not 'rootname' in i: i['rootname'] = '{0} ({1})'.format(i['title'], i['year']) meta = i['meta'] del i['meta'] meta_json = json.dumps(meta) url_params = { 'mode': 'build_season_list', 'meta': meta_json, 'tmdb_id': i['tmdb_id'] } url = build_url(url_params) from_search = 'true' if self.action in ( 'tmdb_tv_search', 'tmdb_tv_people_search') else 'false' hide_recommended_params = { 'mode': 'trakt.hide_recommendations', 'db_type': 'shows', 'imdb_id': i['imdb_id'] } playback_menu_params = {'mode': 'playback_menu'} watched_title = 'Trakt' if watched_indicators in (1, 2) else "Fen" watched_params = { "mode": "mark_tv_show_as_watched_unwatched", "action": 'mark_as_watched', "title": i['title'], "year": i['year'], "media_id": i['tmdb_id'], "imdb_id": i["imdb_id"], "tvdb_id": meta["tvdb_id"], "from_search": from_search } unwatched_params = { "mode": "mark_tv_show_as_watched_unwatched", "action": 'mark_as_unwatched', "title": i['title'], "year": i['year'], "media_id": i['tmdb_id'], "imdb_id": i["imdb_id"], "tvdb_id": meta["tvdb_id"], "from_search": from_search } add_remove_params = { "mode": "build_add_to_remove_from_list", "media_type": "tvshow", "meta": meta_json, "from_search": from_search, "orig_mode": self.action } sim_rel_params = { 'mode': 'similar_related_choice', 'db_type': 'tv', 'tmdb_id': i['tmdb_id'], 'imdb_id': i['imdb_id'], 'from_search': from_search } exit_list_params = { "mode": "navigator.main", "action": "TVShowList" } (trailer_params, trailer_title) = ( { 'mode': 'play_trailer', 'url': i['trailer'], 'all_trailers': json.dumps(i['all_trailers']) }, 'Choose Trailer') if (all_trailers and i.get( 'all_trailers', False)) else ({ 'mode': 'play_trailer', 'url': i['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]Add/Remove[/B]", "XBMC.RunPlugin(%s)" % build_url(add_remove_params))) cm.append(("[B]Similar/Related[/B]", "XBMC.RunPlugin(%s)" % build_url(sim_rel_params))) if self.action == 'trakt_recommendations': cm.append(("[B]Hide from Recommendations[/B]", "XBMC.RunPlugin(%s)" % build_url(hide_recommended_params))) cm.append( ("[B]Options[/B]", 'XBMC.RunPlugin(%s)' % build_url(playback_menu_params))) if i['trailer']: cm.append( ("[B]%s[/B]" % trailer_title, "XBMC.RunPlugin(%s)" % build_url(trailer_params))) cm.append( ("[B]Extended Info[/B]", 'RunScript(script.extendedinfo,info=extendedtvinfo,id=%s)' % i['tmdb_id'])) cm.append( ("[B]Exit TV Show List[/B]", "XBMC.Container.Refresh(%s)" % build_url(exit_list_params))) listitem = xbmcgui.ListItem(i['title']) listitem.setProperty('watchedepisodes', i['total_watched']) listitem.setProperty('unwatchedepisodes', i['total_unwatched']) listitem.setProperty('totalepisodes', i['total_episodes']) listitem.setProperty('totalseasons', i['total_seasons']) listitem.addContextMenuItems(cm) listitem.setCast(i['cast']) listitem.setArt({ 'poster': i['poster'], 'fanart': i['fanart'], 'banner': i['banner'], 'clearlogo': i['clearlogo'], 'landscape': i['landscape'] }) listitem.setInfo('video', remove_unwanted_info_keys(i)) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass
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' list_type = 'video' if (params.get('list_type') == 'file_get_video' or params.get('db_type') == 'video') else 'music' 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 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_add_favs = { 'mode': 'add_to_favourites_audio', 'name': name, '_id': item_id, 'url_dl': url_dl, 'size': size } 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 params.get('db_type') == 'audio': cm.append(("[B]Add to Fen Favourites[/B]", 'XBMC.RunPlugin(%s)' % build_url(con_add_favs))) 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({'thumb': default_furk_icon, 'fanart': fanart}) listitem.setInfo(type=list_type, infoLabels={ 'title': display, 'size': int(size) }) xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True) except: pass