26
26
import urllib .parse
27
27
28
28
logger = logging .getLogger (__name__ )
29
-
29
+ PAGE_SIZE = 20
30
30
31
31
@registry .directory .register_instance
32
32
class PodverseSearchProvider (directory .Provider ):
@@ -36,20 +36,27 @@ def __init__(self):
36
36
self .priority = directory .Provider .PRIORITY_SECONDARY_SEARCH
37
37
38
38
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
40
50
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" ]
43
55
44
- for entry in json_data :
45
- if entry ["credentialsRequired" ]:
46
- continue
56
+ yield (directory .DirectoryEntry (title , url , image , - 1 , description ))
47
57
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
52
60
53
- result_data . append ( directory . DirectoryEntry ( title , url , image , - 1 , description ))
61
+ page += 1
54
62
55
- return result_data
0 commit comments