def list_favorites(): favorites = plugin.get_storage('favorites') channels = get_data()['channel_index'] items = [{ 'label': '[COLOR FFFF0000]已失效频道 [%s][/COLOR]' % ch_id if not ch else ( '[COLOR FF00FF00]%s[/COLOR]' % ch['name'] if ch.get('diy') else ch['name'] ), 'path': plugin.url_for('remove_favorite', channel_id=ch_id) if not ch else ( tvlinks[0]['link'] if len(tvlinks) == 1 else plugin.url_for('try_sources', channel_id=ch_id) ), 'is_playable': True, 'properties': {'mimetype': 'video/x-msvideo', 'isPlayable': ''}, 'context_menu': [( u'[COLOR FFFFFF00]取消收藏[/COLOR]', actions.background( plugin.url_for('remove_favorite', channel_id=ch_id)) ), ( u'[COLOR FFFFFF00]选择信号源播放[/COLOR]', actions.background( plugin.url_for('choose_source', channel_id=ch_id)) )], 'replace_context_menu': True, } for ch_id, ch in sorted( ((ch_id, channels.get(ch_id)) for ch_id in favorites.iterkeys()), key=lambda x:x[1] and x[1]['name'] or x[0] ) for tvlinks in (ch and ch['tvlinks'],) ] return items
def search_index(section): storage = container.search_storage() if 'search_term' in storage: del storage['search_term'] context_menu = [ (lang(40309), actions.background(plugin.url_for('clear_search_history'))) ] items = [{ 'label': lang(34009), 'path': plugin.url_for('new_search', section=section), 'context_menu': context_menu, 'replace_context_menu': True, }, { 'label': lang(34010), 'path': plugin.url_for('advanced_search', section=section), 'context_menu': context_menu, 'replace_context_menu': True, }] if 'search_recent' in storage: items.extend([{ 'label': s, 'path': plugin.url_for('do_search', section=section, name=s), 'context_menu': context_menu + [ (lang(40311), actions.background(plugin.url_for('delete_search', name=s))) ], 'replace_context_menu': True, } for s in reversed(storage['search_recent'])]) plugin.finish(with_fanart(items))
def library_menu(s): """ :type s: Series """ items = library_items() if s.id in items: return [(lang(40310), actions.background(plugin.url_for('remove_from_library', series_id=s.id)))] else: return [(lang(40309), actions.background(plugin.url_for('add_to_library', series_id=s.id)))]
def toggle_auto_refresh_context_menu(section, media_id): not_refreshing_items = container.not_refreshing_items() # plugin.log.info("Media ID: %d, Expire: %r" % (media_id, container.details_cache().get_item_expire(media_id))) if media_id in not_refreshing_items: return [(lang(40323), actions.background(plugin.url_for('turn_on_auto_refresh', section=section.filter_val, media_id=media_id)))] else: return [(lang(40324), actions.background(plugin.url_for('turn_off_auto_refresh', section=section.filter_val, media_id=media_id)))]
def bookmark_context_menu(media_id, section, title): bookmarks = container.bookmarks() if media_id in bookmarks: return [(lang(40307), actions.background(plugin.url_for('delete_bookmark', media_id=media_id, section=section.filter_val)))] else: return [(lang(40306), actions.background(plugin.url_for('add_bookmark', media_id=media_id, section=section.filter_val, title=ensure_str(title))))]
def create_item(data): broadcast = data.get('broadcast') video = data.get('video') airdate = parse_date(broadcast.get('broadcastBeginRounded')[:-6] ) if broadcast.get('broadcastBeginRounded') else None programId = str(video.get('programId')) label = '[B]{title}[/B]'.format(title=video.get('title').encode('utf8')) # suffixes if video.get('subtitle'): label += ' - {subtitle}'.format( subtitle=video.get('subtitle').encode('utf8')) item = { 'label': label, 'path': plugin.url_for('play', vid=programId), 'thumbnail': video.get('imageUrl'), 'is_playable': True, 'info_type': 'video', 'info': { 'title': video.get('title'), 'duration': int(video.get('durationSeconds')), 'genre': video.get('genrePresse'), 'plot': video.get('shortDescription'), 'plotoutline': video.get('teaserText'), # year is not correctly used by kodi :( # the aired year will be used by kodi for production year :( 'year': int(video.get('productionYear')), 'country': [country['label'] for country in video.get('productionCountries')], 'director': video.get('director'), 'aired': str(airdate) }, 'properties': { 'fanart_image': video.get('imageUrl'), }, 'context_menu': [(plugin.get_string(30021), actions.background(plugin.url_for('download', vid=programId))), (plugin.get_string(30020), actions.background(plugin.url_for('enqueue', vid=programId)))], } return item
def library_context_menu(section, media_id, folder_id): library_manager = container.library_manager() if library_manager.has_folder(folder_id): return [(lang(40321), actions.background(plugin.url_for('remove_from_library', folder_id=folder_id)))] else: return [(lang(40320), actions.background(plugin.url_for('add_to_library', section=section.filter_val, media_id=media_id, folder_id=folder_id)))]
def mark_watched_context_menu(section, media_id, date_added=None, total_size=None): watched_items = container.watched_items() if media_id in watched_items: return [(lang(40302), actions.background(plugin.url_for('mark_unwatched', media_id=media_id)))] else: return [(lang(40301), actions.background(plugin.url_for('mark_watched', section=section.filter_val, media_id=media_id, date_added=date_added, total_size=total_size)))]
def create_item(data, options=None): options = options or {} airdate = parse_date(data.get('VDA')[:-6]) if data.get('VDA') else None label = '' # prefixes if options.get('show_airtime'): label += '[COLOR fffa481c]{d.hour:02}:{d.minute:02}[/COLOR] '.format(d=airdate) if options.get('show_deletetime'): if data.get('VRU'): # deletion found deletiondate = parse_date(data.get('VRU')[:-6]) label += '[COLOR ffff0000]{d:%a} {d:%d} {d.hour:02}:{d.minute:02}[/COLOR] '.format(d=deletiondate) if options.get('show_views'): label += '[COLOR ff00aae3]{v:>6}[/COLOR] '.format(v=parse_views(data.get('VVI'))) label += '[B]{title}[/B]'.format(title=data.get('VTI').encode('utf8')) # suffixes if data.get('VSU'): label += ' - {subtitle}'.format(subtitle=data.get('VSU').encode('utf8')) item = { 'label': label, 'path': plugin.url_for('play', vid=str(data.get('VPI'))), 'thumbnail': data.get('VTU').get('IUR'), 'is_playable': True, 'info_type': 'video', 'info': { 'label': data.get('VTI'), 'title': data.get('VTI'), 'duration': str(data.get('VDU')*60), 'genre': data.get('VCG'), 'plot': data.get('VDE'), 'plotoutline': data.get('V7T'), 'year': data.get('productionYear'), 'director': data.get('PPD'), 'aired': str(airdate) }, 'properties': { 'fanart_image': data.get('VTU').get('IUR'), }, 'context_menu': [ (plugin.get_string(30021), actions.background(plugin.url_for('download', vid=str(data.get('VPI'))))), (plugin.get_string(30020), actions.background(plugin.url_for('enqueue', vid=str(data.get('VPI'))))) ], } return item
def topsongs(artistid): url = ROOT_URL+'/app/android/artist-topsongs?id='+artistid req = urllib2.Request(url, headers=HTTP_HEADERS) content = urllib2.urlopen(req, timeout=5).read() data = json.loads(content) result = [] for item in data['songs']: title = unescape_name(item['name']) lyric = None if item['lyric'] and item['lyric'].startswith('http'): req = urllib2.Request(url, headers=HTTP_HEADERS) lyric = urllib2.urlopen(req, timeout=5).read() result.append({ 'label': title, 'path': item['location'], 'info': {'type':'music', 'infoLabels':[('title',title),('artist',item['artist_name']),('album',item['title']),('lyrics',lyric)]}, 'thumbnail': item['album_logo'], 'is_playable': True, 'context_menu': [ (_L(30101), actions.update_view(plugin.url_for('album', albumid=item['album_id']))), (_L(30102), actions.background(plugin.url_for('download_file', url=item['location']))), ] }) return result
def users_list(): items = [{ 'label': '[COLOR FFFFFF00]增加帐号[/COLOR]', 'path': plugin.url_for('add_user'), 'is_playable': True, 'properties': {'isPlayable': ''} }] config = plugin.get_storage('config') users = config.setdefault('users', {}) for userid in users.keys(): items.append({ 'label': userid, 'path': plugin.url_for('remove_user', userid=userid), 'is_playable': True, 'properties': {'isPlayable': ''}, 'context_menu': [( '[COLOR FFFFFF00]重新登录[/COLOR]', actions.background( plugin.url_for('relogin', userid=userid)) )], 'replace_context_menu': True }) return items
def browse_page(url): quality = qualcode[ plugin.get_setting("quality", unicode) ] localsrv = localcode[ plugin.get_setting("local", unicode) ] info = dabdate.parseTop( dabdate.root_url+url, quality=quality, localsrv=localsrv ) items = [] label_download = plugin.get_string(30204) for item in info['video']: items.append({ 'label':item['title'], 'path':plugin.url_for('play_video', url=item['url']), 'thumbnail':item['thumb'], 'context_menu': [ (label_download, actions.background(plugin.url_for('download_video', url=item['url']))) ] }) # navigation if 'prevpage' in info: items.append({'label':tPrevPage, 'path':plugin.url_for('browse_page', url=info['prevpage'])}) if 'nextpage' in info: items.append({'label':tNextPage, 'path':plugin.url_for('browse_page', url=info['nextpage'])}) # extra if url == '/' and quality[0] != 'm': items.append({'label':u"[COLOR FF0000FF]로보카 폴리[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=5")}) items.append({'label':u"[COLOR FF0000FF]그때를 아십니까[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=7")}) items.append({'label':u"[COLOR FF0000FF]특선 다큐멘터리[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=6")}) morepage = True if 'page=' in url else False return plugin.finish(items, update_listing=morepage)
def get_artist_item(self, artist, in_library=False): item = { 'label': artist.name, 'thumbnail': Image.get_url(Image.TYPE_ARTIST, artist.id, Image.SIZE_ARTIST_ORIGINAL), 'properties': { 'fanart_image': Image.get_url(Image.TYPE_ARTIST, artist.id, Image.SIZE_ARTIST_ORIGINAL), }, 'context_menu': [], } if in_library: item['path'] = self._plugin.url_for('artists_library_albums', artist_id=artist.id) item['context_menu'].append( (self._plugin.get_string(30217), actions.update_view( self._plugin.url_for('artists_library_remove', artist_id=artist.id)))) else: item['path'] = self._plugin.url_for('artists_detail', artist_id=artist.id) item['context_menu'].append( (self._plugin.get_string(30215), actions.background( self._plugin.url_for('artists_library_add', artist_id=artist.id)))) return item
def get_album_item(self, album, show_artist=True, in_library=False, library_artist_id=None): if show_artist: label = album.artist.name + ' - ' + album.name + ' (' + str(album.get_release_date().year) + ')' else: label = album.name + ' (' + str(album.get_release_date().year) + ')' item = { 'label': label, 'thumbnail': album.images[0].get_url(size=Image.SIZE_ORIGINAL), 'context_menu': [] } item['context_menu'].append(( self._plugin.get_string(30255).format(album.artist.name), actions.update_view(self._plugin.url_for('artists_detail', artist_id=album.artist.id)) )) if in_library: item['path'] = self._plugin.url_for('albums_library_tracks', album_id=album.id) if library_artist_id is None: action = actions.update_view(self._plugin.url_for('albums_library_remove', album_id=album.id)) else: action = actions.update_view(self._plugin.url_for('artists_library_albums_remove', artist_id=library_artist_id, album_id=album.id)) item['context_menu'].append((self._plugin.get_string(30217), action)) else: item['path'] = self._plugin.url_for('albums_detail', album_id=album.id) item['context_menu'].append(( self._plugin.get_string(30215), actions.background(self._plugin.url_for('albums_library_add', album_id=album.id)))) return item
def list_items(json_url, theme=None): plugin.set_content('tvshows') payload = {} if theme: payload['value'] = theme data = load_json(json_url.format(lang=language), payload) items = [] for video in data['videos']: item = { 'label': video['title'], 'path': plugin.url_for('play', vid=str(video['em'])), 'thumbnail': video['image_url'], 'is_playable': True, 'info_type': 'video', 'info': { 'label': video['title'], 'title': video['title'], 'duration': str(video['duration']), 'genre': video['video_channels'] if video['video_channels'] else '', 'plot': video['desc'] if video['desc'] else '', }, 'properties': { 'fanart_image': video['image_url'], }, 'context_menu': [ (plugin.get_string(30021), actions.background(plugin.url_for('download', vid=str(video['em'])))), ], } # item['context_menu'].append((plugin.get_string(30020), plugin.url_for('enqueue', item=item))) items.append(item) return plugin.finish(items)
def mark_series_watched_menu(series): """ :type series: Series """ return [(lang(40312), actions.background( plugin.url_for('mark_series_watched', series_id=series.id)))]
def get_context_menu(userid, path): if isinstance(path, unicode): path = path.encode("utf-8") return [ ("[COLOR FFFFFF00]删除[/COLOR]", actions.background(plugin.url_for("delete_path", userid=userid, path=path))) ]
def get_context_menu(userid, path): if isinstance(path, unicode): path = path.encode('utf-8') return [('[COLOR FFFFFF00]删除[/COLOR]', actions.background( plugin.url_for('delete_path', userid=userid, path=path)))]
def users_list(): items = [ { "label": "[COLOR FFFFFF00]增加帐号[/COLOR]", "path": plugin.url_for("add_user"), "is_playable": True, "properties": {"isPlayable": ""}, } ] config = plugin.get_storage("config") users = config.setdefault("users", {}) for userid in users.keys(): items.append( { "label": userid, "path": plugin.url_for("remove_user", userid=userid), "is_playable": True, "properties": {"isPlayable": ""}, "context_menu": [ ("[COLOR FFFFFF00]重新登录[/COLOR]", actions.background(plugin.url_for("relogin", userid=userid))) ], "replace_context_menu": True, } ) return items
def users_list(): items = [{ 'label': '[COLOR FFFFFF00]增加帐号[/COLOR]', 'path': plugin.url_for('add_user'), 'is_playable': True, 'properties': { 'isPlayable': '' } }] config = plugin.get_storage('config') users = config.setdefault('users', {}) for userid in users.keys(): items.append({ 'label': userid, 'path': plugin.url_for('remove_user', userid=userid), 'is_playable': True, 'properties': { 'isPlayable': '' }, 'context_menu': [('[COLOR FFFFFF00]重新登录[/COLOR]', actions.background(plugin.url_for('relogin', userid=userid)))], 'replace_context_menu': True }) return items
def _run(plugin, endpoint, **items): '''Returns a RunPlugin string for use in a context menu. :param endpoint: The endpoint to be used with playlists.url_for(). :param **items: Any keyword args to be passed to playlists.url_for(). ''' return actions.background(plugin.url_for(endpoint, **items))
def toggle_episode_watched_menu(episode): """ :type episode: Episode """ return [(lang(40151), actions.background(plugin.url_for('toggle_episode_watched', series_id=episode.series_id, episode=episode.episode_number, season=episode.season_number)))]
def download_menu(e): from xbmcswift2 import actions if plugin.get_setting('torrent-client', int): return [(lang(40308), actions.background(plugin.url_for('download', series=e.series_id, season=e.season_number, episode=e.episode_number)))] else: return []
def ClearPlaylists(item=""): if item == "": label = '[COLOR yellow]Xóa hết Playlists[/COLOR]' else: label = '[COLOR yellow]Xóa "%s"[/COLOR]' % item return (label, actions.background("%s/remove-playlists/%s" % (pluginrootpath, urllib.quote_plus(item))))
def browse_page(url): quality = qualcode[plugin.get_setting("quality", unicode)] localsrv = localcode[plugin.get_setting("local", unicode)] direct_play = plugin.get_setting("direct_play", bool) info = dabdate.parseTop(dabdate.root_url + url, quality=quality, localsrv=localsrv) items = [] label_download = plugin.get_string(30204) for item in info['video']: title = item['title'] vidurl = item['url'] if direct_play and vidmap: turl = dabdate.getDirectUrl(vidmap, item['title'], quality, localsrv) if turl: vidurl = turl title = u"[I]%s[/I]" % item['title'] if item['free']: title = u"[B]%s[/B]" % item['title'] items.append({ 'label': title, 'path': plugin.url_for('play_video', url=vidurl), 'thumbnail': item['thumb'], 'context_menu': [(label_download, actions.background(plugin.url_for('download_video', url=vidurl)))] }) # navigation if 'prevpage' in info: items.append({ 'label': tPrevPage, 'path': plugin.url_for('browse_page', url=info['prevpage']) }) if 'nextpage' in info: items.append({ 'label': tNextPage, 'path': plugin.url_for('browse_page', url=info['nextpage']) }) # extra if url == '/': items.append({ 'label': u"[COLOR FF0000FF]유아프로그램[/COLOR]", 'path': plugin.url_for('browse_page', url="?lang=5") }) #items.append({'label':u"[COLOR FF0000FF]그때를 아십니까[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=7")}) #items.append({'label':u"[COLOR FF0000FF]특선 다큐멘터리[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=6")}) morepage = True if 'page=' in url else False return plugin.finish(items, update_listing=morepage)
def get_context_menu(userid, path): if isinstance(path, unicode): path = path.encode('utf-8') return [( '[COLOR FFFFFF00]删除[/COLOR]', actions.background( plugin.url_for('delete_path', userid=userid, path=path)) )]
def ClearPlaylists(item=""): if item == "": label = '[COLOR yellow]Xóa hết Playlists[/COLOR]' else: label = '[COLOR yellow]Xóa "%s"[/COLOR]' % item return (label, actions.background( "%s/remove-playlists/%s" % (pluginrootpath, urllib.quote_plus(item)) ))
def iIi(item=""): if item == "": II = '[COLOR yellow]Xóa hết lịch sử tìm kiếm[/COLOR]' else: II = '[COLOR yellow]Xóa "%s"[/COLOR]' % item if 14 - 14: Oo.iI / I1Ii return (II, actions.background("%s/remove-search/%s" % (iI11I1II1I1I, item))) if 38 - 38: Iii1IIIiiI % ii1I.i1iIIIiI1I - i1iII1I1i1i1 + I1Ii
def make_favorite_ctx(self, title, station_id): """ Returns action url to Add to Favorites :param title: :param station_id: :return: """ label = self.plugin.get_string(30120) new_url = self.plugin.url_for('add_to_favorites', title=title, station_id=station_id) return label, actions.background(new_url)
def MakeList(pcs_files): item_list = [] ContextMenu = [ ('搜索', actions.background(plugin.url_for('search'))), ('刷新', actions.background(plugin.url_for('refresh'))), ('登出', actions.background(plugin.url_for('clear_cache'))), ] for result in pcs_files: if result['isdir'] == 1: item = { 'label': result['server_filename'], 'path': plugin.url_for('directory', path=result['path'].encode('utf-8')), 'is_playable': False, 'context_menu': ContextMenu, } item_list.append(item) elif result['category'] == 1: if 'thumbs' in result and 'url2' in result['thumbs']: ThumbPath = result['thumbs']['url2'] item = { 'label': result['server_filename'], 'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'icon': ThumbPath, 'context_menu': ContextMenu, } else: item = { 'label': result['server_filename'], 'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'context_menu': ContextMenu, } item_list.append(item) elif result['category'] == 2: item = { 'label': result['server_filename'], 'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')), 'is_playable': False, 'context_menu': ContextMenu, } item_list.append(item) return item_list
def make_channels_menu(channels): return [{ 'label': '[COLOR FF00FF00]%s[/COLOR]' % ch['name'] if ch.get('diy') else ch['name'], 'path': ch['tvlinks'][0]['link'] if len(ch['tvlinks']) == 1 else plugin.url_for('try_sources', channel_id=ch['id']), 'is_playable': True, 'properties': {'mimetype': 'video/x-msvideo', 'isPlayable': ''}, 'context_menu': [( u'[COLOR FFFFFF00]选择信号源播放[/COLOR]', actions.background( plugin.url_for('choose_source', channel_id=ch['id'])) ), ( u'[COLOR FFFFFF00]添加到收藏夹[/COLOR]', actions.background( plugin.url_for('add_favorite', channel_id=ch['id'])) )], 'replace_context_menu': True, } for ch in channels]
def show_listing(): plugin.set_content('tvshows') # very ugly workaround ahead (plugin.request.args.XXX returns an array for unknown reason) url = listing_json.format( lang=language[0], category=plugin.request.args.get('category', ['ALL'])[0], cluster=plugin.request.args.get('cluster', ['ALL'])[0], highlight=plugin.request.args.get('highlight', ['-1'])[0], sort=plugin.request.args.get('sort', ['AIRDATE_DESC'])[0], limit=plugin.request.args.get('limit', ['0'])[0], offset=plugin.request.args.get('offset', ['0'])[0]) data = load_json(url) listing_key = 'program{lang}List'.format(lang=language) items = [] for video in data[listing_key]: vdo = video['VDO'] item = { 'label': vdo.get('VTI'), 'path': plugin.url_for('play', vid=str(vdo.get('VPI'))), 'thumbnail': vdo.get('VTU').get('IUR'), 'is_playable': True, 'info_type': 'video', 'info': { 'label': vdo.get('VTI'), 'title': vdo.get('VTI'), 'duration': str(vdo.get('VDU')), 'genre': vdo.get('VCG'), 'plot': vdo.get('VDE'), 'plotoutline': vdo.get('V7T'), 'year': vdo.get('productionYear'), 'director': vdo.get('PPD'), #'aired': datetime.datetime.strptime(vdo.get('VDA')[:-6], '%d/%m/%Y %H:%M:%S').strftime('%Y-%m-%d') if vdo.get('VDA') else None }, 'properties': { 'fanart_image': vdo.get('VTU').get('IUR'), }, 'context_menu': [ (plugin.get_string(30021), actions.background( plugin.url_for('download', vid=str(vdo.get('VPI'))))), ], } # item['context_menu'].append((plugin.get_string(30020), plugin.url_for('enqueue', item=item))) items.append(item) return plugin.finish(items)
def browse_page(url): quality = qualcode[plugin.get_setting("quality", unicode)] localsrv = localcode[plugin.get_setting("local", unicode)] info = dabdate.parseTop(dabdate.root_url + url, quality=quality, localsrv=localsrv) items = [] label_download = plugin.get_string(30204) for item in info['video']: items.append({ 'label': item['title'], 'path': plugin.url_for('play_video', url=item['url']), 'thumbnail': item['thumb'], 'context_menu': [(label_download, actions.background( plugin.url_for('download_video', url=item['url'])))] }) # navigation if 'prevpage' in info: items.append({ 'label': tPrevPage, 'path': plugin.url_for('browse_page', url=info['prevpage']) }) if 'nextpage' in info: items.append({ 'label': tNextPage, 'path': plugin.url_for('browse_page', url=info['nextpage']) }) # extra if url == '/' and quality[0] != 'm': items.append({ 'label': u"[COLOR FF0000FF]로보카 폴리[/COLOR]", 'path': plugin.url_for('browse_page', url="?lang=5") }) items.append({ 'label': u"[COLOR FF0000FF]그때를 아십니까[/COLOR]", 'path': plugin.url_for('browse_page', url="?lang=7") }) items.append({ 'label': u"[COLOR FF0000FF]특선 다큐멘터리[/COLOR]", 'path': plugin.url_for('browse_page', url="?lang=6") }) morepage = True if 'page=' in url else False return plugin.finish(items, update_listing=morepage)
def index(): items = [{ 'label': sub, 'path': plugin.url_for('show_sub', sub=sub), 'context_menu': [ (plugin.get_string(30020), actions.background(plugin.url_for('del_sub', sub=sub))) ] } for sub in storage['subreddits']] items.append({ 'label': plugin.get_string(30009), 'path': plugin.url_for('add_sub') }) return items
def get_artist_item(self, artist, in_library=False): item = { 'label': artist.name, 'context_menu': [] } if in_library: item['path'] = self._plugin.url_for('artists_library_albums', artist_id=artist.id) item['context_menu'].append(( self._plugin.get_string(30217), actions.update_view(self._plugin.url_for('artists_library_remove', artist_id=artist.id)))) else: item['path'] = self._plugin.url_for('artists_detail', artist_id=artist.id) item['context_menu'].append(( self._plugin.get_string(30215), actions.background(self._plugin.url_for('artists_library_add', artist_id=artist.id)))) return item
def list_users(): users = plugin.get_storage('users') return [{ 'label': userid, 'path': plugin.url_for('show_user_classes', userid=userid), 'context_menu': [( u'[COLOR FFFFFF00]删除帐号[/COLOR]', actions.background( plugin.url_for('remove_user', userid=userid)) )], 'replace_context_menu': True, } for userid in sorted(users.keys())] + [{ 'label': u'[COLOR FFFFFF00]添加帐号[/COLOR]', 'path': plugin.url_for('add_user'), 'is_playable': True, 'properties': {'isPlayable': ''}, }]
def show_listing(): plugin.set_content('tvshows') # very ugly workaround ahead (plugin.request.args.XXX returns an array for unknown reason) url = listing_json.format(lang=language[0], category=plugin.request.args.get('category', ['ALL'])[0], cluster=plugin.request.args.get('cluster', ['ALL'])[0], highlight=plugin.request.args.get('highlight', ['-1'])[0], sort=plugin.request.args.get('sort', ['AIRDATE_DESC'])[0], limit=plugin.request.args.get('limit', ['0'])[0], offset=plugin.request.args.get('offset', ['0'])[0]) data = load_json(url) listing_key = 'program{lang}List'.format(lang=language) items = [] for video in data[listing_key]: vdo = video['VDO'] item = { 'label': vdo.get('VTI'), 'path': plugin.url_for('play', vid=str(vdo.get('VPI'))), 'thumbnail': vdo.get('VTU').get('IUR'), 'is_playable': True, 'info_type': 'video', 'info': { 'label': vdo.get('VTI'), 'title': vdo.get('VTI'), 'duration': str(vdo.get('VDU')), 'genre': vdo.get('VCG'), 'plot': vdo.get('VDE'), 'plotoutline': vdo.get('V7T'), 'year': vdo.get('productionYear'), 'director': vdo.get('PPD'), #'aired': datetime.datetime.strptime(vdo.get('VDA')[:-6], '%d/%m/%Y %H:%M:%S').strftime('%Y-%m-%d') if vdo.get('VDA') else None }, 'properties': { 'fanart_image': vdo.get('VTU').get('IUR'), }, 'context_menu': [ (plugin.get_string(30021), actions.background(plugin.url_for('download', vid=str(vdo.get('VPI'))))), ], } # item['context_menu'].append((plugin.get_string(30020), plugin.url_for('enqueue', item=item))) items.append(item) return plugin.finish(items)
def collect(collectid): url = ROOT_URL + '/app/android/collect?id=%s' % collectid req = urllib2.Request(url, headers=HTTP_HEADERS) content = urllib2.urlopen(req, timeout=5).read() data = json.loads(content) result = [] for item in data['collect']['songs']: title = unescape_name(item['name']) lyric = None if item['lyric'] and item['lyric'].startswith('http'): req = urllib2.Request(url, headers=HTTP_HEADERS) lyric = urllib2.urlopen(req, timeout=5).read() result.append({ 'label': title, 'label2': item['artist_name'], 'path': item['location'], 'info': { 'type': 'music', 'infoLabels': [('title', title), ('album', item['title']), ('artist', item['artist_name']), ('lyrics', lyric)] }, 'thumbnail': item['album_logo'], 'is_playable': True, 'context_menu': [ (_L(30100), actions.update_view( plugin.url_for('artist_top', artistid=item['artist_id']))), (_L(30101), actions.update_view( plugin.url_for('album', albumid=item['album_id']))), (_L(30102), actions.background( plugin.url_for('download_file', url=item['location']))), ] }) #plugin.add_to_playlist(result, playlist='music') return plugin.finish(result, view_mode='thumbnail')
def get_album_item(self, album, show_artist=True, in_library=False, library_artist_id=None): label = album.name + ' (' + str(album.get_release_date().year) + ')' if show_artist: label += '[LIGHT] / ' + album.artist.name + '[/LIGHT]' item = { 'label': label, 'thumbnail': Image.get_url(Image.TYPE_ALBUM, album.id, Image.SIZE_ALBUM_ORIGINAL), 'properties': { 'fanart_image': Image.get_url(Image.TYPE_ARTIST, album.artist.id, Image.SIZE_ARTIST_ORIGINAL), }, 'context_menu': [] } if in_library: item['path'] = self._plugin.url_for('albums_library_tracks', album_id=album.id) if library_artist_id is None: action = actions.update_view( self._plugin.url_for('albums_library_remove', album_id=album.id)) else: action = actions.update_view( self._plugin.url_for('artists_library_albums_remove', artist_id=library_artist_id, album_id=album.id)) item['context_menu'].append( (self._plugin.get_string(30217), action)) else: item['path'] = self._plugin.url_for('albums_detail', album_id=album.id) item['context_menu'].append( (self._plugin.get_string(30215), actions.background( self._plugin.url_for('albums_library_add', album_id=album.id)))) return item
def get_item(self, post): """ Creates a single playable item """ label = self.get_label(post) icon = self.get_icon(post) url = self.get_url(post) path = self.plugin.url_for('play_video', url=url) download_url = self.plugin.url_for('download_video', url=url) item = { 'label': label, 'label2': label, 'icon': icon, 'thumbnail': icon, 'path': path, 'is_playable': True, 'context_menu': [ ('Download Video', actions.background(download_url)) ], 'replace_context_menu': True } return item
def browse_page(url): quality = qualcode[ plugin.get_setting("quality", unicode) ] localsrv = localcode[ plugin.get_setting("local", unicode) ] direct_play = plugin.get_setting("direct_play", bool) info = dabdate.parseTop( dabdate.root_url+url, quality=quality, localsrv=localsrv ) items = [] label_download = plugin.get_string(30204) for item in info['video']: title = item['title'] vidurl = item['url'] if direct_play and vidmap: turl = dabdate.getDirectUrl(vidmap, item['title'], quality, localsrv) if turl: vidurl = turl title = u"[I]%s[/I]"% item['title'] if item['free']: title = u"[B]%s[/B]"% item['title'] items.append({ 'label':title, 'path':plugin.url_for('play_video', url=vidurl), 'thumbnail':item['thumb'], 'context_menu': [ (label_download, actions.background(plugin.url_for('download_video', url=vidurl))) ] }) # navigation if 'prevpage' in info: items.append({'label':tPrevPage, 'path':plugin.url_for('browse_page', url=info['prevpage'])}) if 'nextpage' in info: items.append({'label':tNextPage, 'path':plugin.url_for('browse_page', url=info['nextpage'])}) # extra if url == '/': items.append({'label':u"[COLOR FF0000FF]유아프로그램[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=5")}) #items.append({'label':u"[COLOR FF0000FF]그때를 아십니까[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=7")}) #items.append({'label':u"[COLOR FF0000FF]특선 다큐멘터리[/COLOR]", 'path':plugin.url_for('browse_page', url="?lang=6")}) morepage = True if 'page=' in url else False return plugin.finish(items, update_listing=morepage)
def _disc_play_all_ctx(disc_id): label = 'Play all' url = plugin.url_for('disc_play_all', disc_id=disc_id) return (label, actions.background(url))
def makedefaultrecording(code): label = 'Set Default Recording' new_url = plugin.url_for('setdefaultrecording', code=code) return (label, actions.background(new_url))
def get_track_item(self, track, track_number=None, show_artist=True, in_library=False, in_favorites=False, in_playlists=False, playlist_id=None, library_album_id=None): label = track.name if show_artist: label += '[LIGHT] / ' + track.artist.name + '[/LIGHT]' item = { 'label': label, 'is_playable': True, 'info': { 'title': track.name, 'artist': track.artist.name, 'album': track.album.name, 'duration': track.duration }, 'thumbnail': Image.get_url(Image.TYPE_ALBUM, track.album.id, Image.SIZE_ALBUM_ORIGINAL), 'properties': { 'fanart_image': Image.get_url(Image.TYPE_ARTIST, track.artist.id, Image.SIZE_ARTIST_ORIGINAL), }, 'context_menu': [] } if track_number is not None: item['info']['tracknumber'] = track_number item['context_menu'].append( (self._plugin.get_string(30255).format(track.artist.name), actions.update_view( self._plugin.url_for('artists_detail', artist_id=track.artist.id)))) if in_library: if library_album_id is None: action = actions.update_view( self._plugin.url_for('tracks_library_remove', track_id=track.id)) else: action = actions.update_view( self._plugin.url_for('albums_library_tracks_remove', track_id=track.id, album_id=library_album_id)) item['context_menu'].append( (self._plugin.get_string(30217), action)) else: item['context_menu'].append( (self._plugin.get_string(30215), actions.background( self._plugin.url_for('tracks_library_add', track_id=track.id)))) if in_favorites: item['context_menu'].append( (self._plugin.get_string(30218), actions.update_view( self._plugin.url_for('favorites_remove', track_id=track.id)))) else: item['context_menu'].append( (self._plugin.get_string(30216), actions.background( self._plugin.url_for('favorites_add', track_id=track.id)))) if in_playlists: item['context_menu'].append( (self._plugin.get_string(30254), actions.update_view( self._plugin.url_for('playlists_library_remove_track', track_id=track.id, playlist_id=playlist_id)))) else: item['context_menu'].append( (self._plugin.get_string(30253), actions.background( self._plugin.url_for('playlists_library_select', track_id=track.id)))) item['path'] = self._plugin.url_for('play', track_id=track.id) return item
def _playlist_play_all_ctx(playlist_id): label = 'Play all' url = plugin.url_for('playlist_play_all', playlist_id=playlist_id) return (label, actions.background(url))
def make_remove_favorite_ctx(channel, show): label = 'Remove show from favorites' new_url = plugin.url_for('del_show_from_favs', channel=channel, show=show) return (label, actions.background(new_url))
def make_favorite_ctx(channel, show): label = 'Add show to add-on favorites' new_url = plugin.url_for('add_show_to_favs', channel=channel, show=show) return (label, actions.background(new_url))
def update_library_menu(): return [(lang(40311), actions.background(plugin.url_for('update_library_on_demand')))]
def list_dir(userid=None, path='/'): if not userid: return [] api = get_api(userid) entries = [] for page in xrange(1, 21): tmp_entries = api.list_dir(path, page=page) entries.extend(tmp_entries) if len(tmp_entries) < 100: break dirs = [] video_files = [] # torrent_files = [] subtitle_files = [] # compresses_files = [] other_files = [] for entry in entries: filename = entry['server_filename'] remote_path = entry.get('path').encode('utf-8') file_md5 = entry.get('md5') imgurl = '' if 'thumbs' in entry and 'url1' in entry['thumbs']: imgurl = entry['thumbs']['url1'].replace('size=c140_u90', 'size=c300_u300') if str(entry['isdir']) == '1': dirs.append(filename) elif is_video(filename): video_files.append((filename, remote_path, imgurl, file_md5)) # elif is_torrent(filename): # torrent_files.append((filename, dlink, imgurl,file_md5)) elif is_subtitle(filename): subtitle_files.append((filename, remote_path, imgurl, file_md5)) # elif is_compressed(filename): # compresses_files.append((filename, dlink, imgurl,file_md5)) else: other_files.append((filename, remote_path, imgurl, file_md5)) def get_context_menu(userid, path): if isinstance(path, unicode): path = path.encode('utf-8') return [('[COLOR FFFFFF00]删除[/COLOR]', actions.background( plugin.url_for('delete_path', userid=userid, path=path)))] def get_subtitle(name): filename, _, ext = name.rpartition('.') for subfile, subfile_dlink, _, _ in subtitle_files: if (subfile.startswith(filename + '.') and '.' not in subfile[len(filename) + 1:]): return subfile_dlink return '' items = [{ 'label': '[ %s ]' % name, 'path': plugin.url_for('list_user_dir', userid=userid, path=(path + '/' + name).encode('utf-8')), 'context_menu': get_context_menu(userid, path + '/' + name) } for name in dirs] if video_files: prefer_transcode = plugin.get_setting('prefer_transcode', bool) items.extend([{ 'label': name, 'path': (plugin.url_for('play_transcode_video', userid=userid, path=(path + '/' + name).encode('utf-8'), md5=file_md5, name=name.encode('utf-8'), subtitle=get_subtitle(name)) if prefer_transcode else plugin.url_for('play_path', userid=userid, path=remote_path, md5=file_md5, name=name.encode('utf-8'), subtitle=get_subtitle(name), resolved=True)), 'is_playable': True, 'thumbnail': imgurl or api.get_thumbnail_url(path + '/' + name), 'properties': { 'isPlayable': '' if prefer_transcode else 'true' }, 'context_menu': [('[COLOR FFFFFF00]播放原始视频[/COLOR]' if prefer_transcode else '[COLOR FFFFFF00]播放转码视频[/COLOR]', actions.background( plugin.url_for('play_path', userid=userid, path=remote_path, md5=file_md5, name=name.encode('utf-8'), subtitle=get_subtitle(name) ) if prefer_transcode else plugin. url_for('play_transcode_video', userid=userid, path=(path + '/' + name).encode('utf-8'), md5=file_md5, name=name.encode('utf-8'), subtitle=get_subtitle(name)))), ('[COLOR FFFFFF00]选择转码格式播放[/COLOR]', actions.background( plugin.url_for('play_transcode_video_select_type', userid=userid, path=(path + '/' + name).encode('utf-8'), md5=file_md5, name=name.encode('utf-8'), subtitle=get_subtitle(name))))] + get_context_menu(userid, path + '/' + name) } for name, remote_path, imgurl, file_md5 in video_files]) # if torrent_files: # items.extend([{ # 'label': name, # 'path': plugin.url_for('play_torrent', userid=userid, url=dlink), # 'is_playable': True, # 'properties': {'isPlayable': ''}, # 'context_menu': get_context_menu(userid, path + '/' + name) # } for name, dlink, imgurl in torrent_files]) # if compresses_files: # items.extend([{ # 'label': name, # 'path': plugin.url_for('show_compressed_file', # name=name.encode('utf-8'), # url=dlink), # 'context_menu': get_context_menu(userid, path + '/' + name) # } for name, dlink, imgurl in compresses_files]) if other_files and plugin.get_setting('show_non_video_files', bool): items.extend([{ 'label': name, 'path': '', 'thumbnail': imgurl, 'is_playable': True, 'properties': { 'isPlayable': '' }, 'context_menu': get_context_menu(userid, path + '/' + name), 'replace_context_menu': True } for name, remote_path, imgurl, file_md5 in other_files]) return items
def make_filter_ctx(filterIndex): return (_('delete_filter'), actions.background( plugin.url_for('remove_filter_option', indexId=filterIndex)))
def create_item(data, options=None): options = options or {} airdate = parse_date(data.get('VDA')[:-6]) if data.get('VDA') else None label = '' # prefixes if options.get('show_airtime'): label += '[COLOR fffa481c]{d.hour:02}:{d.minute:02}[/COLOR] '.format( d=airdate) if options.get('show_deletetime'): if data.get('VRU'): # deletion found deletiondate = parse_date(data.get('VRU')[:-6]) label += '[COLOR ffff0000]{d:%a} {d:%d} {d.hour:02}:{d.minute:02}[/COLOR] '.format( d=deletiondate) if options.get('show_views'): label += '[COLOR ff00aae3]{v:>6}[/COLOR] '.format( v=parse_views(data.get('VVI'))) label += '[B]{title}[/B]'.format(title=data.get('VTI').encode('utf8')) # suffixes if data.get('VSU'): label += ' - {subtitle}'.format( subtitle=data.get('VSU').encode('utf8')) item = { 'label': label, 'path': plugin.url_for('play', vid=str(data.get('VPI'))), 'thumbnail': data.get('VTU').get('IUR'), 'is_playable': True, 'info_type': 'video', 'info': { 'label': data.get('VTI'), 'title': data.get('VTI'), 'duration': str(data.get('VDU') * 60), 'genre': data.get('VCG'), 'plot': data.get('VDE'), 'plotoutline': data.get('V7T'), 'year': data.get('productionYear'), 'director': data.get('PPD'), 'aired': str(airdate) }, 'properties': { 'fanart_image': data.get('VTU').get('IUR'), }, 'context_menu': [(plugin.get_string(30021), actions.background( plugin.url_for('download', vid=str(data.get('VPI'))))), (plugin.get_string(30020), actions.background( plugin.url_for('enqueue', vid=str(data.get('VPI')))))], } return item