2626import urllib .parse
2727
2828logger = logging .getLogger (__name__ )
29-
29+ PAGE_SIZE = 20
3030
3131@registry .directory .register_instance
3232class PodverseSearchProvider (directory .Provider ):
@@ -36,20 +36,27 @@ def __init__(self):
3636 self .priority = directory .Provider .PRIORITY_SECONDARY_SEARCH
3737
3838 def on_search (self , query ):
39- json_url = "https://api.podverse.fm/api/v1/podcast?page=1&searchTitle={}&sort=top-past-week" .format (urllib .parse .quote (query ))
39+ page = 1
40+
41+ while True :
42+ json_url = "https://api.podverse.fm/api/v1/podcast?page={}&searchTitle={}&sort=top-past-week" .format (page , urllib .parse .quote (query ))
43+
44+ json_data , entry_count = util .read_json (json_url )
45+
46+ if entry_count > 0 :
47+ for entry in json_data :
48+ if entry ["credentialsRequired" ]:
49+ continue
4050
41- result_data = []
42- json_data = util .read_json (json_url )[0 ]
51+ title = entry ["title" ]
52+ url = entry ["feedUrls" ][0 ]["url" ]
53+ image = entry ["imageUrl" ]
54+ description = entry ["description" ]
4355
44- for entry in json_data :
45- if entry ["credentialsRequired" ]:
46- continue
56+ yield (directory .DirectoryEntry (title , url , image , - 1 , description ))
4757
48- title = entry ["title" ]
49- url = entry ["feedUrls" ][0 ]["url" ]
50- image = entry ["imageUrl" ]
51- description = entry ["description" ]
58+ if entry_count < PAGE_SIZE :
59+ break
5260
53- result_data . append ( directory . DirectoryEntry ( title , url , image , - 1 , description ))
61+ page += 1
5462
55- return result_data
0 commit comments