Permalink
Browse files

Python backend: Delete episode, error checking

  • Loading branch information...
thp committed Jan 30, 2014
1 parent 2e18f54 commit ef279bbd3d16bac8e15699ef1db546b9badb5233
Showing with 13 additions and 0 deletions.
  1. +13 −0 main.py
View
13 main.py
@@ -159,10 +159,12 @@ def get_fresh_episodes(self):
@run_in_background_thread
def subscribe(self, url):
url = util.normalize_feed_url(url)
+ # TODO: Check if subscription already exists
self.core.model.load_podcast(url, create=True)
self.core.save()
pyotherside.send('podcast-list-changed')
pyotherside.send('update-stats')
+ # TODO: Return True/False for reporting success
@run_in_background_thread
def unsubscribe(self, podcast_id):
@@ -177,6 +179,9 @@ def download_episode(self, episode_id):
def progress_callback(progress):
pyotherside.send('download-progress', episode_id, progress)
episode = self._get_episode_by_id(episode_id)
+ if episode.state == gpodder.STATE_DOWNLOADED:
+ return
+
pyotherside.send('downloading', episode_id)
if episode.download(progress_callback):
pyotherside.send('downloaded', episode_id)
@@ -185,6 +190,13 @@ def progress_callback(progress):
self.core.save()
pyotherside.send('update-stats')
+ @run_in_background_thread
+ def delete_episode(self, episode_id):
+ episode = self._get_episode_by_id(episode_id)
+ episode.delete()
+ pyotherside.send('deleted', episode_id)
+ pyotherside.send('update-stats')
+
@run_in_background_thread
def check_for_episodes(self):
if self._checking_for_new_episodes:
@@ -243,3 +255,4 @@ def show_episode(self, episode_id):
get_fresh_episodes = gpotherside.get_fresh_episodes
get_fresh_episodes_summary = gpotherside.get_fresh_episodes_summary
download_episode = gpotherside.download_episode
+delete_episode = gpotherside.delete_episode

0 comments on commit ef279bb

Please sign in to comment.