From 6ca647da33c79be36e856e6b78d95c4c98d597a9 Mon Sep 17 00:00:00 2001 From: kermit Date: Thu, 7 Jan 2021 16:38:35 +0000 Subject: [PATCH] Fix new releases for some obscure channels For example, Christian new release only has the items included in the main page, it doesn't include 'target' to link to more. Also add a general try/except so that an error on one channel doesn't kill the entire request. --- app.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 1040964..c19cdab 100644 --- a/app.py +++ b/app.py @@ -342,13 +342,19 @@ class deemix: pattern = '^New.*releases$' new_releases = next((x for x in channel_data['sections'] if re.match(pattern, x['title'])), None) - if new_releases is None: + try: + if new_releases is None: + return [] + elif 'target' in new_releases: + show_all = dz.gw.get_page(new_releases['target']) + return [x['data'] for x in show_all['sections'][0]['items']] + elif 'items' in new_releases: + return [x['data'] for x in new_releases['items']] + else: + return [] + except Exception: return [] - show_all = dz.gw.get_page(new_releases['target']) - albums = [x['data'] for x in show_all['sections'][0]['items']] - return albums - def newReleases(self, dz): explore = dz.gw.get_page('channels/explore') music_section = next((x for x in explore['sections'] if x['title'] == 'Music'), None)