Beispiel #1
0
def experts():
    """Lists experts, and their choices"""
    href = get_arg("href", False)
    if not href:
        url = jafc.get_page_url("en/works-favorites.html")
        data = jafc.get_html(url)
        container = data.find("div", "work-favorites")
        for item in container.find_all("div", "work-favorite"):
            action = item.find("a")
            img = item.find("img", "thumbnail")
            title = img["alt"]
            ku.log(action)
            add_menu_item(experts,
                          title,
                          args={"href": "en/" + action["href"], "title": title},
                          info={"plot": item.find("div", "work-favorite-summary").text},
                          art=ku.art(jafc.get_page_url(img["src"])))
    else:
        url = jafc.get_page_url(href)
        data = jafc.get_html(url)
        for item in data.find_all("div", "favorite-work"):
            img = item.find("img", "thumbnail")
            action = item.find("h2").find("a")
            title = action.text
            add_menu_item(play_film,
                          title,
                          args={"href": action["href"]},
                          info={"plot": item.find("dd").text},
                          art=ku.art(jafc.get_page_url(img["src"])),
                          directory=False)
    xp.setPluginCategory(plugin.handle, get_arg("title"))
    xp.endOfDirectory(plugin.handle)
Beispiel #2
0
def highlights():
    href = get_arg("href", False)
    xp.setPluginCategory(plugin.handle, get_arg("title", ku.get_string(32006)))  # Highlights
    if not href:
        url = eafa.get_page_url("highlights.aspx")
        data = eafa.get_html(url)
        for item in data.find_all("div", "hl_box"):
            action = item.find("a")
            img = action.find("img")
            title = img["alt"]
            add_menu_item(
                highlights,
                title,
                {"href": action["href"], "title": title},
                art=ku.art(eafa.get_page_url(img["src"]))
            )
        xp.setContent(plugin.handle, "videos")
        xp.endOfDirectory(plugin.handle)
        return
    url = eafa.get_page_url(href)
    data = eafa.get_html(url)
    form = get_form_data(data)
    if form:
        parse_links(data, form)
    else:
        parse_results(data)
Beispiel #3
0
def films():
    """Playable movie items"""
    url = jafc.get_page_url(get_arg("href"))
    data = jafc.get_html(url)
    paginate(data.find("ul", "pager-menu"), films)
    container = data.find(True, {"class": ["categories", "characters", "writer-works"]})
    for item in container.find_all("li"):
        title = item.find(True, {"class": ["category-title", "character-serif", "writer-work-heading"]}).text
        action = item.find("a")
        if action is None:
            continue
        img = item.find("img", "thumbnail")
        add_menu_item(
            play_film,
            title,
            {"href": action["href"]},
            info=get_info(action["href"]),
            art=ku.art(jafc.get_page_url(img["src"])),
            directory=False)
    xp.setPluginCategory(plugin.handle, get_arg("title"))
    xp.setContent(plugin.handle, "videos")
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_LABEL_IGNORE_THE)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_GENRE)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_VIDEO_YEAR)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_DURATION)
    xp.endOfDirectory(plugin.handle)
Beispiel #4
0
def parse_results(data):
    # type (BeautifulSoup) -> None
    """Adds menu items for result data"""
    directory = data.find("div", {"id": "directory-list"})
    if directory is None:
        return
    list = directory.find("ul")
    if list is None:
        return
    for child in list.find_all("li"):
        image = child.find("img")
        action = child.find("a")
        if image is None or action is None:
            continue
        info = {
            "genre": child.find("div", "col-4").text.split(","),
            "year": bcfs.text_to_int(child.find("div", "col-3").text),
            "director": child.find("div", "col-2").text
        }
        add_menu_item(play_film,
                      child.find("div", "col-1").text,
                      args={"href": action["href"]},
                      info=info,
                      art=ku.art(bcfs.get_page_url(image["src"])),
                      directory=False)
    xp.setContent(plugin.handle, "videos")
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_LABEL_IGNORE_THE)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_GENRE)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_VIDEO_YEAR)
    xp.endOfDirectory(plugin.handle)
Beispiel #5
0
def parse_results(data, offset=1, query=None):
    # type (BeautifulSoup, int, str) -> None
    """Parse videos from results and add pagination"""
    items = data.find_all("div", "result_item")
    if not items:
        return
    if query is not None and data.find("div", "pagination"):
        paginate(query, offset, len(items))
    for item in items:
        action = item.find("a")
        title = item.find("h2").text.strip()
        img = item.find("img")
        add_menu_item(
            play_film,
            title,
            args={"href": action["href"].lstrip("../")},
            art=ku.art(eafa.get_page_url(img["src"])),
            info={
                "title": title,
                "plot": item.find("p").text.strip(),
                "duration": parse_time(item.find("span", "dur").text)
            },
            directory=False
        )
    xp.setContent(plugin.handle, "videos")
    xp.endOfDirectory(plugin.handle)
Beispiel #6
0
def play_film():
    # type: () -> None
    """Show playable item"""
    details = iwm.get_info(iwm.get_page_url(get_arg("href")))
    list_item = ListItem(path=iwm.get_m3u8_url(details["soup"].text))
    list_item.setInfo("video", details["info"])
    xbmcplugin.setResolvedUrl(plugin.handle, True, list_item)
Beispiel #7
0
def search():
    query = get_arg("q")
    href = get_arg("href", False)

    # remove saved search item
    if bool(get_arg("delete", False)):
        jafc.remove(query)
        xbmc.executebuiltin("Container.Refresh()")
        return True

    # View saved search menu
    if bool(get_arg("menu", False)):
        add_menu_item(search, "[{}]".format(ku.get_string(32016)), {"new": True})  # [New Search]
        for item in jafc.retrieve():
            text = item.encode("utf-8")
            add_menu_item(search, text, {"q": text})
        xp.setPluginCategory(plugin.handle, ku.get_string(32007))  # Search
        xp.endOfDirectory(plugin.handle)
        return True

    # look-up
    if bool(get_arg("new", False)):
        query = ku.user_input()
        jafc.append(query)
        if not query:
            return False

    url = jafc.get_page_url(href) if href else jafc.get_search_url(query)
    data = jafc.get_html(url)
    results = data.find("ul", "work-results")
    if not results:
        return

    paginate(data.find("ul", "pager-menu"), search)
    for item in results.find_all("li", "work-result"):
        action = item.find("a")
        img = item.find("img", "thumbnail")
        add_menu_item(play_film,
                      item.find("h2").text,
                      {"href": action["href"]},
                      info=get_info(action["href"]),
                      art=ku.art(jafc.get_page_url(img["src"])),
                      directory=False)
    xp.setPluginCategory(plugin.handle, "{} '{}'".format(ku.get_string(32016), query))
    xp.endOfDirectory(plugin.handle)
Beispiel #8
0
def authors():
    """List of authors"""
    url = jafc.get_page_url("en/writer.html")
    data = jafc.get_html(url)
    container = data.find("ul", "writer-results")
    for item in container.find_all("li"):
        img = item.find("img", "thumbnail")
        action = item.find("a")
        if action is None:
            continue
        add_menu_item(films, action.text, args={
            "href": "en/{}".format(action["href"]),
            "title": action.text
        }, info={
            "plot": item.find("div", "writer-result-description").text
        }, art=ku.art(jafc.get_page_url(img["src"])))
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_LABEL)
    xp.endOfDirectory(plugin.handle)
Beispiel #9
0
def themes():
    url = eafa.get_page_url(get_arg("action"))
    xp.setPluginCategory(plugin.handle, get_arg("title"))
    parse_results(eafa.post_html(url, {
        "ctl00$ContentPlaceHolder1$ucBrowse$cbVideo": "on",
        "__EVENTTARGET": get_arg("target"),
        "__EVENTVALIDATION": get_arg("validation"),
        "__VIEWSTATE": get_arg("state")
    }))
Beispiel #10
0
def play_film():
    # type: () -> None
    """Play film"""
    uri = eyes.get_page_url(get_arg("href"))
    eyes.recents.append(uri)
    details = eyes.get_info(uri)
    token = eyes.get_stream_token(details["soup"])
    list_item = ListItem(path="plugin://plugin.video.youtube/play/?video_id={}".format(token))
    list_item.setInfo("video", details["info"])
    xbmcplugin.setResolvedUrl(plugin.handle, True, list_item)
Beispiel #11
0
def parse_results(href, category):
    # type: (str, str) -> Union[None, bool]
    html = eyes.get_html(eyes.get_page_url(href))
    paginate(html, category)
    data = html.find_all("li", "packery-item")
    for item in data:
        action = item.find("a")
        details = eyes.get_info(eyes.get_page_url(action["href"]))
        add_menu_item(play_film,
                      details["title"],
                      args={"href": action["href"]},
                      art=details["art"],
                      info=details["info"],
                      directory=False)
    xbmcplugin.setContent(plugin.handle, "videos")
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_GENRE)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_DURATION)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
Beispiel #12
0
def play_film():
    """Attempts to find and load an m3u8 file for a give href"""
    url = bfis.get_page_url(get_arg("href"))
    html = bfis.get_html(url)
    try:
        video_id = html.find(True, attrs={PLAYER_ID_ATTR: True})[PLAYER_ID_ATTR]
    except (AttributeError, TypeError) as e:
        return False
    if video_id is not None:
        video_url = bfis.get_video_url(video_id)
        m3u8_url = bfis.get_m3u8(video_url)
        xp.setResolvedUrl(plugin.handle, True, ListItem(path=m3u8_url))
Beispiel #13
0
def play_film():
    """Attempts to find and load an m3u8 file for a give href"""
    url = bfis.get_page_url(get_arg("href"))
    html = bfis.get_html(url)
    try:
        video_id = html.find(True, attrs={PLAYER_ID_ATTR:
                                          True})[PLAYER_ID_ATTR]
    except (AttributeError, TypeError) as e:
        return False
    if video_id is not None:
        video_url = bfis.get_video_url(video_id)
        m3u8_url = bfis.get_m3u8(video_url)
        xp.setResolvedUrl(plugin.handle, True, ListItem(path=m3u8_url))
Beispiel #14
0
def play_film():
    url = eafa.get_page_url(get_arg("href"))
    data = eafa.get_html(url)
    container = data.find("div", {"id": "video-container"})
    if not container:
        return False
    script = container.find_next_sibling("script")
    if not script:
        return False
    mp4_url = eafa.pluck(
        eafa.remove_whitespace(script.text),
        "'hd-2':{'file':'", "'}}});")  # TODO: maybe re
    list_item = ListItem(path=mp4_url)
    xp.setResolvedUrl(plugin.handle, True, list_item)
Beispiel #15
0
def play_film():
    uri = bcfs.get_page_url(get_arg("href"))
    data = bcfs.get_html(uri)
    if data is None:
        return False
    link = data.select_one("a[href*={}]".format(bcfs.PLAYER_URI))
    if link is None:
        return False
    list_item = ListItem(path=link["href"])
    dl_data = data.find("dl", "details")
    plot = data.find("p", "standfirst").text
    year = dl_data.find(
        "dt", string="Release year").find_next_sibling("dd").text.strip()
    list_item.setInfo("video", {"plot": plot, "year": year})
    xp.setResolvedUrl(plugin.handle, True, list_item)
Beispiel #16
0
def the_cut():
    # type: () -> None
    """Shows the-cut menu and sub-menu items"""
    href = get_arg("href")
    category = get_arg("title", "The Cut")
    if not href:
        # The Cut menu
        soup = bfis.get_html(bfis.THE_CUT_URI)
        for card in soup.find_all("div", "c_card"):
            action = card.find(["a", "card__action"]).extract()
            if action is None:
                continue
            title_tag = card.find("h3", "c_card__title")
            plot_tag = card.find("div", "c_card__footer__summary")
            title = title_tag.text if title_tag else action["aria-label"]
            add_menu_item(the_cut,
                          title,
                          args={
                              "href": action["href"],
                              "title": title
                          },
                          info={"plot": plot_tag.text},
                          art=ku.art(bfis.BFI_URI,
                                     card.find("img").attrs))
    else:
        # The Cut playable items
        soup = bfis.get_html(bfis.get_page_url(href))
        items = soup.find_all("div", "player")
        for item in items:
            plot = soup.find("div", "text__visible").find("p") \
                if item is items[0] \
                else item.find_next("div", "m_card__description")
            add_menu_item(play_film,
                          item.get("data-label"),
                          args={
                              "video_id": item.get(PLAYER_ID_ATTR),
                              "href": href
                          },
                          info={
                              "mediatype": "video",
                              "plot": plot.text.encode("utf-8") if plot else ""
                          },
                          art=ku.art(bfis.BFI_URI,
                                     item.find_next("img").attrs),
                          directory=False)
        xbmcplugin.setContent(plugin.handle, "videos")
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Beispiel #17
0
def play_film():
    # type: () -> None
    """Attempts to find the m3u8 file for a give href and play it"""
    url = bfis.get_page_url(get_arg("href"))
    video_id = get_arg("video_id")
    target = get_arg("target")
    soup = bfis.get_html(url)
    if not video_id:
        video_id = soup.find(id=target).get(PLAYER_ID_ATTR) \
            if target \
            else soup.find(True, attrs={PLAYER_ID_ATTR: True})[PLAYER_ID_ATTR]
    if video_id:
        if bfis.RECENT_SAVED:
            bfis.recents.append((url, video_id))
        m3u8 = bfis.get_m3u8_url(video_id)
        xbmcplugin.setResolvedUrl(plugin.handle, True, ListItem(path=m3u8))
Beispiel #18
0
def themes():
    """List of directory menu items for each theme"""
    url = jafc.get_page_url(get_arg("href"))
    data = jafc.get_html(url)
    element = data.find("ul", {
        "class": ["category-condition-keyword", "work-favorites-condition-keyword"]
    })
    for item in element.find_all("li"):
        action = item.find("a")
        span = action.find("span")
        if span:
            span.extract()
        title = action.text
        add_menu_item(films, title, {"href": action["href"], "title": title})
    xp.setPluginCategory(plugin.handle, get_arg("title"))
    xp.endOfDirectory(plugin.handle)
Beispiel #19
0
def show_category():
    # type: () -> None
    """Shows the category menu (based on supplied key)"""
    key = get_arg("key", "category")
    href = get_arg("href", "free")
    target = get_arg("target")
    sub_directory = bool(get_arg("sub_directory", False))
    category = get_arg("title", ku.localize(32008))
    soup = bfis.get_html(bfis.get_page_url(href))
    for card in soup.find_all(*JIG[key]["card"]):
        action = card.find(["a", "card__action"])
        if action is None:
            continue
        plot_tag = card.find(*JIG[key]["plot"])
        title = action["aria-label"].encode("utf-8")
        info = {"plot": plot_tag.text if plot_tag else "", "genre": []}
        if "meta" in JIG[key]:
            bfis.parse_meta_info(card.find_all(*JIG[key]["meta"]), info)
        if target == "play-kermode-introduces":
            del info["duration"]
        add_menu_item(show_category if sub_directory else play_film,
                      title,
                      args={
                          "href": action["href"],
                          "title": title,
                          "target": target
                      },
                      art=ku.art(bfis.BFI_URI,
                                 card.find("img").attrs),
                      info=info,
                      directory=sub_directory)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.setContent(plugin.handle, "videos")
    xbmcplugin.addSortMethod(plugin.handle,
                             xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_GENRE)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_DURATION)
    xbmcplugin.endOfDirectory(plugin.handle)
Beispiel #20
0
def show_category():
    key = get_arg("key", "category")
    href = get_arg("href", "free")
    is_dir = bool(get_arg("isdir", False))
    category = get_arg("title", ku.get_string(32008))
    url = bfis.get_page_url(href)
    html = bfis.get_html(url)
    for card in html.findAll(*JIG[key]["card"]):
        action = card.find(*JIG[key]["action"])
        if action is None:
            continue

        title = card.find(*JIG[key]["title"]).text.encode("utf-8")
        info = {
            "mediatype":
            "video",
            "plot":
            bfis.html_to_text(
                card.find(*JIG[key]["plot"]).text.encode("utf-8"))
        }
        if "meta" in JIG[key]:
            try:
                genre, year, duration = card.find_all(*JIG[key]["meta"],
                                                      limit=3)
                info["genre"] = genre.text.encode("utf-8")
                info["year"] = bfis.text_to_int(year.text.encode("utf-8"))
                info["duration"] = bfis.text_to_int(
                    duration.text.encode("utf-8"))
            except (ValueError, TypeError):
                pass
        add_menu_item(show_category if is_dir else play_film, title, {
            "href": action["href"],
            "title": title
        }, ku.art(card.find("img").attrs), info, is_dir)
    xp.setPluginCategory(plugin.handle, category)
    xp.setContent(plugin.handle, "videos")
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_LABEL_IGNORE_THE)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_GENRE)
    xp.endOfDirectory(plugin.handle)
Beispiel #21
0
def show_category():
    key = get_arg("key", "category")
    href = get_arg("href", "free")
    is_dir = bool(get_arg("isdir", False))
    category = get_arg("title", ku.get_string(32008))
    url = bfis.get_page_url(href)
    html = bfis.get_html(url)
    for card in html.findAll(*JIG[key]["card"]):
        action = card.find(*JIG[key]["action"])
        if action is None:
            continue

        title = card.find(*JIG[key]["title"]).text.encode("utf-8")
        info = {
            "mediatype": "video",
            "plot": bfis.html_to_text(card.find(*JIG[key]["plot"]).text.encode("utf-8"))
        }
        if "meta" in JIG[key]:
            try:
                genre, year, duration = card.find_all(*JIG[key]["meta"], limit=3)
                info["genre"] = genre.text.encode("utf-8")
                info["year"] = bfis.text_to_int(year.text.encode("utf-8"))
                info["duration"] = bfis.text_to_int(duration.text.encode("utf-8"))
            except (ValueError, TypeError):
                pass
        add_menu_item(
            show_category if is_dir else play_film,
            title,
            {"href": action["href"], "title": title},
            ku.art(card.find("img").attrs),
            info,
            is_dir
        )
    xp.setPluginCategory(plugin.handle, category)
    xp.setContent(plugin.handle, "videos")
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_LABEL_IGNORE_THE)
    xp.addSortMethod(plugin.handle, xp.SORT_METHOD_GENRE)
    xp.endOfDirectory(plugin.handle)