Skip to content

Commit

Permalink
Merge pull request #183 from Keeper-of-the-Keys/opml-import
Browse files Browse the repository at this point in the history
Opml import
  • Loading branch information
Keeper-of-the-Keys authored Mar 20, 2024
2 parents 43f5201 + 2ef440b commit df5c2fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions common/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def import_opml(self, url):
Import subscriptions from a local file
"""
for channel in opml.Importer(url).items:
self.subscribe(channel['url'])
self.subscribe(channel['url'], channel['section'])

@run_in_background_thread
def export_opml(self, uri):
Expand All @@ -250,7 +250,7 @@ def export_opml(self, uri):
opml.Exporter(uri).write(self.core.model.get_podcasts())

@run_in_background_thread
def subscribe(self, url):
def subscribe(self, url, section = None):
url = self.core.model.normalize_feed_url(url)
# TODO: Check if subscription already exists

Expand All @@ -262,7 +262,11 @@ def show_loading():
pyotherside.send('podcast-list-changed')
show_loading()

self.core.model.load_podcast(url, create=True)
podcast = self.core.model.load_podcast(url, create=True)

if section is not None:
podcast.section = section

self.core.save()
pyotherside.send('podcast-list-changed')
pyotherside.send('update-stats')
Expand Down

0 comments on commit df5c2fd

Please sign in to comment.