Skip to content

Commit

Permalink
Merge pull request #48 from Keeper-of-the-Keys/itunes-search
Browse files Browse the repository at this point in the history
Adds iTunes podcast search
  • Loading branch information
Keeper-of-the-Keys authored Sep 18, 2023
2 parents 27138b6 + ebcb9bb commit 8ab8999
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/gpodder/plugins/itunes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import gpodder

from gpodder import util
from gpodder import registry
from gpodder import util, registry, directory

import re
import logging
import urllib.parse

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -60,3 +60,15 @@ def itunes_feed_handler(channel, max_episodes, config):
except Exception as ex:
logger.warn('Cannot resolve iTunes feed: {}'.format(str(ex)))
raise

@registry.directory.register_instance
class ApplePodcastsSearchProvider(directory.Provider):
def __init__(self):
self.name = 'Apple Podcasts'
self.kind = directory.Provider.PROVIDER_SEARCH
self.priority = directory.Provider.PRIORITY_SECONDARY_SEARCH

def on_search(self, query):
json_url = 'https://itunes.apple.com/search?media=podcast&term={}'.format(urllib.parse.quote(query))

return [directory.DirectoryEntry(entry['collectionName'], entry['feedUrl'], entry['artworkUrl100']) for entry in util.read_json(json_url)['results']]

0 comments on commit 8ab8999

Please sign in to comment.