def episodes(id): response = KinoPubClient("items/{}".format(id)).get() item = response["item"] xbmcplugin.setContent(request.handle, "episodes") for video_number, video in enumerate(item["videos"], 1): episode_title = "e{:02d}".format(video_number) if video["title"]: episode_title = "{} | {}".format(episode_title, video["title"].encode("utf-8")) li = xbmcgui.ListItem(episode_title, iconImage=video["thumbnail"], thumbnailImage=video["thumbnail"]) li.setInfo( "Video", video_info( item, { "season": 1, "episode": video_number, "playcount": video["watched"], "mediatype": "episode" })) li.setArt({"poster": item["posters"]["big"]}) li.setProperty("id", str(item["id"])) li.setProperty("isPlayable", "true") qp = { "id": item["id"], "title": episode_title, "episode_number": video_number, "video_data": json.dumps(video) } link = get_internal_link("play", **qp) context_menu.add_items(li) xbmcplugin.addDirectoryItem(request.handle, link, li, False) xbmcplugin.endOfDirectory(request.handle)
def show_items(items, options={}): xbmc.log("%s : show_items. Total items: %s" % (__plugin__, str(len(items)))) xbmcplugin.setContent(handle, 'movies') # Fill list with items for index, item in enumerate(items): isdir = True if item['type'] in ['serial', 'docuserial', 'tvshow' ] else False link = get_internal_link('view', {'id': item['id']}) li = xbmcgui.ListItem(item['title'].encode('utf-8')) if 'enumerate' in options: li.setLabel("%s. %s" % (index + 1, li.getLabel())) li.setInfo( 'Video', addonutils.video_info(item, {'trailer': trailer_link(item)})) li.setArt({'poster': item['posters']['big']}) # If not serials or multiseries movie, create playable item if item['type'] not in ['serial', 'docuserial', 'tvshow']: if item['subtype'] == '': link = get_internal_link('play', { 'id': item['id'], 'video': 1 }) #li.setInfo('Video', {'playcount': int(full_item['videos'][0]['watched'])}) li.setProperty('IsPlayable', 'true') isdir = False else: link = get_internal_link('view', {'id': item['id']}) isdir = True xbmcplugin.addDirectoryItem(handle, link, li, isdir)
def season_episodes(id, season_number): response = KinoPubClient("items/{}".format(id)).get() item = response["item"] watching_info = KinoPubClient("watching").get( data={"id": item["id"]})["item"] season_number = int(season_number) season = item["seasons"][season_number - 1] watching_season = watching_info["seasons"][season_number - 1] selectedEpisode = False xbmcplugin.setContent(request.handle, "episodes") for episode in season["episodes"]: episode_title = "s{:02d}e{:02d}".format(season_number, episode["number"]) if episode["title"]: episode_title = "{} | {}".format(episode_title, episode["title"].encode("utf-8")) li = xbmcgui.ListItem(episode_title, iconImage=episode["thumbnail"], thumbnailImage=episode["thumbnail"]) li.setInfo( "Video", video_info( item, { "season": season_number, "episode": episode["number"], "duration": episode["duration"], "playcount": episode["watched"], "mediatype": "episode" })) li.setArt({"poster": item["posters"]["big"]}) li.setProperty("id", str(item["id"])) li.setProperty("isPlayable", "true") status = watching_season["episodes"][episode["number"] - 1]["status"] if status < 1 and not selectedEpisode: selectedEpisode = True li.select(selectedEpisode) qp = { "id": item["id"], "title": episode_title, "season_number": season["number"], "episode_number": episode["number"], "video_data": json.dumps(episode) } link = get_internal_link("play", **qp) context_menu.add_items(li) xbmcplugin.addDirectoryItem(request.handle, link, li, False) xbmcplugin.endOfDirectory(request.handle)
def seasons(id): response = KinoPubClient("items/{}".format(id)).get() item = response["item"] watching_info = KinoPubClient("watching").get( data={"id": item["id"]})["item"] selectedSeason = False xbmcplugin.setContent(request.handle, "tvshows") for season in item["seasons"]: season_title = "Сезон {}".format(season["number"]) watching_season = watching_info["seasons"][season["number"] - 1] li = xbmcgui.ListItem(season_title) li.setInfo("Video", video_info(item, {"season": season["number"]})) li.setArt({"poster": item["posters"]["big"]}) if watching_season["status"] < 1 and not selectedSeason: selectedSeason = True li.select(selectedSeason) qp = {"id": id, "season_number": season["number"]} link = get_internal_link("view_season_episodes", **qp) xbmcplugin.addDirectoryItem(request.handle, link, li, True) xbmcplugin.endOfDirectory(request.handle)
def show_items(items, options={}): xbmc.log("%s : show_items. Total items: %s" % (__plugin__, str(len(items)))) xbmcplugin.setContent(handle, 'movies') # Fill list with items for index, item in enumerate(items): isdir = True if item['type'] in ['serial', 'docuserial', 'tvshow'] else False link = get_internal_link('view', {'id': item['id']}) li = xbmcgui.ListItem(item['title'].encode('utf-8')) if 'enumerate' in options: li.setLabel("%s. %s" % (index+1, li.getLabel())) li.setInfo('Video', addonutils.video_info(item, {'trailer': trailer_link(item)})) li.setArt({'poster': item['posters']['big']}) # If not serials or multiseries movie, create playable item if item['type'] not in ['serial', 'docuserial', 'tvshow']: if item['subtype'] == '': link = get_internal_link('play', {'id': item['id'], 'video': 1}) #li.setInfo('Video', {'playcount': int(full_item['videos'][0]['watched'])}) li.setProperty('IsPlayable', 'true') isdir = False else: link = get_internal_link('view', {'id': item['id']}) isdir = True xbmcplugin.addDirectoryItem(handle, link, li, isdir)
def show_items(items, add_indexes=False): xbmc.log("{} : show_items. Total items: {}".format(__plugin__, str(len(items)))) xbmcplugin.setContent(request.handle, "movies") # Fill list with items for index, item in enumerate(items, 1): title = item["title"].encode("utf-8") li = xbmcgui.ListItem(title) if add_indexes: li.setLabel("{}. {}".format(index, li.getLabel())) li.setArt({"poster": item["posters"]["big"]}) li.setProperty("id", str(item["id"])) if "in_watchlist" in item: li.setProperty("in_watchlist", str(int(item["in_watchlist"]))) extra_info = { "trailer": trailer_link(item), "mediatype": mediatype_map[item["type"]] } # If not serials or multiseries movie, create playable item if item["type"] not in ["serial", "docuserial", "tvshow" ] and not item["subtype"]: watched = KinoPubClient("watching").get( data={"id": item["id"]})["item"] extra_info.update({"playcount": watched["status"]}) link = get_internal_link("play", id=item["id"], title=title) li.setProperty("isPlayable", "true") isdir = False elif item["subtype"] == "multi": link = get_internal_link("view_episodes", id=item["id"]) isdir = True else: link = get_internal_link("view_seasons", id=item["id"]) isdir = True li.setInfo("Video", video_info(item, extra_info)) context_menu.add_items(li) xbmcplugin.addDirectoryItem(request.handle, link, li, isdir)
def actionView(qp): response = api('items/%s' % qp['id']) #xbmc.log("%s" % response) if response['status'] == 200: item = response['item'] #xbmc.log("%s" % item) watchingInfo = api('watching', {'id': item['id']})['item'] # If serial instance or multiseries film show navigation, else start play if item['type'] in ['serial', 'docuserial', 'tvshow']: if 'season' in qp: for season in item['seasons']: if int(season['number']) == int(qp['season']): watching_season = watchingInfo['seasons'][season['number']-1] selectedEpisode = False xbmcplugin.setContent(handle, 'episodes') for episode_number, episode in enumerate(season['episodes']): episode_number += 1 episode_title = "s%02de%02d" % (season['number'], episode_number) episode_title = episode_title + " | " + episode['title'] if episode['title'] else episode_title li = xbmcgui.ListItem(episode_title, iconImage=episode['thumbnail'], thumbnailImage=episode['thumbnail']) li.setInfo('Video', addonutils.video_info(item, { 'season': int(season['number']), 'episode': episode_number, 'duration': int(episode['duration']), })) li.setInfo('Video', {'playcount': int(episode['watched'])}) li.setArt({'poster': item['posters']['big']}) li.setProperty('IsPlayable', 'true') if watching_season['episodes'][episode_number-1]['status'] < 1 and not selectedEpisode: selectedEpisode = True li.select(selectedEpisode) link = get_internal_link('play', {'id': item['id'], 'season': int(season['number']), 'episode': episode_number}) xbmcplugin.addDirectoryItem(handle, link, li, False) break xbmcplugin.endOfDirectory(handle) else: selectedSeason = False xbmcplugin.setContent(handle, 'tvshows') for season in item['seasons']: #xbmc.log("%s" % season) season_title = "Сезон %s" % int(season['number']) watching_season = watchingInfo['seasons'][season['number']-1] li = xbmcgui.ListItem(season_title) li.setInfo('Video', addonutils.video_info(item, { 'season': int(season['number']), })) li.setArt({'poster': item['posters']['big']}) if watching_season['status'] < 1 and not selectedSeason: selectedSeason = True li.select(selectedSeason) link = get_internal_link('view', {'id': qp['id'], 'season': season['number']}) xbmcplugin.addDirectoryItem(handle, link, li, True) xbmcplugin.endOfDirectory(handle) elif 'videos' in item and len(item['videos']) > 1: xbmcplugin.setContent(handle, 'episodes') for video_number, video in enumerate(item['videos']): video_number += 1 episode_title = "e%02d" % video_number episode_title = "%s | %s" % (episode_title, video['title']) if video['title'] else episode_title li = xbmcgui.ListItem(episode_title, iconImage=video['thumbnail'], thumbnailImage=video['thumbnail']) li.setInfo('Video', addonutils.video_info(item, { 'season' : 1, 'episode': video_number })) li.setInfo('Video', {'playcount': int(video['watched'])}) li.setArt({'poster': item['posters']['big']}) li.setProperty('IsPlayable', 'true') link = get_internal_link('play', {'id': item['id'], 'video': video_number}) xbmcplugin.addDirectoryItem(handle, link, li, False) xbmcplugin.endOfDirectory(handle) else: return
def actionView(qp): response = api('items/%s' % qp['id']) #xbmc.log("%s" % response) if response['status'] == 200: item = response['item'] #xbmc.log("%s" % item) watchingInfo = api('watching', {'id': item['id']})['item'] # If serial instance or multiseries film show navigation, else start play if item['type'] in ['serial', 'docuserial', 'tvshow']: if 'season' in qp: for season in item['seasons']: if int(season['number']) == int(qp['season']): watching_season = watchingInfo['seasons'][ season['number'] - 1] selectedEpisode = False xbmcplugin.setContent(handle, 'episodes') for episode_number, episode in enumerate( season['episodes']): episode_number += 1 episode_title = "s%02de%02d" % (season['number'], episode_number) episode_title = episode_title + " | " + episode[ 'title'] if episode['title'] else episode_title li = xbmcgui.ListItem( episode_title, iconImage=episode['thumbnail'], thumbnailImage=episode['thumbnail']) li.setInfo( 'Video', addonutils.video_info( item, { 'season': int(season['number']), 'episode': episode_number, 'duration': int(episode['duration']), })) li.setInfo('Video', {'playcount': int(episode['watched'])}) li.setArt({'poster': item['posters']['big']}) li.setProperty('IsPlayable', 'true') if watching_season['episodes'][ episode_number - 1]['status'] < 1 and not selectedEpisode: selectedEpisode = True li.select(selectedEpisode) link = get_internal_link( 'play', { 'id': item['id'], 'season': int(season['number']), 'episode': episode_number }) xbmcplugin.addDirectoryItem( handle, link, li, False) break xbmcplugin.endOfDirectory(handle) else: selectedSeason = False xbmcplugin.setContent(handle, 'tvshows') for season in item['seasons']: #xbmc.log("%s" % season) season_title = "Сезон %s" % int(season['number']) watching_season = watchingInfo['seasons'][season['number'] - 1] li = xbmcgui.ListItem(season_title) li.setInfo( 'Video', addonutils.video_info(item, { 'season': int(season['number']), })) li.setArt({'poster': item['posters']['big']}) if watching_season['status'] < 1 and not selectedSeason: selectedSeason = True li.select(selectedSeason) link = get_internal_link('view', { 'id': qp['id'], 'season': season['number'] }) xbmcplugin.addDirectoryItem(handle, link, li, True) xbmcplugin.endOfDirectory(handle) elif 'videos' in item and len(item['videos']) > 1: xbmcplugin.setContent(handle, 'episodes') for video_number, video in enumerate(item['videos']): video_number += 1 episode_title = "e%02d" % video_number episode_title = "%s | %s" % ( episode_title, video['title']) if video['title'] else episode_title li = xbmcgui.ListItem(episode_title, iconImage=video['thumbnail'], thumbnailImage=video['thumbnail']) li.setInfo( 'Video', addonutils.video_info(item, { 'season': 1, 'episode': video_number })) li.setInfo('Video', {'playcount': int(video['watched'])}) li.setArt({'poster': item['posters']['big']}) li.setProperty('IsPlayable', 'true') link = get_internal_link('play', { 'id': item['id'], 'video': video_number }) xbmcplugin.addDirectoryItem(handle, link, li, False) xbmcplugin.endOfDirectory(handle) else: return