Skip to content

Commit 4ffc236

Browse files
Merge pull request #52 from Keeper-of-the-Keys/podverse-pagination
Adds pagination support to the plugin
2 parents c6c2a4d + 51cbf6a commit 4ffc236

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/gpodder/plugins/podverse.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import urllib.parse
2727

2828
logger = logging.getLogger(__name__)
29-
29+
PAGE_SIZE = 20
3030

3131
@registry.directory.register_instance
3232
class 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

Comments
 (0)