예제 #1
0
    def test_returns_originally_defined_router_instance(self):
        from resources.lib.router_factory import get_router_instance

        expected_instance = 'test'
        self.mock_routing.Plugin.return_value = expected_instance

        router_instance = get_router_instance()
        router_instance2 = get_router_instance()

        self.assertEqual(router_instance, expected_instance)
        self.assertEqual(router_instance2, expected_instance)
        self.mock_routing.Plugin.assert_called_once()
def name_filter():
    plugin = get_router_instance()

    name_input = Dialog().input("Enter anime name")
    _display_filter_menu_items(plugin, { "name": name_input })

    endOfDirectory(plugin.handle)
예제 #3
0
def filter_screen():
    logger.debug("Inside filter screen")
    plugin = get_router_instance()

    _display_filter_menu_items(plugin, _get_current_params(plugin))

    endOfDirectory(plugin.handle)
def video_sources():
    plugin = get_router_instance()
    anime_id = plugin.args["id"][0]
    anime_list_id = plugin.args["listId"][0]
    episode_selection = plugin.args["episode"][0]

    logger.debug("Anime ID: " + anime_id)
    logger.debug("Anime List ID: " + anime_list_id)
    logger.debug("Episode: " + episode_selection)

    params = {
        "id": anime_id,
        "listid": anime_list_id,
        "episode": episode_selection
    }

    res = requests.get(BASE_URL + HOME_DETAIL_PATH, params=params)
    json_data = res.json()

    for source in json_data["data"]["animeWebSiteSrc"]:
        # Website only does the first link. We're using all defined though
        for src in source["srclist"]:
            addDirectoryItem(
                plugin.handle,
                plugin.url_for(play_source,
                               source_url=src["src"],
                               website_name=src["website"]),
                ListItem(src["website"]), True)

    endOfDirectory(plugin.handle)
예제 #5
0
    def test_retrieves_router_instance_if_none_defined(self):
        from resources.lib.router_factory import get_router_instance

        expected_instance = 'test'
        self.mock_routing.Plugin.return_value = expected_instance

        router_instance = get_router_instance()

        self.assertEqual(router_instance, expected_instance)
        self.mock_routing.Plugin.assert_called_once()
예제 #6
0
def index():
    ADDON = xbmcaddon.Addon()
    plugin = get_router_instance()

    anime_list_str = ADDON.getLocalizedString(32002)
    search_str = ADDON.getLocalizedString(32003)

    addDirectoryItem(plugin.handle, plugin.url_for(filter_screen),
                     ListItem(anime_list_str), True)
    addDirectoryItem(plugin.handle, plugin.url_for(search_filter),
                     ListItem(search_str), True)
    endOfDirectory(plugin.handle)
예제 #7
0
def season_select():
    logger.debug("Season select")
    plugin = get_router_instance()
    args = _get_current_params(plugin)

    res = Dialog().select("Choose a season", seasons)

    if res >= 0:
        args[SEASON_ARG_KEY] = seasons[res]

    _display_filter_menu_items(plugin, args)
    endOfDirectory(plugin.handle)
예제 #8
0
def year_select():
    logger.debug("Year select")
    plugin = get_router_instance()
    args = _get_current_params(plugin)

    res = Dialog().select("Choose a year", years)

    if res >= 0:
        args[YEAR_ARG_KEY] = years[res]

    _display_filter_menu_items(plugin, args)
    endOfDirectory(plugin.handle)
예제 #9
0
def anime_list():
    plugin = get_router_instance()

    params = {
        "page": "1",
        "limit": "15",
        "year": "2018",
        "season": "Summer",
        "genres": "",
        "sort": "1",
        "sort2": "",
        "website": ""
    }
    params.update(_get_current_params(plugin))

    int_fields = ["sort", "year", "page", "limit"]
    mapped_ints = {}
    for x in int_fields:
        mapped_ints[x] = int(params.get(x))

    params.update(mapped_ints)

    res = requests.get(BASE_URL + LIST_PATH, params=params)
    json_data = res.json()
    for anime in json_data["data"]["list"]:
        image = anime['backgroundSrc'] if anime['backgroundSrc'] else None
        info = anime['animeSynopsis'] if anime['animeSynopsis'] else ''

        li = ListItem(anime["animeName"])
        li.setArt({'icon': image})
        li.setInfo(type='video', infoLabels={'plot': info})

        addDirectoryItem(
            plugin.handle,
            plugin.url_for(episode_list,
                           id=anime["animeID"],
                           listId=anime["animeListID"],
                           episode_count=anime["animeEpisode"]), li, True)

    are_pages_remaining = math.ceil(
        float(json_data["data"]["count"]) / float(params["limit"])) > int(
            params.get("page"))
    if (are_pages_remaining):
        next_page_params = params.copy()
        next_page_params.update({"page": str(int(params.get("page")) + 1)})

        addDirectoryItem(plugin.handle,
                         plugin.url_for(anime_list, **next_page_params),
                         ListItem('Next Page'), True)

    endOfDirectory(plugin.handle)
def anime_search():
    plugin = get_router_instance()
    search_value = plugin.args["name"][0] if "name" in plugin.args else ""
    page = plugin.args["page"][0] if "page" in plugin.args else "1"

    params = {
        "name": search_value,
        "limit": 10,
        "page": int(page)
    }

    res = requests.get(BASE_URL + SEARCH_PATH, params=params)
    json_data = res.json()

    for anime in json_data['data']['list']:
        li = ListItem(anime["animeName"])
        li.setArt({"icon": anime["backgroundSrc"]})
        li.setInfo(type="video", infoLabels={"plot": anime["animeSynopsis"]})

        addDirectoryItem(
            plugin.handle,
            plugin.url_for(
                episode_list,
                id=str(anime["animeID"]),
                listId=str(anime["animeListID"]),
                episode_count=str(anime["animeEpisode"])
            ),
            li,
            True
        )

    are_pages_remaining = math.ceil(float(json_data["data"]["count"]) / float(params.get("limit"))) > int(page)
    if (are_pages_remaining):
        next_page_params = { "page": page, "name": search_value }
        next_page_params.update({ "page": str(int(params.get("page")) + 1) })

        addDirectoryItem(
            plugin.handle, 
            plugin.url_for(
                anime_search, **next_page_params
            ),
            ListItem('Next Page'),
            True
        )

    endOfDirectory(plugin.handle)
def episode_list():
    plugin = get_router_instance()
    anime_id = plugin.args["id"][0]
    anime_list_id = plugin.args["listId"][0]
    episode_count = plugin.args["episode_count"][0]

    episode_str = ADDON.getLocalizedString(32004)

    for i in range(int(episode_count)):
        episode = str(i + 1)
        addDirectoryItem(
            plugin.handle,
            plugin.url_for(video_sources,
                           id=anime_id,
                           listId=anime_list_id,
                           episode=episode), ListItem(episode_str % episode),
            True)

    endOfDirectory(plugin.handle)
예제 #12
0
def genre_select():
    logger.debug("Genre select")
    plugin = get_router_instance()
    args = _get_current_params(plugin)

    res = requests.get(BASE_URL + GENRE_PATH)
    json_data = res.json()

    list_of_genres = list(
        map(lambda genre_obj: genre_obj.get("name"), json_data.get("data")))

    res = Dialog().multiselect("Select Genres", list_of_genres)

    if res == None:
        args[GENRES_ARG_KEY] = ""
    else:
        args[GENRES_ARG_KEY] = ",".join(
            list(map(lambda i: list_of_genres[i], res)))

    _display_filter_menu_items(plugin, args)
    endOfDirectory(plugin.handle)
예제 #13
0
def play_source():
    plugin = get_router_instance()
    website_name = plugin.args["website_name"][0]
    source_url = plugin.args["source_url"][0]

    logger.debug("Website: " + website_name)
    logger.debug("Source URL: " + source_url)

    embedded_processors = {
        "MP4UPLOAD": mp4upload,
        "STREAMANGO": streamango,
    }

    decrypted_source = None
    processor = embedded_processors.get(
        website_name.split(".")[1].upper(), None)

    try:
        if processor:
            res = requests.get(source_url)
            soup = BeautifulSoup(res.text, 'html.parser')
            if processor:
                (err, decrypted_source) = processor.retrieve_source_url(soup)

                if err:
                    raise err
        else:
            # For sources without custom logic use the urlresolver package
            decrypted_source = resolveurl.resolve(source_url)
            logger.debug(decrypted_source)

        if not processor and not decrypted_source:
            raise AnimePieException(ADDON.getLocalizedString(32001))
        elif decrypted_source:
            play_item = ListItem(path=decrypted_source)
            xbmc.Player().play(decrypted_source, play_item)

    except AnimePieException as e:
        logger.error(e.args)
        xbmc.executebuiltin("Notification(Error," + e.args[0] + ")")
예제 #14
0
def run():
    plugin = get_router_instance()
    generate_all_routes(plugin)
    plugin.run()
def search_filter():
    plugin = get_router_instance()

    _display_filter_menu_items(plugin, { "name": "" })

    endOfDirectory(plugin.handle)