Beispiel #1
0
def watching_movies():
    xbmcplugin.setContent(request.handle, "movies")
    for item in KinoPubClient("watching/movies").get()["items"]:
        li = ExtendedListItem(
            item["title"].encode("utf-8"),
            poster=item["posters"]["big"],
            properties={"id": item["id"]},
            video_info={"mediatype": mediatype_map[item["type"]]},
            addContextMenuItems=True)
        if item["subtype"] == "multi":
            link = get_internal_link("view_episodes", id=item["id"])
            isdir = True
        else:
            response = KinoPubClient("items/{}".format(item["id"])).get()
            watching_info = KinoPubClient("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"])
            link = get_internal_link("play",
                                     id=item["id"],
                                     title=item["title"].encode("utf-8"),
                                     poster=item["posters"]["big"],
                                     video_info=json.dumps(video_info))
            isdir = False
        xbmcplugin.addDirectoryItem(request.handle, link, li, isdir)
    xbmcplugin.endOfDirectory(request.handle)
Beispiel #2
0
def show_items(items, add_indexes=False):
    xbmc.log("{} : show_items. Total items: {}".format(__plugin__,
                                                       str(len(items))))
    # Fill list with items
    for index, item in enumerate(items, 1):
        title = item["title"].encode("utf-8")
        title = "{}. {}".format(index, title) if add_indexes else title
        li = ExtendedListItem(title,
                              poster=item["posters"]["big"],
                              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": 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"]:
            watching_info = KinoPubClient("watching").get(
                data={"id": item["id"]})["item"]["videos"][0]
            video_info.update({
                "time": watching_info["time"],
                "duration": watching_info["duration"],
                "playcount": watching_info["status"],
            })
            video_info = {
                "time": watching_info["time"],
                "duration": watching_info["duration"],
                "playcount": watching_info["status"],
            }
            link = get_internal_link("play",
                                     id=item["id"],
                                     title=title,
                                     video_info=json.dumps(video_info),
                                     poster=item["posters"]["big"])
            li.setProperty("isPlayable", "true")
            li.setResumeTime(watching_info["time"], watching_info["duration"])
            isdir = False
        elif item["subtype"] == "multi":
            watching_info = KinoPubClient("watching").get(
                data={"id": item["id"]})["item"]
            li.setProperty("subtype", "multi")
            video_info.update({"playcount": watching_info["status"]})
            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)
        li.addPredefinedContextMenuItems()
        xbmcplugin.addDirectoryItem(request.handle, link, li, isdir)