Implement OPML import in the desktop and touch ui
The core has already implemented parsing OPML files from URLs and files, it only needs to be exposed by the UI which this parch does.
This commit is contained in:
parent
1386245b50
commit
8aab9adb4d
4 changed files with 46 additions and 0 deletions
|
@ -7,6 +7,7 @@ import '../common'
|
|||
import '../common/util.js' as Util
|
||||
|
||||
Dialog {
|
||||
property alias labelText: urlEntyLabel.text
|
||||
signal addUrl(string url)
|
||||
|
||||
width: 300
|
||||
|
@ -18,6 +19,7 @@ Dialog {
|
|||
anchors.fill: parent
|
||||
|
||||
Label {
|
||||
id: urlEntyLabel
|
||||
text: 'URL:'
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,19 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: 'Add from OPML'
|
||||
onTriggered: {
|
||||
openDialog('dialogs/AddPodcastDialog.qml', function(dialog) {
|
||||
dialog.title = "Add from OPML"
|
||||
dialog.labelText = "OPML URL:"
|
||||
dialog.addUrl.connect(function (url) {
|
||||
py.call('main.import_opml', [url]);
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: 'Quit'
|
||||
onTriggered: Qt.quit()
|
||||
|
|
17
main.py
17
main.py
|
@ -32,6 +32,7 @@ from gpodder.api import core
|
|||
from gpodder.api import util
|
||||
from gpodder.api import query
|
||||
from gpodder.api import registry
|
||||
from gpodder import opml
|
||||
|
||||
import logging
|
||||
import functools
|
||||
|
@ -221,6 +222,21 @@ class gPotherSide:
|
|||
summary.sort(key=lambda e: e['newEpisodes'], reverse=True)
|
||||
return summary[:int(count)]
|
||||
|
||||
@run_in_background_thread
|
||||
def import_opml(self, url):
|
||||
"""Import subscriptions from an OPML file
|
||||
|
||||
import http://example.com/subscriptions.opml
|
||||
|
||||
Import subscriptions from the given URL
|
||||
|
||||
import ./feeds.opml
|
||||
|
||||
Import subscriptions from a local file
|
||||
"""
|
||||
for channel in opml.Importer(url).items:
|
||||
self.subscribe(channel['url'])
|
||||
|
||||
@run_in_background_thread
|
||||
def subscribe(self, url):
|
||||
url = self.core.model.normalize_feed_url(url)
|
||||
|
@ -545,6 +561,7 @@ load_podcasts = gpotherside.load_podcasts
|
|||
load_episodes = gpotherside.load_episodes
|
||||
show_episode = gpotherside.show_episode
|
||||
play_episode = gpotherside.play_episode
|
||||
import_opml = gpotherside.import_opml
|
||||
subscribe = gpotherside.subscribe
|
||||
unsubscribe = gpotherside.unsubscribe
|
||||
check_for_episodes = gpotherside.check_for_episodes
|
||||
|
|
|
@ -66,6 +66,20 @@ SlidePage {
|
|||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Add from OPML',
|
||||
callback: function () {
|
||||
var ctx = { py: py };
|
||||
pgst.loadPage('TextInputDialog.qml', {
|
||||
buttonText: 'Subscribe',
|
||||
placeholderText: 'OPML URL',
|
||||
pasteOnLoad: true,
|
||||
callback: function (url) {
|
||||
ctx.py.call('main.import_opml', [url]);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Discover new podcasts',
|
||||
callback: function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue