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.
This commit is contained in:
kermit 2021-01-07 16:38:35 +00:00
parent 885d3fb04e
commit 6ca647da33

16
app.py
View file

@ -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)