コード例 #1
0
ファイル: main.py プロジェクト: Limeone/kodi.kino.pub
def season_episodes(item_id, season_number):
    item = plugin.client("items/{}".format(item_id)).get()["item"]
    watching_info = plugin.client("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(plugin.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.
        try:
            watching_episode = watching_season["episodes"][episode["number"] -
                                                           1]
        except IndexError:
            continue
        episode_title = "s{:02d}e{:02d}".format(season_number,
                                                episode["number"])
        if episode["title"]:
            episode_title = u"{} | {}".format(episode_title, episode["title"])
        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 = plugin.list_item(
            episode_title,
            thumbnailImage=episode["thumbnail"],
            poster=item["posters"]["big"],
            fanart=item["posters"]["wide"],
            video_info=info,
            properties={
                "id": item["id"],
                "isPlayable": "true"
            },
            addContextMenuItems=True,
        )
        if watching_episode["status"] < 1 and not selectedEpisode:
            selectedEpisode = True
            li.select(selectedEpisode)
        url = plugin.routing.build_url("play", item["id"], episode["number"])
        playback_data[episode["number"]] = {
            "video_data": episode,
            "video_info": info,
            "poster": item["posters"]["big"],
            "title": episode_title,
        }
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, False)
    set_window_property(playback_data)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=False)
コード例 #2
0
ファイル: main.py プロジェクト: vladimir-poleh/kodi.kino.pub
def show_items(items, content_type, add_indexes=False):
    xbmcplugin.setContent(plugin.handle,
                          content_type_map[content_type.rstrip("s")])
    playback_data = {}
    # Fill list with items
    for index, item in enumerate(items, 1):
        title = item["title"]
        title = u"{}. {}".format(index, title) if add_indexes else title
        li = plugin.list_item(
            title,
            poster=item["posters"]["big"],
            fanart=item["posters"]["wide"],
            properties={"id": item["id"]},
        )
        if "in_watchlist" in item:
            li.setProperty("in_watchlist", str(int(item["in_watchlist"])))
        video_info = extract_video_info(
            item, {
                "trailer": trailer_link(item),
                "mediatype": content_type_map[item["type"]]
            })
        # If not serials or multiseries movie, create a playable item
        if item["type"] not in ["serial", "docuserial", "tvshow"
                                ] and not item["subtype"]:
            watching_info = plugin.client("watching").get(
                data={"id": item["id"]})["item"]["videos"][0]
            video_info.update({
                "time": watching_info["time"],
                "duration": watching_info["duration"],
                "playcount": watching_info["status"],
            })
            link = plugin.routing.build_url("play", item["id"], index)
            li.setProperty("isPlayable", "true")
            li.setResumeTime(watching_info["time"], watching_info["duration"])
            isdir = False
            playback_data[index] = {
                "video_info": video_info,
                "poster": item["posters"]["big"],
                "title": title,
            }
            set_window_property(playback_data)
        elif item["subtype"] == "multi":
            watching_info = plugin.client("watching").get(
                data={"id": item["id"]})["item"]
            li.setProperty("subtype", "multi")
            video_info.update({"playcount": watching_info["status"]})
            link = plugin.routing.build_url("episodes", item["id"])
            isdir = True
        else:
            link = plugin.routing.build_url("seasons", item["id"])
            isdir = True
        li.setInfo("video", video_info)
        li.addPredefinedContextMenuItems()
        li.markAdvert(item["advert"])
        xbmcplugin.addDirectoryItem(plugin.handle, link, li, isdir)
コード例 #3
0
ファイル: main.py プロジェクト: Limeone/kodi.kino.pub
def episodes(item_id):
    item = plugin.client("items/{}".format(item_id)).get()["item"]
    watching_info = plugin.client("watching").get(data={"id": item_id})["item"]
    xbmcplugin.setContent(plugin.handle, "episodes")
    playback_data = {}
    for video in item["videos"]:
        watching_episode = watching_info["videos"][video["number"] - 1]
        episode_title = "e{:02d}".format(video["number"])
        if video["title"]:
            episode_title = u"{} | {}".format(episode_title, video["title"])
        info = extract_video_info(
            item,
            {
                "episode": video["number"],
                "tvshowtitle": video["title"],
                "time": watching_episode["time"],
                "duration": watching_episode["duration"],
                "playcount": video["watched"],
                "mediatype": "episode",
            },
        )
        li = plugin.list_item(
            episode_title,
            thumbnailImage=video["thumbnail"],
            video_info=info,
            poster=item["posters"]["big"],
            fanart=item["posters"]["wide"],
            properties={
                "id": item["id"],
                "isPlayable": "true"
            },
            addContextMenuItems=True,
        )
        url = plugin.routing.build_url("play", item["id"], video["number"])
        playback_data[video["number"]] = {
            "video_data": video,
            "video_info": info,
            "poster": item["posters"]["big"],
            "title": episode_title,
        }
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, False)
    set_window_property(playback_data)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=False)
コード例 #4
0
ファイル: main.py プロジェクト: Limeone/kodi.kino.pub
def watching_movies():
    xbmcplugin.setContent(plugin.handle, "movies")
    playback_data = {}
    for i, item in enumerate(plugin.client("watching/movies").get()["items"]):
        li = plugin.list_item(
            item["title"],
            poster=item["posters"]["big"],
            properties={"id": item["id"]},
            video_info={"mediatype": content_type_map[item["type"].lower()]},
            addContextMenuItems=True,
        )
        if item["subtype"] == "multi":
            url = plugin.routing.build_url("episodes", item["id"])
            isdir = True
        else:
            response = plugin.client("items/{}".format(item["id"])).get()
            watching_info = plugin.client("watching").get(
                data={"id": item["id"]})["item"]["videos"]
            watching_info = watching_info[0]
            video_info = extract_video_info(
                response["item"],
                {
                    "time": watching_info["time"],
                    "duration": watching_info["duration"],
                    "playcount": watching_info["status"],
                },
            )
            li.setInfo("video", video_info)
            li.setProperty("isPlayable", "true")
            li.setResumeTime(watching_info["time"])
            url = plugin.routing.build_url("play", item["id"], i)
            playback_data[i] = {
                "video_info": video_info,
                "poster": item["posters"]["big"],
                "title": item["title"],
            }
            isdir = False
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, isdir)
    set_window_property(playback_data)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=False)