Beispiel #1
0
def get_info(href):
    idx = jafc.text_to_int(href)
    data = jafc.get_html("{}{}".format(jafc.JAFC_INFO_URI, idx))
    return {
        "plot": jafc.get_table_data(data, "Plot"),
        "title": jafc.get_table_data(data, "English Title"),
        "originaltitle": jafc.get_table_data(data, "Japanese kana Rendering"),  # Original Title
        "year": jafc.text_to_int(jafc.get_table_data(data, "Production Date")),
        "director": jafc.get_table_data(data, "Credits: Director"),
        "duration": jafc.text_to_int(jafc.get_table_data(data, "Duration (minutes)")) * 60
    }
Beispiel #2
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 #3
0
def play_film():
    href = get_arg("href", False)
    if not href:
        return
    url = jafc.get_player_url(jafc.text_to_int(href))
    list_item = ListItem(path=url)
    xp.setResolvedUrl(plugin.handle, True, list_item)
def search():
    # type: () -> Optional[bool]
    """Search the archive"""
    query = get_arg("q")
    category = get_arg("category", ku.localize(32007))  # Search
    total = get_arg("total")
    # Remove saved search item
    if bool(get_arg("delete", False)):
        pas.searches.remove(query)
        xbmc.executebuiltin("Container.Refresh()")
        return True
    # View saved search menu
    if bool(get_arg("menu", False)):
        add_menu_item(search, "[{}]".format(ku.localize(32016)), args={"new": True})  # [New Search]
        for item in pas.searches.retrieve():
            text = item.encode("utf-8")
            add_menu_item(search, text, args={"q": text, "category": "{} '{}'".format(ku.localize(32007), text)})
        xbmcplugin.setPluginCategory(plugin.handle, category)
        xbmcplugin.endOfDirectory(plugin.handle)
        return True
    # New look-up
    if bool(get_arg("new", False)):
        query = ku.user_input()
        if not query:
            return False
        category = "{} '{}'".format(ku.localize(32007), query)
        if pas.SEARCH_SAVED:
            pas.searches.append(query)
    # Process search
    url = get_arg("href", pas.get_search_url(query=query))
    soup = pas.get_html(url)
    count = int(total) if total else pas.text_to_int(soup.find("div", "results_count").text)
    parse_search_results(soup, url, count, category)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Beispiel #5
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 #6
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)
def play_film():
    href = get_arg("href", False)
    if not href:
        return
    url = jafc.get_mpd_url(jafc.text_to_int(href))
    is_helper = inputstreamhelper.Helper(STREAM_FORMAT)
    if is_helper.check_inputstream():
        list_item = ListItem(path=url)
        list_item.setProperty("inputstreamaddon", STREAM_ADDON)
        list_item.setProperty("inputstream.adaptive.manifest_type", STREAM_FORMAT)
        list_item.setMimeType(STREAM_MIME_TYPE)
        list_item.setContentLookup(False)
        xbmcplugin.setResolvedUrl(plugin.handle, True, list_item)
    else:
        logger.debug("play_film error: {}".format(url))
Beispiel #8
0
def paginate(html, category):
    pager = html.find("ul", "pager")
    if not pager:
        return
    offset = eyes.text_to_int(pager.find("li", "pager-current").text) + 1
    first_page = pager.find("li", "pager-first")
    next_page = pager.find("li", "pager-next")
    if first_page:
        add_menu_item(collections,
                      "[{} 1]".format(ku.localize(32011)),
                      {"href": first_page.find_next("a")["href"], "category": category})
    if next_page:
        add_menu_item(collections,
                      "[{} {}]".format(ku.localize(32011), offset),
                      {"href": next_page.find_next("a")["href"], "category": category})
    add_menu_item(index, "[{}]".format(ku.localize(32012)))  # [Menu]
Beispiel #9
0
def parse_time(text):
    # type (str) -> int
    """
    Attempts to calculate the total number of seconds in a time string
    e.g. "10"=10 "1:14"=74 "1:03:28"=3808
    """
    sep = text.count(":")
    if not sep:
        return eafa.text_to_int(text)
    if sep == 1:
        m, s = text.split(":")
        return (eafa.text_to_int(m) * 60) + eafa.text_to_int(s)
    if sep == 2:
        h, m, s = text.split(":")
        return ((eafa.text_to_int(h) * 3600) +
                (eafa.text_to_int(m) * 60) +
                eafa.text_to_int(s))
    return 0
Beispiel #10
0
def paginate(soup, query, period):
    # type: (BeautifulSoup, str, str) -> None
    """Adds pagination to results pages"""
    pager = soup.find("ul", "paging-nav")
    if not pager:
        logger.debug("No pagination for Query:'{}' Period:'{}'".format(
            query, period))
        return
    selected = pager.findNext("a", "selected")
    if not selected:
        return
    offset = bps.text_to_int(selected.text) + 1
    next_page = pager.find("a", string=">")
    category = period if period and query == "+" else query
    if next_page:
        add_menu_item(search,
                      "[{} {}]".format(ku.localize(32011), offset),
                      args={
                          "q": query,
                          "period": period,
                          "page": offset,
                          "category": category
                      })
    add_menu_item(index, "[{}]".format(ku.localize(32012)))  # [Menu]