예제 #1
0
def seasons(id):
    item = KinoPubClient("items/{}".format(id)).get()["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 = ExtendedListItem(season_title,
                              video_info=extract_video_info(
                                  item, {
                                      "season": season["number"],
                                      "playcount": watching_season["status"],
                                      "mediatype": "season"
                                  }),
                              poster=item["posters"]["big"],
                              properties={"id": item["id"]},
                              addContextMenuItems=True)
        if watching_season["status"] < 1 and not selectedSeason:
            selectedSeason = True
            li.select(selectedSeason)
        link = get_internal_link("view_season_episodes",
                                 id=id,
                                 season_number=season["number"])
        xbmcplugin.addDirectoryItem(request.handle, link, li, True)
    xbmcplugin.endOfDirectory(request.handle)
예제 #2
0
def season_episodes(id, season_number):
    item = KinoPubClient("items/{}".format(id)).get()["item"]
    watching_info = KinoPubClient("watching").get(data={"id": id})["item"]
    season_number = int(season_number)
    season = item["seasons"][season_number - 1]
    watching_season = watching_info["seasons"][season_number - 1]
    watching_episode_numbers = [
        episode["number"] for episode in watching_season["episodes"]
    ]
    selectedEpisode = False
    xbmcplugin.setContent(request.handle, "episodes")
    playback_data = {}
    for episode in season["episodes"]:
        # In tvshow season could be a case when some episodes are not available, but episode numbers
        # in response payload are set correctly.
        if episode["number"] not in watching_episode_numbers:
            continue
        watching_episode = watching_season["episodes"][episode["number"] - 1]
        episode_title = "s{:02d}e{:02d}".format(season_number,
                                                episode["number"])
        if episode["title"]:
            episode_title = "{} | {}".format(episode_title,
                                             episode["title"].encode("utf-8"))
        info = extract_video_info(
            item, {
                "season": season_number,
                "episode": episode["number"],
                "tvshowtitle": episode["title"],
                "time": watching_episode["time"],
                "duration": watching_episode["duration"],
                "playcount": watching_episode["status"],
                "mediatype": "episode"
            })
        li = ExtendedListItem(episode_title,
                              thumbnailImage=episode["thumbnail"],
                              poster=item["posters"]["big"],
                              video_info=info,
                              properties={
                                  "id": item["id"],
                                  "isPlayable": "true"
                              },
                              addContextMenuItems=True)
        if watching_episode["status"] < 1 and not selectedEpisode:
            selectedEpisode = True
            li.select(selectedEpisode)
        link = get_internal_link("play",
                                 id=item["id"],
                                 index=episode["number"])
        playback_data[episode["number"]] = {
            "video_data": episode,
            "video_info": info,
            "poster": item["posters"]["big"],
            "title": episode_title
        }
        xbmcplugin.addDirectoryItem(request.handle, link, li, False)
    set_window_property(playback_data)
    xbmcplugin.endOfDirectory(request.handle, cacheToDisc=False)
예제 #3
0
def season_episodes(id, season_number):
    item = KinoPubClient("items/{}".format(id)).get()["item"]
    watching_info = KinoPubClient("watching").get(data={"id": id})["item"]
    season_number = int(season_number)
    season = item["seasons"][season_number - 1]
    watching_season = watching_info["seasons"][season_number - 1]
    watching_episode_numbers = [
        episode["number"] for episode in watching_season["episodes"]
    ]
    selectedEpisode = False
    xbmcplugin.setContent(request.handle, "episodes")
    for episode in season["episodes"]:
        # In tvshow season could be a case when some episodes are not available, but episode numbers
        # in response payload are set correctly.
        if episode["number"] not in watching_episode_numbers:
            continue
        watching_episode = watching_season["episodes"][episode["number"] - 1]
        episode_title = "s{:02d}e{:02d}".format(season_number,
                                                episode["number"])
        if episode["title"]:
            episode_title = "{} | {}".format(episode_title,
                                             episode["title"].encode("utf-8"))
        info = extract_video_info(
            item, {
                "season": season_number,
                "episode": episode["number"],
                "time": watching_episode["time"],
                "duration": watching_episode["duration"],
                "playcount": watching_episode["status"],
                "mediatype": "episode",
                "title": episode["title"]
            })
        li = ExtendedListItem(episode_title,
                              thumbnailImage=episode["thumbnail"],
                              poster=item["posters"]["big"],
                              video_info=info,
                              properties={
                                  "id": item["id"],
                                  "isPlayable": "true"
                              },
                              addContextMenuItems=True)
        if watching_episode["status"] < 1 and not selectedEpisode:
            selectedEpisode = True
            li.select(selectedEpisode)
        info = {
            "season": season_number,
            "episode": episode["number"],
            "time": watching_episode["time"],
            "duration": watching_episode["duration"],
            "playcount": watching_episode["status"],
            "mediatype": "episode"
        }
        video_data = {'subtitles': episode.get('subtitles', []), 'files': []}
        url = get_mlink(episode,
                        quality=__settings__.getSetting("video_quality"),
                        stream_type=__settings__.getSetting("stream_type"),
                        ask_quality=__settings__.getSetting("ask_quality"))
        link = get_internal_link(
            "play",
            id=item["id"],
            title=episode_title,
            video_info=json.dumps(info),
            video_data=json.dumps(video_data),
            poster=item["posters"]["big"],
            url=url,
        )
        xbmcplugin.addDirectoryItem(request.handle, link, li, False)
    xbmcplugin.endOfDirectory(request.handle)