Added general exception catch when tring to connect to deezer

This commit is contained in:
RemixDev 2020-12-30 15:21:33 +01:00
parent 1e9e28ec2c
commit 34b93de62c
No known key found for this signature in database
GPG key ID: B33962B465BDB51C
2 changed files with 8 additions and 4 deletions

10
app.py
View file

@ -96,7 +96,11 @@ class deemix:
def checkDeezerAvailability(self): def checkDeezerAvailability(self):
print("Pinging deezer.com...") print("Pinging deezer.com...")
body = requests.get("https://www.deezer.com/", headers={'Cookie': 'dz_lang=en; Domain=deezer.com; Path=/; Secure; hostOnly=false;'}).text try:
body = requests.get("https://www.deezer.com/", headers={'Cookie': 'dz_lang=en; Domain=deezer.com; Path=/; Secure; hostOnly=false;'}).text
except Exception as e:
self.isDeezerAvailable = False
print(f"deezer.com not reached! {str(e)}")
title = body[body.find('<title>')+7:body.find('</title>')] title = body[body.find('<title>')+7:body.find('</title>')]
self.isDeezerAvailable = title.strip() != "Deezer will soon be available in your country." self.isDeezerAvailable = title.strip() != "Deezer will soon be available in your country."
print(f"deezer.com reached: {'Available' if self.isDeezerAvailable else 'Not Available'}") print(f"deezer.com reached: {'Available' if self.isDeezerAvailable else 'Not Available'}")
@ -340,7 +344,7 @@ class deemix:
if new_releases is None: if new_releases is None:
return [] return []
show_all = dz.gw.get_page(new_releases['target']) show_all = dz.gw.get_page(new_releases['target'])
albums = [x['data'] for x in show_all['sections'][0]['items']] albums = [x['data'] for x in show_all['sections'][0]['items']]
return albums return albums
@ -369,7 +373,7 @@ class deemix:
albums = [a for a in pool.imap(albumDetailsWorker, [x['ALB_ID'] for x in recent_releases])] albums = [a for a in pool.imap(albumDetailsWorker, [x['ALB_ID'] for x in recent_releases])]
return albums return albums
# Queue functions # Queue functions
def addToQueue(self, dz, url, bitrate=None, interface=None, ack=None): def addToQueue(self, dz, url, bitrate=None, interface=None, ack=None):
if ';' in url: if ';' in url:

2
webui

@ -1 +1 @@
Subproject commit 08064146d5242dadcece4cd0fbb910e7f302bad0 Subproject commit fd564547279dbcb8ff1eaf08afe728291e640b62