Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def section():
    # type: () -> None
    """Handles the various sections such as years, genre, series, etc"""
    href = get_arg("href", False)
    token = get_arg("token", False)
    category = get_arg("category")
    if not href and token:
        # Section menu
        soup = mias.get_html(mias.get_search_url())
        element = soup.find("ul", {"id": token})
        if not element:
            logger.debug("No menu data: {}".format(token))
            return
        items = element.extract().findAll("li")
        for item in items:
            action = item.find("a")
            if not action:
                continue
            title = action.text.title()
            add_menu_item(section,
                          title,
                          args={
                              "href": action["href"],
                              "category": title
                          })
    else:
        # Section playable items
        url = mias.get_url(href)
        soup = mias.get_html(url)
        parse_search_results(soup, url, category)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 3
0
def experts():
    """Lists experts, and their choices"""
    href = get_arg("href", False)
    if not href:
        url = jafc.get_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"):
            author = item.find("strong").text
            add_menu_item(experts,
                          author,
                          args={"href": "en/" + item.find("a")["href"], "title": item.find("strong").text},
                          info={"plot": item.find("div", "work-favorite-summary").text},
                          art=ku.art(jafc.get_url(item.find("img", "thumbnail")["src"])))
            xbmcplugin.setPluginCategory(plugin.handle, ku.localize(32023))  # Experts Choice
    else:
        url = jafc.get_url(href)
        data = jafc.get_html(url)
        for item in data.find_all("div", "favorite-work"):
            action = item.find("h2").find("a")
            add_menu_item(play_film,
                          action.text,
                          args={"href": action["href"]},
                          info={"plot": item.find("dd").text},
                          art=ku.art(jafc.get_url(item.find("img", "thumbnail")["src"])),
                          directory=False)
            xbmcplugin.setPluginCategory(plugin.handle, get_arg("title"))  # Experts name
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 4
0
def programme():
    """Shows the programme menu or a programme's playable items"""
    href = get_arg("href")
    category = get_arg("category", ku.localize(32009))  # Programs
    if not href:
        # TV Shows menu
        soup = dws.get_html(dws.DW_PROGRAMME_URI)
        content = soup.find("div", {"id": "bodyContent"}).extract()
        items = content.find_all("div", "epg")
        for item in items:
            img = item.find("img")
            title = item.find("h2").text.encode("utf-8")
            action = item.find("a", string="All videos")
            pid = dws.get_program_id(action.get("href"))
            plot = item.find("p").text.strip()
            add_menu_item(programme, title, {
                "href": dws.get_search_url(pid=pid),
                "category": title
            }, ku.art(dws.get_url(img.get("src"))),
                          {"plot": plot if plot else title})
        xbmcplugin.setContent(plugin.handle, "tvshows")
    else:
        # TV Show's playable episodes
        soup = dws.get_html(href)
        parse_search_results(soup, href, programme, category)
        xbmcplugin.setContent(plugin.handle, "episodes")
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def section():
    # type: () -> None
    """Show category menu and category playable items"""
    href = get_arg("href")
    category = get_arg("category", ku.localize(32002))
    page = int(get_arg("page", 1))
    offset = int(get_arg("offset", 0))
    if not href:
        # section menu
        soup = nfpfs.get_html(nfpfs.NFPF_SCREENING_ROOM_URI)
        for item in soup.find_all("table"):
            title = item.find("h5").text
            add_menu_item(section,
                          title,
                          args={
                              "href": item.find("a").get("href"),
                              "category": title
                          },
                          art=ku.art(nfpfs.get_url(
                              item.find("img").get("src"))),
                          info={"plot": item.find("p").text})
    else:
        url = nfpfs.get_url(href)
        soup = nfpfs.get_html(url)
        if url == nfpfs.NFPF_MERCURY_URI:
            # odd playable items
            parse_mercury(soup)
        else:
            results = soup.find_all("figure", "video-thumb")
            items = results[offset:nfpfs.SEARCH_MAX_RESULTS + offset]
            # section paging
            if len(results) > len(items) == nfpfs.SEARCH_MAX_RESULTS:
                paginate(category, href, page)
            for item in items:
                # section playable items
                action = item.find("figcaption").find("a")
                url = nfpfs.get_url(action.get("href"))
                data = nfpfs.get_info(nfpfs.get_html(url))
                data.get("info")["genre"] = item.get("data-archive")
                add_menu_item(play_film,
                              data.get("title"),
                              args={"href": url},
                              art=ku.art(data.get("image")),
                              info=data.get("info"),
                              directory=False)
        xbmcplugin.setContent(plugin.handle, "videos")
        xbmcplugin.addSortMethod(plugin.handle,
                                 xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
        xbmcplugin.addSortMethod(plugin.handle,
                                 xbmcplugin.SORT_METHOD_VIDEO_YEAR)
        xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_GENRE)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 7
0
def programmes():
    # type: () -> None
    """View series curated by British Pathé."""
    href = get_arg("href", False)
    category = get_arg("category", ku.localize(32021))  # programming
    if not href:
        # Programmes menu
        soup = bps.get_html(bps.BP_COLLECTIONS_URI)
        for img in soup.select("a > img"):
            if img.parent['href'].startswith('/programmes/'):
                title = img.parent.findNext("a").text
                href = img.parent.findNext("a")["href"]
                add_menu_item(programmes,
                              title,
                              info={"plot": "foobar"},
                              args={
                                  "href": href,
                                  "category": title
                              },
                              art=ku.art(bps.get_uri(img["src"])))
    else:
        # Programme's playable items
        soup = bps.get_html(bps.get_uri(href))
        table = soup.find("table", {"id": "programmeTable"}).extract()
        for img in table.select("a > img"):
            action = img.parent
            row = action.find_parent("tr")
            add_menu_item(play_film,
                          row.find("span").text,
                          args={"href": action["href"]},
                          info={
                              "plot":
                              "",
                              "year":
                              int(row.find("td", "far-right").text.strip()),
                              "episode":
                              int(
                                  row.find("td",
                                           "episode-number").text.strip())
                          },
                          art=ku.art(img["src"]),
                          directory=False)
        xbmcplugin.setContent(plugin.handle, "episodes")
        xbmcplugin.addSortMethod(plugin.handle,
                                 xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
        xbmcplugin.addSortMethod(plugin.handle,
                                 xbmcplugin.SORT_METHOD_VIDEO_YEAR)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
def recent():
    # type: () -> None
    """Show recently viewed films"""
    data = bfis.recents.retrieve()
    for url, video_id in data:
        soup = bfis.get_html(url)
        title = soup.find("h1").text.strip()
        description = soup.find("meta", {
            "name": "description"
        }).get("content").encode("utf-8")
        image = soup.find("meta", {"property": "og:image"}).get("content")
        add_menu_item(play_film,
                      title,
                      args={
                          "href": url,
                          "video_id": video_id
                      },
                      info={
                          "plot": description,
                          "mediatype": "video"
                      },
                      art=ku.art("", image),
                      directory=False)
    xbmcplugin.setContent(plugin.handle, "videos")
    xbmcplugin.setPluginCategory(plugin.handle,
                                 ku.localize(32021))  # Recently Viewed
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 10
0
def archive():
    # type: () -> None
    """View important anniversaries, contextualising current events or illustrating trending topics"""
    data = bps.get_html(bps.BP_ARCHIVE_URI)
    content = data.find("div", "entry-content")
    if not content:
        logger.debug("Missing menu: {}".format(bps.BP_ARCHIVE_URI))
        return
    images = content.select("a > img")
    # Archive menu
    for img in images:
        action = img.findNext("a")
        if not action:
            continue
        title = action.text.strip()
        date = action.findNextSibling("strong").text.strip()
        add_menu_item(collection,
                      "{} ({})".format(title, date),
                      args={
                          "href": action["href"],
                          "playable": True,
                          "category": title
                      },
                      art=ku.art(img["src"]))
    xbmcplugin.setPluginCategory(plugin.handle,
                                 ku.localize(32009))  # Archive Picks
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 11
0
def search():
    query = get_arg("q")
    offset = int(get_arg("offset", 0))
    # remove saved search item
    if bool(get_arg("delete", False)):
        bcfs.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 bcfs.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()
        bcfs.append(query)
        if not query:
            return False

    search_url = bcfs.get_search_url(query=query)
    data = bcfs.get_html(search_url)
    xp.setPluginCategory(
        plugin.handle, "{} '{}'".format(ku.get_string(32007),
                                        bcfs.query_decode(query)))
    parse_results(data)
Ejemplo n.º 12
0
def films():
    """Playable movie items"""
    url = jafc.get_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"]})
    if container is None:
        ku.notification(ku.localize(32008), ku.localize(32009))  # Error - No playable items found
        return
    for item in container.find_all("li"):
        action = item.find("a")
        if action is None:
            continue
        add_menu_item(
            play_film,
            item.find(True, {"class": ["category-title", "character-serif", "writer-work-heading"]}).text,
            args={"href": action["href"]},
            info=jafc.get_info(action["href"]),
            art=ku.art(jafc.get_url(item.find("img", "thumbnail")["src"])),
            directory=False)
    xbmcplugin.setContent(plugin.handle, "videos")
    xbmcplugin.setPluginCategory(plugin.handle, get_arg("title"))
    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)
Ejemplo n.º 13
0
def shows():
    page = get_arg("page", 0)
    category = get_arg("category", ku.localize(32003))
    soup = ngs.get_html(ngs.get_show_url(page))
    # Shows paging
    load_more = soup.find("a", "load-more")
    if load_more:
        next_page = ngs.get_gp(load_more.get("href"))
        add_menu_item(shows,
                      "[{} {}]".format(ku.localize(32011), next_page + 1),
                      args={"page": next_page})
    for item in soup.find_all("div", "media-module"):
        # shows menu
        action = item.find("a")
        title = item.find("div", "title").text
        img = action.find("img")
        count = ngs.get_playable_item_count(action.get("href"))
        add_menu_item(section,
                      "{} [{} items]".format(title, count),
                      args={
                          "href": action.get("href"),
                          "category": title
                      },
                      art=ku.art(img.get("src")))
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
def browse():
    data = eafa.get_html(eafa.EAFA_BROWSE_URI)
    form = get_form_data(data)
    if not form:
        return False
    container = data.find("div", {"id": get_arg("id")})
    form["action"] = "browse.aspx"
    parse_links(container, form)
Ejemplo n.º 17
0
def collection():
    # type: () -> None
    """Various workspaces by theme, location and the personalities involved."""
    category = get_arg("category", False)
    playable = get_arg("playable", False)
    href = get_arg("href", False)
    data = bps.get_collection_data()
    if not category:
        # Main collections menu
        for item in data:
            add_menu_item(collection,
                          item,
                          args={"category": item.encode("utf-8")})
    if category and not href:
        # Collection category menu
        for item in data[category]:
            add_menu_item(collection,
                          item,
                          args={
                              "href": bps.get_uri(data[category][item][0]),
                              "category": item.encode("utf-8")
                          },
                          art=ku.art(bps.get_uri(data[category][item][1])))
    if href and not playable:
        # Collection category sub-meu
        soup = bps.get_html(href)
        workspaces = soup.find_all("dl", "workspace")
        for item in workspaces:
            action = item.find("a")
            title = action["title"].strip().encode("utf-8")
            add_menu_item(collection,
                          title,
                          args={
                              "href": action["href"],
                              "category": title,
                              "playable": True
                          },
                          art=ku.art(item.find("img")["src"]))
    if href and playable:
        # Collection category sub-menu playable items
        soup = bps.get_html(href)
        parse_search_results(soup)
    xbmcplugin.setPluginCategory(plugin.handle,
                                 category if category else ku.localize(32004))
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 18
0
def past24h():
    """Shows playable items from the last 24 hours"""
    url = dws.get_search_url()
    soup = dws.get_html(url)
    parse_search_results(soup, url, past24h, ku.localize(32004))
    xbmcplugin.setContent(plugin.handle, "episodes")
    xbmcplugin.setPluginCategory(plugin.handle,
                                 ku.localize(32004))  # Past 24 hours
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 19
0
def year(token):
    if token == "0":
        for item in BCF_YEARS:
            add_menu_item(year, str(item), {"token": item})
        xp.setPluginCategory(plugin.handle, ku.get_string(32005))
        xp.endOfDirectory(plugin.handle)
        return
    uri = bcfs.get_search_url(year=token)
    data = bcfs.get_html(uri)
    xp.setPluginCategory(plugin.handle, token)
    parse_results(data)
Ejemplo n.º 20
0
def new():
    # type: () -> None
    """Shows new playable items menu"""
    href = get_arg("href", ngs.NG_URI)
    soup = ngs.get_html(ngs.get_url(href))
    parse_search_results(
        soup.find("div", {
            "id": "grid-frame"
        }).extract(), ku.localize(32006), new)
    xbmcplugin.setPluginCategory(plugin.handle, ku.localize(32006))
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 21
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
    }
Ejemplo n.º 22
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))
Ejemplo n.º 23
0
def series(token):
    if token == "0":
        for idx, name in enumerate(BCF_SERIES):
            if idx == 0:
                continue
            add_menu_item(series, name, {"token": idx})
        xp.setPluginCategory(plugin.handle, ku.get_string(32006))
        xp.endOfDirectory(plugin.handle)
        return
    uri = bcfs.get_search_url(series=token)
    data = bcfs.get_html(uri)
    xp.setPluginCategory(plugin.handle, BCF_SERIES[int(token)])
    parse_results(data)
Ejemplo n.º 24
0
def topic():
    """Shows the topics menu or a topic's playable items"""
    href = get_arg("href", False)
    category = get_arg("category", ku.localize(32008))  # Themes
    if not href:
        # Topics menu
        soup = dws.get_html(dws.DW_MEDIA_ALL_URL)
        content = soup.find("div", {"id": "themes"}).extract()
        items = content.find_all("a", "check")
        for item in items:
            add_menu_item(
                topic, item.text, {
                    "href": dws.get_search_url(tid=item.get("value")),
                    "category": item.text
                })
    else:
        # Topic's playable items
        soup = dws.get_html(href)
        parse_search_results(soup, href, topic, category)
        xbmcplugin.setContent(plugin.handle, "episodes")
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 25
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))
Ejemplo n.º 26
0
def section():
    # type: () -> None
    """Show category menu and category playable items"""
    href = get_arg("href")
    category = get_arg("category", ku.localize(32002))
    if not href:
        # category menu
        soup = ngs.get_html(ngs.NG_URI)
        menu = soup.find("ul", "dropdown-menu").extract()
        for item in menu.find_all("li"):
            action = item.find("a")
            add_menu_item(section,
                          action.text,
                          args={
                              "href": action.get("href"),
                              "category": action.text
                          })
    else:
        # playable items
        soup = ngs.get_html(ngs.get_url(href))
        parse_search_results(soup, category, section)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 27
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)
Ejemplo n.º 28
0
def recent():
    # type: () -> None
    """Show recently viewed films"""
    data = pas.recents.retrieve()
    for url in data:
        soup = pas.get_html(url)
        info = pas.get_info(soup)
        add_menu_item(play_film,
                      info.get("title"),
                      args={"href": url},
                      art=ku.art(pas.get_url(info.get("image"))),
                      info=info.get("info"),
                      directory=False)
    xbmcplugin.setPluginCategory(plugin.handle, ku.localize(32005))  # Recent
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
def play_film():
    # type: () -> None
    """Show playable item"""
    href = get_arg("href")
    url = pas.get_url(href)
    soup = pas.get_html(url)
    data = pas.get_info(soup)
    if not data.get("video"):
        logger.debug("play_film error: {}".format(href))
        return
    if pas.RECENT_SAVED:
        pas.recents.append(url)
    list_item = ListItem(path=data.get("video"))
    list_item.setInfo("video", data.get("info"))
    xbmcplugin.setResolvedUrl(plugin.handle, True, list_item)
Ejemplo n.º 31
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.localize(32016)), {"new": True})  # [New Search]
        for item in jafc.retrieve():
            text = item.encode("utf-8")
            add_menu_item(
                search,
                text,
                args={"q": text})
        xbmcplugin.setPluginCategory(plugin.handle, ku.localize(32007))  # Search
        xbmcplugin.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_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,
                      args={"href": action["href"]},
                      info=jafc.get_info(action["href"]),
                      art=ku.art(jafc.get_url(img["src"])),
                      directory=False)
    xbmcplugin.setPluginCategory(plugin.handle, "{} '{}'".format(ku.localize(32016), query))
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 32
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))
Ejemplo n.º 33
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)
Ejemplo n.º 34
0
def authors():
    """List of authors"""
    url = jafc.get_url("en/writer.html")
    data = jafc.get_html(url)
    container = data.find("ul", "writer-results")
    for item in container.find_all("li"):
        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_url(item.find("img", "thumbnail")["src"])))
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.setPluginCategory(plugin.handle, ku.localize(32004))  # Authors
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 35
0
def collections():
    # type: () -> None
    href = get_arg("href", False)
    category = get_arg("category", ku.localize(32004))
    if not href:
        # Show the list of collections
        html = eyes.get_html(eyes.EYE_COLLECTIONS_URI)
        ul = html.find("ul", {"id": "facetapi-facet-search-apieye-filmgeschiedenis-block-field-coll-sub"})
        data = ul.find_all("li", "leaf")
        for item in data:
            action = item.find("a", "facetapi-inactive")
            title = action.contents[0].encode("utf-8").title()
            add_menu_item(collections, title, args={"href": action["href"], "category": title})
    else:
        parse_results(href, category)
    xbmcplugin.setPluginCategory(plugin.handle, category)
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 36
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)
Ejemplo n.º 37
0
def themes():
    """List of directory menu items for each theme"""
    url = jafc.get_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()
        add_menu_item(
            films,
            action.text,
            args={"href": action["href"], "title": action.text})
    xbmcplugin.setPluginCategory(plugin.handle, get_arg("title"))
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 38
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)
Ejemplo n.º 39
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)
Ejemplo n.º 40
0
def year():
    # type: () -> None
    """View archive by periods"""
    period = get_arg("period", False)
    if not period:
        # Years menu
        for item in BP_PERIODS:
            add_menu_item(year, str(item), args={"period": item})
        xbmcplugin.setPluginCategory(plugin.handle,
                                     ku.localize(32006))  # Years
    else:
        # Period playable items
        start, end = period.split("-")
        url = bps.get_search_url(start=start, end=end)
        soup = bps.get_html(url)
        paginate(soup, "+", period)
        parse_search_results(soup)
        xbmcplugin.setPluginCategory(plugin.handle, period)  # YYYY-YYYY
    xbmcplugin.endOfDirectory(plugin.handle)
Ejemplo n.º 41
0
def search():
    query = get_arg("q")
    page = int(get_arg("page", 1))

    # remove saved search item
    if bool(get_arg("delete", False)):
        eafa.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 eafa.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()
        eafa.append(query)
        if not query:
            return False

    form = get_form_data(eafa.get_html(eafa.EAFA_SEARCH_URI))
    if not form:
        return False
    data = eafa.post_html(eafa.EAFA_SEARCH_URI, {
        "__EVENTTARGET": "ctl00$ContentPlaceHolder1$ucSearch$ToolkitScriptManager1",
        "__EVENTARGUMENT": eafa.get_search_params(query, page),
        "__VIEWSTATE": form["state"]
    })
    xp.setPluginCategory(
        plugin.handle,
        "{} '{}'".format(ku.get_string(32007),  # Search 'query'
                         eafa.query_decode(query))
    )
    parse_results(data, page, query)
Ejemplo n.º 42
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)