Skip to content

Commit

Permalink
Merge pull request #52 from Keeper-of-the-Keys/podverse-pagination
Browse files Browse the repository at this point in the history
Adds pagination support to the plugin
  • Loading branch information
Keeper-of-the-Keys authored Mar 20, 2024
2 parents c6c2a4d + 51cbf6a commit 4ffc236
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/gpodder/plugins/podverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import urllib.parse

logger = logging.getLogger(__name__)

PAGE_SIZE = 20

@registry.directory.register_instance
class PodverseSearchProvider(directory.Provider):
Expand All @@ -36,20 +36,27 @@ def __init__(self):
self.priority = directory.Provider.PRIORITY_SECONDARY_SEARCH

def on_search(self, query):
json_url = "https://api.podverse.fm/api/v1/podcast?page=1&searchTitle={}&sort=top-past-week".format(urllib.parse.quote(query))
page = 1

while True:
json_url = "https://api.podverse.fm/api/v1/podcast?page={}&searchTitle={}&sort=top-past-week".format(page, urllib.parse.quote(query))

json_data, entry_count = util.read_json(json_url)

if entry_count > 0:
for entry in json_data:
if entry["credentialsRequired"]:
continue

result_data = []
json_data = util.read_json(json_url)[0]
title = entry["title"]
url = entry["feedUrls"][0]["url"]
image = entry["imageUrl"]
description = entry["description"]

for entry in json_data:
if entry["credentialsRequired"]:
continue
yield(directory.DirectoryEntry(title, url, image, -1, description))

title = entry["title"]
url = entry["feedUrls"][0]["url"]
image = entry["imageUrl"]
description = entry["description"]
if entry_count < PAGE_SIZE:
break

result_data.append(directory.DirectoryEntry(title, url, image, -1, description))
page += 1

return result_data

0 comments on commit 4ffc236

Please sign in to comment.