mirror of
https://github.com/krateng/maloja.git
synced 2025-04-18 17:47:37 +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 urllib.parse, urllib.request
|
||||
import base64
|
||||
import time
|
||||
from doreah.logging import log
|
||||
from threading import BoundedSemaphore
|
||||
|
||||
@ -196,6 +197,8 @@ class MetadataInterface(GenericInterface,abstract=True):
|
||||
"activated_setting":None
|
||||
}
|
||||
|
||||
delay = 0
|
||||
|
||||
# service provides this role only if the setting is active AND all
|
||||
# necessary auth settings exist
|
||||
def active_metadata(self):
|
||||
@ -219,6 +222,7 @@ class MetadataInterface(GenericInterface,abstract=True):
|
||||
else:
|
||||
imgurl = None
|
||||
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
||||
time.sleep(self.delay)
|
||||
return imgurl
|
||||
|
||||
def get_image_artist(self,artist):
|
||||
@ -234,6 +238,7 @@ class MetadataInterface(GenericInterface,abstract=True):
|
||||
else:
|
||||
imgurl = None
|
||||
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
||||
time.sleep(self.delay)
|
||||
return imgurl
|
||||
|
||||
def get_image_album(self,album):
|
||||
@ -251,6 +256,7 @@ class MetadataInterface(GenericInterface,abstract=True):
|
||||
else:
|
||||
imgurl = None
|
||||
if imgurl is not None: imgurl = self.postprocess_url(imgurl)
|
||||
time.sleep(self.delay)
|
||||
return imgurl
|
||||
|
||||
# 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": [],
|
||||
}
|
||||
|
||||
delay = 1
|
||||
|
||||
def get_image_track(self,track):
|
||||
return None
|
||||
# we can use the album pic from the track search,
|
||||
@ -29,4 +31,9 @@ class Deezer(MetadataInterface):
|
||||
if result.get('data') == []:
|
||||
return True
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user