mirror of
https://github.com/krateng/maloja.git
synced 2025-06-05 18:03:14 +03:00
Added delay for Deezer
This commit is contained in:
parent
02c6742479
commit
93a371a2c2
6
maloja/thirdparty/__init__.py
vendored
6
maloja/thirdparty/__init__.py
vendored
@ -10,6 +10,7 @@ import xml.etree.ElementTree as ElementTree
|
|||||||
import json
|
import json
|
||||||
import urllib.parse, urllib.request
|
import urllib.parse, urllib.request
|
||||||
import base64
|
import base64
|
||||||
|
import time
|
||||||
from doreah.logging import log
|
from doreah.logging import log
|
||||||
from threading import BoundedSemaphore
|
from threading import BoundedSemaphore
|
||||||
|
|
||||||
@ -196,6 +197,8 @@ class MetadataInterface(GenericInterface,abstract=True):
|
|||||||
"activated_setting":None
|
"activated_setting":None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay = 0
|
||||||
|
|
||||||
# service provides this role only if the setting is active AND all
|
# service provides this role only if the setting is active AND all
|
||||||
# necessary auth settings exist
|
# necessary auth settings exist
|
||||||
def active_metadata(self):
|
def active_metadata(self):
|
||||||
@ -219,6 +222,7 @@ class MetadataInterface(GenericInterface,abstract=True):
|
|||||||
else:
|
else:
|
||||||
imgurl = None
|
imgurl = None
|
||||||
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
||||||
|
time.sleep(self.delay)
|
||||||
return imgurl
|
return imgurl
|
||||||
|
|
||||||
def get_image_artist(self,artist):
|
def get_image_artist(self,artist):
|
||||||
@ -234,6 +238,7 @@ class MetadataInterface(GenericInterface,abstract=True):
|
|||||||
else:
|
else:
|
||||||
imgurl = None
|
imgurl = None
|
||||||
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
||||||
|
time.sleep(self.delay)
|
||||||
return imgurl
|
return imgurl
|
||||||
|
|
||||||
def get_image_album(self,album):
|
def get_image_album(self,album):
|
||||||
@ -251,6 +256,7 @@ class MetadataInterface(GenericInterface,abstract=True):
|
|||||||
else:
|
else:
|
||||||
imgurl = None
|
imgurl = None
|
||||||
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
||||||
|
time.sleep(self.delay)
|
||||||
return imgurl
|
return imgurl
|
||||||
|
|
||||||
# default function to parse response by descending down nodes
|
# default function to parse response by descending down nodes
|
||||||
|
7
maloja/thirdparty/deezer.py
vendored
7
maloja/thirdparty/deezer.py
vendored
@ -19,6 +19,8 @@ class Deezer(MetadataInterface):
|
|||||||
"required_settings": [],
|
"required_settings": [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay = 1
|
||||||
|
|
||||||
def get_image_track(self,track):
|
def get_image_track(self,track):
|
||||||
return None
|
return None
|
||||||
# we can use the album pic from the track search,
|
# we can use the album pic from the track search,
|
||||||
@ -29,4 +31,9 @@ class Deezer(MetadataInterface):
|
|||||||
if result.get('data') == []:
|
if result.get('data') == []:
|
||||||
return True
|
return True
|
||||||
if result.get('error',{}).get('code',None) == 4:
|
if result.get('error',{}).get('code',None) == 4:
|
||||||
|
self.delay += 1
|
||||||
|
# this is permanent (for the lifetime of the process)
|
||||||
|
# but that's actually ok
|
||||||
|
# since hitting the rate limit means we are doing this to fast
|
||||||
|
# and these requests arent really time sensitive
|
||||||
raise RateLimitExceeded()
|
raise RateLimitExceeded()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user