From 404659facab08699e6372c6d6c04dd8aac6a3dd0 Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 15:47:38 -0500 Subject: [PATCH 1/8] Update anime_planet.py --- minoshiro/web_api/anime_planet.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/minoshiro/web_api/anime_planet.py b/minoshiro/web_api/anime_planet.py index 6c2e535..61e8c11 100644 --- a/minoshiro/web_api/anime_planet.py +++ b/minoshiro/web_api/anime_planet.py @@ -36,9 +36,7 @@ async def get_anime_url(session_manager, query, names: list, :return: the anime url if it's found. """ query = sanitize_search_text(query) - params = { - 'name': quote(query) - } + params = {'name': quote(query)} async with await session_manager.get( "http://www.anime-planet.com/anime/all?", params=params, timeout=timeout) as resp: @@ -47,12 +45,11 @@ async def get_anime_url(session_manager, query, names: list, if ap.find('.cardDeck.pure-g.cd-narrow[data-type="anime"]'): anime_list = [] for entry in ap.find('.card.pure-1-6'): - anime = { + anime_list.append({ 'title': PyQuery(entry).find('h4').text(), 'url': (f'http://www.anime-planet.com' f'{PyQuery(entry).find("a").attr("href")}') - } - anime_list.append(anime) + }) return __get_closest(query, anime_list, names).get('url') return ap.find("meta[property='og:url']").attr('content') @@ -76,9 +73,7 @@ async def get_manga_url(session_manager, query, :return: the anime url if it's found. """ - params = { - 'name': quote(query) - } + params = {'name': quote(query)} if author_name: params['author'] = quote(author_name) async with await session_manager.get( From 35e8480e35b6dd96154a93e5853efdb805a83785 Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 15:49:14 -0500 Subject: [PATCH 2/8] Update kitsu.py --- minoshiro/web_api/kitsu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minoshiro/web_api/kitsu.py b/minoshiro/web_api/kitsu.py index 0ef53e0..c74f6cd 100644 --- a/minoshiro/web_api/kitsu.py +++ b/minoshiro/web_api/kitsu.py @@ -61,7 +61,7 @@ def match_max(thing: dict, matcher: SequenceMatcher) -> float: matcher.set_seq1(name.lower()) ratio = matcher.ratio() if 'one shot' in thing['type'].lower(): - ratio = ratio - .05 + ratio -= .05 if ratio > max_ratio: max_ratio = ratio return max_ratio From 3ab564c986b2f3e31cc3791e2bfffe08c40a3b6e Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 15:53:55 -0500 Subject: [PATCH 3/8] Update anime_planet.py --- minoshiro/web_api/anime_planet.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/minoshiro/web_api/anime_planet.py b/minoshiro/web_api/anime_planet.py index 61e8c11..8bf78af 100644 --- a/minoshiro/web_api/anime_planet.py +++ b/minoshiro/web_api/anime_planet.py @@ -45,11 +45,12 @@ async def get_anime_url(session_manager, query, names: list, if ap.find('.cardDeck.pure-g.cd-narrow[data-type="anime"]'): anime_list = [] for entry in ap.find('.card.pure-1-6'): - anime_list.append({ + anime = { 'title': PyQuery(entry).find('h4').text(), 'url': (f'http://www.anime-planet.com' f'{PyQuery(entry).find("a").attr("href")}') - }) + } + anime_list.append(anime) return __get_closest(query, anime_list, names).get('url') return ap.find("meta[property='og:url']").attr('content') @@ -129,7 +130,7 @@ def get_anime_url_by_id(anime_id) -> str: :return: the anime url. """ - return 'http://www.anime-planet.com/anime/' + str(anime_id) + return f'http://www.anime-planet.com/anime/{anime_id!s}' def get_manga_url_by_id(manga_id) -> str: @@ -140,7 +141,7 @@ def get_manga_url_by_id(manga_id) -> str: :return: the manga url. """ - return 'http://www.anime-planet.com/manga/' + str(manga_id) + return f'http://www.anime-planet.com/manga/{manga_id!s}' def __get_closest(query: str, anime_list: List[dict], names) -> dict: From e993375a1f5b76ec414995b87c4bcfce9716fccd Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 15:55:19 -0500 Subject: [PATCH 4/8] Update mu.py --- minoshiro/web_api/mu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minoshiro/web_api/mu.py b/minoshiro/web_api/mu.py index a7858c7..8bb8236 100644 --- a/minoshiro/web_api/mu.py +++ b/minoshiro/web_api/mu.py @@ -57,7 +57,7 @@ def get_manga_url_by_id(manga_id) -> str: :return: the manga url. """ - return 'https://www.mangaupdates.com/series.html?id=' + str(manga_id) + return f'https://www.mangaupdates.com/series.html?id={manga_id!s}' def __get_closest(query: str, manga_list: List[dict], names) -> dict: From de2a3a252322f53c9e1492a49114be896ebc395c Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 15:55:44 -0500 Subject: [PATCH 5/8] Update anime_planet.py --- minoshiro/web_api/anime_planet.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/minoshiro/web_api/anime_planet.py b/minoshiro/web_api/anime_planet.py index 8bf78af..d9b8e07 100644 --- a/minoshiro/web_api/anime_planet.py +++ b/minoshiro/web_api/anime_planet.py @@ -36,7 +36,9 @@ async def get_anime_url(session_manager, query, names: list, :return: the anime url if it's found. """ query = sanitize_search_text(query) - params = {'name': quote(query)} + params = { + 'name': quote(query) + } async with await session_manager.get( "http://www.anime-planet.com/anime/all?", params=params, timeout=timeout) as resp: @@ -74,7 +76,9 @@ async def get_manga_url(session_manager, query, :return: the anime url if it's found. """ - params = {'name': quote(query)} + params = { + 'name': quote(query) + } if author_name: params['author'] = quote(author_name) async with await session_manager.get( From 7c77a92568aaba2feab00baa54acdacfd16fa1e8 Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 15:56:47 -0500 Subject: [PATCH 6/8] Update nu.py --- minoshiro/web_api/nu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minoshiro/web_api/nu.py b/minoshiro/web_api/nu.py index f01b2a7..a977a5e 100644 --- a/minoshiro/web_api/nu.py +++ b/minoshiro/web_api/nu.py @@ -55,7 +55,7 @@ def get_light_novel_by_id(ln_id: str) -> str: :return: the ln url. """ - return 'http://novelupdates.com/series/' + str(ln_id) + return f'http://novelupdates.com/series/{ln_id!s}' def __get_closest(query: str, ln_list: List[dict], names) -> dict: From 50ad4c61a166d81df21807efaefee71aa69388b5 Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 16:02:48 -0500 Subject: [PATCH 7/8] Update lndb.py --- minoshiro/web_api/lndb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minoshiro/web_api/lndb.py b/minoshiro/web_api/lndb.py index 7b4a158..cff26fe 100644 --- a/minoshiro/web_api/lndb.py +++ b/minoshiro/web_api/lndb.py @@ -57,7 +57,7 @@ def get_light_novel_by_id(ln_id) -> str: :return: the ln url """ - return 'http://lndb.info/light_novel/' + str(ln_id) + return f'http://lndb.info/light_novel/{ln_id!s}' def __get_closest(query: str, ln_list: List[dict], names) -> dict: From f945bdc7fd49729c63403908e9eac5a598b2899e Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Sun, 15 Dec 2019 16:05:20 -0500 Subject: [PATCH 8/8] Update ani_list.py --- minoshiro/web_api/ani_list.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/minoshiro/web_api/ani_list.py b/minoshiro/web_api/ani_list.py index 6fa355c..d100ce4 100644 --- a/minoshiro/web_api/ani_list.py +++ b/minoshiro/web_api/ani_list.py @@ -75,7 +75,7 @@ def match_max(thing: dict, matcher: SequenceMatcher) -> float: matcher.set_seq1(name.lower()) ratio = matcher.ratio() if 'one shot' in thing['type'].lower(): - ratio = ratio - .05 + ratio -= .05 if ratio > max_ratio: max_ratio = ratio return max_ratio @@ -193,10 +193,7 @@ async def get_page_by_popularity(session_manager, medium: Medium, def __get_query_string(medium, query, search=False) -> str: - if medium == Medium.ANIME: - med_str = 'ANIME' - else: - med_str = 'MANGA' + med_str = 'ANIME' if medium == Medium.ANIME else 'MANGA' if search: full_str = f'''Page (page: 1, perPage: 40) {{ media (search: "{query}" type: {med_str})'''