Browse Source

some things

podcasts
dave 4 years ago
parent
commit
122addbfa9
  1. 39
      pysonic/api.py
  2. 2
      pysonic/database.py
  3. 4
      pysonic/podcast.py

39
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

2
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")

4
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):
"""

Loading…
Cancel
Save