diff --git a/python/podcast/podcast.py b/python/podcast/podcast.py index 424d634dbe7583eae992c26ffa21d8246ded099c..1f2570d8ff1e2c42af58e9eac3faf069f4166cd0 100644 --- a/python/podcast/podcast.py +++ b/python/podcast/podcast.py @@ -306,6 +306,7 @@ class Podcast: def refresh(self, moveto, limit=0): """ Refresh podcast and return list of new entries + @type moveto: int the page the podcast should be moved to (see FeedParser#movePost) """ pyotherside.send("refreshPost", self.title) old_published = self.published @@ -326,7 +327,8 @@ class Podcast: logger.debug("Moveto is %d", move) - yield from self.__process_refreshed_feedentries(feed, limit, move) + for post in self.__process_refreshed_feedentries(feed, limit, move): + yield (move,post) except NotModified: logger.info("Got 304 response, skipping") pyotherside.send("refreshPost", None) @@ -337,14 +339,7 @@ class Podcast: yields all new entries """ new_posts = self.__process_episodes(feed, limit) - for post in new_posts: - yield { - "id": post.id, - "post": post.get_data(), - "pctitle": self.title, - "pstitle": post.title, - "move": move - } + yield from new_posts logger.info("Fount %d new entries.", len(new_posts)) def set_params(self, params): diff --git a/python/podcast/podcastlist.py b/python/podcast/podcastlist.py index 5fe15d623e6d0fac922cfc4454a9c730a95b195a..4ae86d7a41371d2488a436e134d259e7da78bcbc 100644 --- a/python/podcast/podcastlist.py +++ b/python/podcast/podcastlist.py @@ -3,7 +3,7 @@ List of subscribed podcasts """ import sys -from typing import List +from typing import List, Tuple, Iterator sys.path.append("../") @@ -73,9 +73,10 @@ class PodcastList: if hasattr(pc, "subscribed") and pc.subscribed: yield podcast - def refresh(self, moveto, limit=0): + def refresh(self, moveto, limit=0) -> Iterator[Tuple[object, str, str, int]]: """ Refresh all podcasts and put them in queue, index, or archive + @rtype: Iterator[Tuple[object, str, str, int]], yields the postid, podcastitle, posttitle, move """ pllen = len(self.podcasts) @@ -85,8 +86,13 @@ class PodcastList: if pc: try: if pc.subscribed: - for post in pc.refresh(moveto, limit): - yield post + for move, post in pc.refresh(moveto, limit): + yield ( + post.id, + podcast.title, + post.title, + move + ) except: logger.exception( "podcast refresh failed for %s." % pc.title diff --git a/qml/components/FeedParser.py b/qml/components/FeedParser.py index 39984ae32d21403487a7eb548e86c2bc0535b420..53e6be6d4f603091cdc904c0c311b20377abc03a 100644 --- a/qml/components/FeedParser.py +++ b/qml/components/FeedParser.py @@ -114,24 +114,24 @@ def delete_podcast(url): get_podcasts() -def movePost(post): +def movePost(move: int, postid): """ Do move the object into the right place Returns page for Notification """ page = "Inbox" - if post["move"] == 0: - InboxFactory().get_inbox().insert(post["id"]) + if move == 0: + InboxFactory().get_inbox().insert(postid) page = "Inbox" - elif post["move"] == 1: - QueueFactory().get_queue().insert_next(post["id"]) + elif move == 1: + QueueFactory().get_queue().insert_next(postid) page = "Queue" - elif post["move"] == 2: - QueueFactory().get_queue().insert_bottom(post["id"]) + elif move == 2: + QueueFactory().get_queue().insert_bottom(postid) page = "Queue" - elif post["move"] == 3: - ArchiveFactory().get_archive().insert(post["id"]) + elif move == 3: + ArchiveFactory().get_archive().insert(postid) page = "History" return page @@ -157,14 +157,14 @@ def refresh_podcast(url, moveto, download, limit=0): podcast = PodcastFactory().get_podcast(url) posts = [] - for post in podcast.refresh(moveto, limit): - page = movePost(post) - posts.append(post["id"]) + for move, post in podcast.refresh(moveto, limit): + page = movePost(move, post.id) + posts.append(post.id) pyotherside.send( - "updatesNotification", post["pctitle"], post["pstitle"], page + "updatesNotification", podcast.title, post.title, page ) - pyotherside.send("newPodcasts", posts) + pyotherside.send("refreshFinished") def refresh_podcasts(moveto, download, limit=0): @@ -177,17 +177,14 @@ def refresh_podcasts(moveto, download, limit=0): podcast_list = PodcastListFactory().get_podcast_list() - posts = [] - - for post in podcast_list.refresh(moveto, limit): - page = movePost(post) - posts.append(post["id"]) + for postid, podcasttitle, posttitle, move in podcast_list.refresh(moveto, limit): + page = movePost(move, postid) pyotherside.send( - "updatesNotification", post["pctitle"], post["pstitle"], page + "updatesNotification", podcasttitle, posttitle, page ) # pyotherside.send("refreshProgress", count / pllen) - pyotherside.send("newPodcasts", posts) + pyotherside.send("refreshFinished") def get_podcast_params(url): diff --git a/qml/components/FeedParserPython.qml b/qml/components/FeedParserPython.qml index 46b7782aeb1d951e5451f279b749704a759f5e06..1e816204de898b180266cb53a0e17865a6122acf 100644 --- a/qml/components/FeedParserPython.qml +++ b/qml/components/FeedParserPython.qml @@ -13,7 +13,7 @@ Python { signal podcastParams(var pcdata) signal subscribed(string pcurl) signal updatesNotification(string pctitle, string pstitle, string page) - signal newPodcasts(var posts) + signal refreshFinished() signal htmlfile(string htmlfile) signal refreshProgress(real progress) signal refreshPost(string posttitle) @@ -31,7 +31,7 @@ Python { setHandler("podcastParams", podcastParams) setHandler("subscribed", subscribed) setHandler("updatesNotification", updatesNotification) - setHandler("newPodcasts", newPodcasts) + setHandler("refreshFinished", refreshFinished) setHandler("htmlfile", htmlfile) setHandler("refreshProgress", refreshProgress) setHandler("refreshPost", refreshPost) diff --git a/qml/pages/Archive.qml b/qml/pages/Archive.qml index 1f957b59762c77a57ef1c96995237089cf61a050..bc189b28cbe9b208923d30b96a78747b68aa1488 100644 --- a/qml/pages/Archive.qml +++ b/qml/pages/Archive.qml @@ -64,7 +64,7 @@ Page { Connections { target: feedparserhandler - onNewPodcasts: { + onRefreshFinished: { archivetitle.refreshing = false } onRefreshProgress: { diff --git a/qml/pages/Inbox.qml b/qml/pages/Inbox.qml index 0fa4cbb0c7d06f23dca08f71dc7cb2ef89b0df8d..a4f5c800665f61d78605736a3d75a324638b82b7 100644 --- a/qml/pages/Inbox.qml +++ b/qml/pages/Inbox.qml @@ -38,7 +38,7 @@ Page { Connections { target: feedparserhandler - onNewPodcasts: { + onRefreshFinished: { inboxhandler.getInboxEntries(podqast.ifilter) inboxhandler.getInboxPodData() } diff --git a/qml/pages/Queue.qml b/qml/pages/Queue.qml index 19655907296868b46dd98789c4420baf1933ac41..b12571c8503ec361bd802f9500736d52d1d156ae 100644 --- a/qml/pages/Queue.qml +++ b/qml/pages/Queue.qml @@ -41,7 +41,7 @@ Page { Connections { target: feedparserhandler - onNewPodcasts: { + onRefreshFinished: { queuehandler.getQueueEntries() } }