Skip to content
Snippets Groups Projects
Commit 8331fbf0 authored by Cy8aer's avatar Cy8aer
Browse files

import podcasts from gpodder database

parent 9d9e126b
No related branches found
No related tags found
No related merge requests found
"""
Import gpodder data
"""
import sqlite3
import pyotherside
import os
conn = sqlite3.connect("Database.minidb")
def get():
home = os.path.expanduser('~')
xdg_data_home = os.environ.get('XDG_DATA_HOME', os.path.join(home, '.local', 'share'))
data_home = os.path.join(xdg_data_home, 'harbour-org.gpodder.sailfish')
database = os.path.join(data_home, 'Database.minidb')
conn = sqlite3.connect(database)
c = conn.cursor()
d = conn.cursor()
c = conn.cursor()
d = conn.cursor()
channels = c.execute('SELECT * FROM PodcastChannel')
for channel in channels:
cid = channel[0]
url = channel[2]
channels = c.execute('SELECT * FROM PodcastChannel')
for channel in channels:
cid = channel[0]
url = channel[2]
pyotherside.send("import channel %s" % url)
if url:
yield url
posts = d.execute('SELECT * FROM PodcastEpisode WHERE podcast_id=%d' % cid)
print(cid, url)
for post in posts:
print(post[2])
print()
# posts = d.execute('SELECT * FROM PodcastEpisode WHERE podcast_id=%d' % cid)
# print(cid, url)
# for post in posts:
# print(post[2])
# print()
......@@ -9,6 +9,7 @@ from podcast.singleton import Singleton
from podcast.factory import Factory
from podcast.podcast import PodcastFactory
from podcast import util
from podcast import gpodder_import
import pyotherside
listname = 'the_podcast_list'
......@@ -99,6 +100,21 @@ class PodcastList:
self.save()
return podcounter
def import_gpodder(self):
"""
import podcasts from gpodder database
TODO: Import the posts
"""
podcounter = 0
for pod in gpodder_import.get():
self.add(pod)
podcounter += 1
self.save()
return podcounter
class PodcastListFactory(metaclass=Singleton):
"""
The Factory of fhe PodcastList
......
......@@ -193,8 +193,18 @@ def import_opml(opmlfile):
pclist = PodcastListFactory().get_podcast_list()
imported = pclist.import_opml(opmlfile)
if imported > 0:
pyotherside.send("opmlimported", pclist.import_opml(opmlfile))
pyotherside.send("opmlimported", imported)
def import_gpodder():
"""
Import podcasts from opmlfile
"""
pclist = PodcastListFactory().get_podcast_list()
imported = pclist.import_gpodder()
if imported > 0:
pyotherside.send("opmlimported", imported)
class FeedParser:
def __init__(self):
self.bgthread = threading.Thread()
......@@ -295,4 +305,10 @@ class FeedParser:
self.bgthread = threading.Thread(target=import_opml, args=[opmlfile])
self.bgthread.start()
def importgpodder(self):
if self.bgthread.is_alive():
return
self.bgthread = threading.Thread(target=import_gpodder)
self.bgthread.start()
feedparse = FeedParser()
......@@ -136,6 +136,11 @@ Python {
// call("FeedParser.feedparse.importopml", [opmlfile], function() {})
call("FeedParser.import_opml", [opmlfile], function() {})
}
function importGpodder() {
console.log("Import Podcasts from Gpodder database")
// call("FeedParser.feedparse.importgpodder", function() {})
call("FeedParser.import_gpodder", function() {})
}
onError: {
console.log('python error: ' + traceback);
......
......@@ -8,11 +8,28 @@ Page {
allowedOrientations: Orientation.All
property int margin: 16
SilicaFlickable {
id: mainflick
anchors.fill: parent
// contentHeight: page.height
property bool downloadGpodder: false
property bool downloadOpml: false
Connections {
target: feedparserhandler
onOpmlImported: {
console.log("Notify the OPML imported")
appNotification.previewSummary = opmlcount + qsTr(" Podcasts imported")
appNotification.previewBody = opmlcount + qsTr(" Podcasts imported from OPML")
appNotification.body = opmlcount + qsTr(" Podcasts imported from OPML")
appNotification.publish()
mainflick.downloadGpodder = false
mainflick.downloadOpml = false
}
}
AppMenu { thispage: "Discover" }
Row {
......@@ -48,7 +65,15 @@ Page {
id: importbutton
text: qsTr("Import OPML")
onClicked: {
feedparserhandler.importOpml(opmlfile.text)
Remorse.popupAction(page, qsTr("Import OPML File"), function() {
mainflick.downloadOpml = true
feedparserhandler.importOpml(opmlfile.text)
})
}
BusyIndicator {
size: BusyIndicatorSize.Medium
anchors.centerIn: parent
running: mainflick.downloadOpml
}
}
}
......@@ -59,6 +84,17 @@ Page {
anchors.top: importb.bottom
Button {
text: qsTr("Import from Gpodder")
onClicked: {
Remorse.popupAction(page, qsTr("Import Gpodder Database"), function() {
mainflick.downloadGpodder = true
feedparserhandler.importGpodder()
})
}
BusyIndicator {
size: BusyIndicatorSize.Medium
anchors.centerIn: parent
running: mainflick.downloadGpodder
}
}
}
......
......@@ -119,20 +119,41 @@
<context>
<name>DiscoverImport</name>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="27"/>
<location filename="../qml/pages/DiscoverImport.qml" line="24"/>
<source> Podcasts imported</source>
<translation type="unfinished"> Podcasts importiert</translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="25"/>
<location filename="../qml/pages/DiscoverImport.qml" line="26"/>
<source> Podcasts imported from OPML</source>
<translation type="unfinished"> Podcasts vom OPML importiert</translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="44"/>
<source>Discover by Importing</source>
<translation>Entdecken durch Importieren</translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="49"/>
<location filename="../qml/pages/DiscoverImport.qml" line="66"/>
<source>Import OPML</source>
<translation>Importiere OPML</translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="61"/>
<location filename="../qml/pages/DiscoverImport.qml" line="68"/>
<source>Import OPML File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="86"/>
<source>Import from Gpodder</source>
<translation>Importiere von Gpodder</translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="88"/>
<source>Import Gpodder Database</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiscoverSearch</name>
......@@ -184,7 +205,7 @@
<context>
<name>FeedParserPython</name>
<message>
<location filename="../qml/components/FeedParserPython.qml" line="149"/>
<location filename="../qml/components/FeedParserPython.qml" line="154"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
......
......@@ -119,20 +119,41 @@
<context>
<name>DiscoverImport</name>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="27"/>
<location filename="../qml/pages/DiscoverImport.qml" line="24"/>
<source> Podcasts imported</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="25"/>
<location filename="../qml/pages/DiscoverImport.qml" line="26"/>
<source> Podcasts imported from OPML</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="44"/>
<source>Discover by Importing</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="49"/>
<location filename="../qml/pages/DiscoverImport.qml" line="66"/>
<source>Import OPML</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="61"/>
<location filename="../qml/pages/DiscoverImport.qml" line="68"/>
<source>Import OPML File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="86"/>
<source>Import from Gpodder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/DiscoverImport.qml" line="88"/>
<source>Import Gpodder Database</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiscoverSearch</name>
......@@ -184,7 +205,7 @@
<context>
<name>FeedParserPython</name>
<message>
<location filename="../qml/components/FeedParserPython.qml" line="149"/>
<location filename="../qml/components/FeedParserPython.qml" line="154"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment