Skip to content

Commit

Permalink
More results parsed in global search
Browse files Browse the repository at this point in the history
  • Loading branch information
Daedren committed Dec 28, 2022
1 parent 64b6298 commit d82f5f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
60 changes: 32 additions & 28 deletions manga/gateways/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ def getProgressFor(self, mediaId):
def searchMediaBy(self, title) -> Mapping[int, TrackerSeries]:
query = """
query($searchId: String) {
Media(search: $searchId, format: MANGA) {
id
synonyms
countryOfOrigin
title {
romaji
english
}
status
chapters
}
Page(page: 1, perPage: 10) {
media(search: $searchId, format: MANGA) {
id
synonyms
countryOfOrigin
title {
romaji
english
}
status
chapters
}
}
}"""
variables = {"searchId": title}

Expand All @@ -91,25 +93,27 @@ def searchMediaBy(self, title) -> Mapping[int, TrackerSeries]:
print(result["errors"])
return

# Merge all of the user's manga lists
entries = result["data"]["Page"]["media"]
models: List[TrackerSeries] = []
series = result["data"]["Media"]
main_titles = [
series["title"]["english"],
series["title"]["romaji"],
]
all_titles = main_titles + series["synonyms"]
non_empty_all_titles = list(filter(None, all_titles))

models.append(
TrackerSeries(
series["id"],
non_empty_all_titles,
series["status"],
series["chapters"],
series["countryOfOrigin"],
0,
for series in entries:
main_titles = [
series["title"]["english"],
series["title"]["romaji"],
]
all_titles = main_titles + series["synonyms"]
non_empty_all_titles = list(filter(None, all_titles))

models.append(
TrackerSeries(
series["id"],
non_empty_all_titles,
series["status"],
series["chapters"],
series["countryOfOrigin"],
0,
)
)
)

# Create anilist ID keyed dictionary
model_dictionary = dict((v.tracker_id, v) for v in models)
Expand Down
1 change: 1 addition & 0 deletions manga/updateAnilistIds.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def updateFor(self, series, interactive=False) -> Optional[str]:

# If not in our tracker, search for it. Add as planning to read.
if result is None:
self.logger.info(f"Couldn't find tracked series. Searching globally.")
entries = self.anilist.searchMediaBy(series)
result = self.__findTrackerForSeries(entries.values(), series, interactive=interactive)
if result is not None:
Expand Down

0 comments on commit d82f5f1

Please sign in to comment.