Skip to content

Commit

Permalink
libanilist: Retrieving studios
Browse files Browse the repository at this point in the history
  • Loading branch information
z411 committed Apr 11, 2019
1 parent 759581f commit 94a7438
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions trackma/lib/libanilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def search(self, criteria, method):
genres
synonyms
averageScore
studios(sort: NAME, isMain: true) { nodes { name } }
}
}
}'''
Expand Down Expand Up @@ -421,6 +422,7 @@ def request_info(self, itemlist):
genres
synonyms
averageScore
studios(sort: NAME, isMain: true) { nodes { name } }
}
}'''

Expand Down Expand Up @@ -458,14 +460,12 @@ def _parse_info(self, item):
('Romaji', item['title'].get('romaji')),
('Japanese', item['title'].get('native')),
('Synonyms', item['title'].get('synonyms')),
#('Classification', item.get('classification')),
('Genres', item.get('genres')),
('Studios', [s['name'] for s in item['studios']['nodes']]),
('Synopsis', item.get('description')),
('Type', item.get('format')),
('Average score', item.get('averageScore')),
('Status', self.status_translate[item['status']]),
#('Start Date', item.get('start_date')),
#('End Date', item.get('end_date')),
]
})
return info
Expand Down
4 changes: 2 additions & 2 deletions trackma/ui/qt/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ def s_show_image(self, filename):
def r_details_loaded(self, result):
if result['success']:
details = result['details']
print(repr(details))

info_strings = []
description_strings = []
description_keys = {'Synopsis', 'English', 'Japanese', 'Synonyms'} # This might come down to personal preference
list_keys = {'Genres'} # Anilist gives genres as a list, need a special case to fix formatting

for line in details['extra']:
if line[0] and line[1]:
if line[0] in description_keys:
description_strings.append( "<h3>%s</h3><p>%s</p>" % (line[0], line[1]) )
else:
if line[0] in list_keys:
if isinstance(line[1], list):
description_strings.append( "<h3>%s</h3><p>%s</p>" % (line[0], ', '.join(line[1])) )
elif len("%s" % line[1]) >= 17: # Avoid short tidbits taking up too much vertical space
info_strings.append( "<h3>%s</h3><p>%s</p>" % (line[0], line[1]) )
Expand Down

0 comments on commit 94a7438

Please sign in to comment.