diff --git a/pysonic/api.py b/pysonic/api.py index 63fd925..99a8e31 100644 --- a/pysonic/api.py +++ b/pysonic/api.py @@ -533,21 +533,36 @@ class PysonicSubsonicApi(object): # Podcast related endpoints @cherrypy.expose @formatresponse - def getPodcasts_view(self, includeEpisodes=False, **kwargs): - #TODO implement includeEpisodes + def getPodcasts_view(self, id=None, includeEpisodes=True, **kwargs): + #TODO implement includeEpisodes properly response = ApiResponse() response.add_child("podcasts") + for podcast in self.library.get_podcasts(): - response.add_child("channel", - _parent="podcasts", - id=podcast["id"], - title=podcast["title"], - url=podcast["url"], - description=podcast["description"], - # coverArt="pl-1" - # originalImageUrl="", - status="completed" # or "downloading" - ) + node = response.add_child("channel", + _parent="podcasts", + id=podcast["id"], + title=podcast["title"], + url=podcast["url"], + description=podcast["description"], + # coverArt="pl-1" + # originalImageUrl="", + status="completed" # or "downloading" + ) + if includeEpisodes: + for episode in self.library.db.get_podcast_episodes(podcast_id=podcast['id']): + response.add_child("episode", + _real_parent=node, # what the actual fuck does this do + isDir="false", + title=episode["title"], + id=episode["id"], + duration="420", + description=episode["description"], + status=episode["status"] + ) + + # publishDate="2018-03-29T01:00:00.000Z"/> + return response @cherrypy.expose diff --git a/pysonic/database.py b/pysonic/database.py index cce1b52..9410917 100644 --- a/pysonic/database.py +++ b/pysonic/database.py @@ -489,6 +489,6 @@ class PysonicDatabase(object): @readcursor def set_podcast_episode_status(self, cursor, episode_id, status): - assert status in ["new", "downloading", "completed"] + assert status in ["new", "skipped", "downloading", "completed"] cursor.execute("UPDATE podcast_episodes SET status=? WHERE id=?", (status, episode_id, )) cursor.execute("COMMIT") diff --git a/pysonic/podcast.py b/pysonic/podcast.py index e6ed3f4..e497d79 100644 --- a/pysonic/podcast.py +++ b/pysonic/podcast.py @@ -1,7 +1,6 @@ -from threading import Thread, Lock, Timer +from threading import Thread, Timer from concurrent.futures import ThreadPoolExecutor from queue import Queue -from contextlib import closing import shutil import logging import os @@ -86,6 +85,7 @@ class PodcastManager(Thread): # for item in self.db.get_podcasts(): # self.refresh_podcast(item) logging.info("podcast refresh complete") + #TODO all episodes in 'new' status change to 'skipped' def refresh_podcast(self, podcast): """