Added delay for Deezer

This commit is contained in:
krateng 2023-10-25 13:24:03 +02:00
parent 02c6742479
commit 93a371a2c2
2 changed files with 13 additions and 0 deletions

View File

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

View File

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