From 32ce20c630ca48ebb0c01bd3ab1174317cfe8902 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 3 Jul 2021 15:23:45 +0200 Subject: [PATCH] Fix AniPlay --- channels/aniplay.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/channels/aniplay.py b/channels/aniplay.py index 7d362a04..257cfaf8 100644 --- a/channels/aniplay.py +++ b/channels/aniplay.py @@ -197,7 +197,7 @@ def episodios(item): url = '{}/api/anime/{}'.format(host, item.id) json = httptools.downloadpage(url, CF=False ).json - if 'seasons' in json and len(json['seasons']) > 0: + if json.get('seasons'): seasons = json['seasons'] seasons.sort(key=lambda s: s['episodeStart']) @@ -224,21 +224,25 @@ def episodios(item): if res.result(): itlist.extend(res.result()) itemlist = itlist + elif json.get('episodes'): + itemlist = list_episodes(item, json) - # add renumber option - if stack()[1][3] not in ['find_episodes'] and itemlist and itemlist[0].contentType == 'episode': - autorenumber.start(itemlist, item) + # add renumber option + if stack()[1][3] not in ['find_episodes'] and itemlist and itemlist[0].contentType == 'episode': + autorenumber.start(itemlist, item) - # add add to videolibrary menu - if stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes']: - support.videolibrary(itemlist, item) - return itemlist + # add add to videolibrary menu + if stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes']: + support.videolibrary(itemlist, item) + + return itemlist + -def list_episodes(item): +def list_episodes(item, json=None): itemlist = [] - - url = '{}/api/anime/{}'.format(host, item.id) - json = httptools.downloadpage(url, CF=False ).json + if not json: + url = '{}/api/anime/{}'.format(host, item.id) + json = httptools.downloadpage(url, CF=False ).json episodes = json['episodes'] if 'episodes' in json else json episodes.sort(key=lambda ep: int(ep['episodeNumber'].split('.')[0]))