Skip to content

Commit

Permalink
Multiple search result support.
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaw authored Aug 16, 2019
1 parent 659cc71 commit f17222b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
3 changes: 2 additions & 1 deletion Contents/Code/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def get_anime(id):
return request.content
except:
Log.Error('Error getting anime info')
return

def get_anime_kitsu(id):
headers = {
Expand Down Expand Up @@ -135,4 +136,4 @@ def get_episodes_kitsu(id):
return anime_episodes
except:
Log.Error('Error anime episodes info')
return
return
39 changes: 23 additions & 16 deletions Contents/Code/search.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
def search_anime(type, results, media, lang):
query = media.show if type == 'tv' else media.name
query = String.Quote(query)
# if media.year is not None:
# query += ' (' + media.year + ')'

query = '''
query {
Media (search: "''' + query + '''", type: ANIME) {
id
title {
romaji
anime: Page (perPage: 8) {
pageInfo {
total
}
startDate {
year
results: media (type: ANIME, search: "''' + query + '''") {
id
title {
romaji
}
startDate {
year
}
}
}
}
Expand All @@ -30,12 +33,16 @@ def search_anime(type, results, media, lang):
except:
Log.Error('Error searching AniList - Anime: ' + query)
return
result = JSON.ObjectFromString(request.content)

results.Append(MetadataSearchResult(
id = str(result['data']['Media']['id']),
name = result['data']['Media']['title']['romaji'],
year = result['data']['Media']['startDate']['year'],
score = 100,
lang = lang
))
s = 100
for result in JSON.ObjectFromString(request.content)['data']['anime']['results']:
results.Append(MetadataSearchResult(
id = str(result['id']),
name = result['title']['romaji'],
year = result['startDate']['year'],
score = s,
lang = lang
))
s = s - 1
return

0 comments on commit f17222b

Please sign in to comment.