Skip to content

Feature/35 support chonological podcasts take2 #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/gpo
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,14 @@ class gPodderCli(object):

title, url, status = podcast.title, podcast.url, \
feed_update_status_msg(podcast)
strategy = 'episodic (newest first)' if podcast.download_strategy != podcast.STRATEGY_CHRONO else 'serial (oldest first)'
episodes = self._episodesList(podcast)
episodes = '\n '.join(episodes)
self._pager("""
Title: %(title)s
URL: %(url)s
Feed update is %(status)s
Feed Order: %(strategy)s

Episodes:
%(episodes)s
Expand Down Expand Up @@ -564,6 +566,7 @@ class gPodderCli(object):
return True

def _format_podcast(self, podcast):
strategy = '' if podcast.download_strategy != podcast.STRATEGY_CHRONO else '(serial)'
if not podcast.pause_subscription:
return ' '.join(('#', ingreen(podcast.title)))

Expand Down
15 changes: 9 additions & 6 deletions src/gpodder/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class PodcastChannel(PodcastModelFields, PodcastModelMixin):
UNICODE_TRANSLATE = {ord('ö'): 'o', ord('ä'): 'a', ord('ü'): 'u'}

# Enumerations for download strategy
STRATEGY_DEFAULT, STRATEGY_LATEST = list(range(2))
STRATEGY_DEFAULT, STRATEGY_LATEST, STRATEGY_CHRONO = list(range(3))

MAX_FOLDERNAME_LENGTH = 60
SECONDS_PER_WEEK = 7*24*60*60
Expand All @@ -507,7 +507,7 @@ def __init__(self, model):
if self.id:
self._children = sorted(self.db.load_episodes(self, self),
key=lambda e: (e.published, e.id),
reverse=True)
reverse=self.download_strategy != PodcastChannel.STRATEGY_CHRONO)
self._determine_common_prefix()

def one_line_description(self):
Expand Down Expand Up @@ -691,12 +691,14 @@ def _consume_updated_title(self, new_title):
if not self.title or self.title == self.url:
self.title = registry.podcast_title.resolve(self, new_title, new_title)

def _consume_metadata(self, title, link, description, cover_url, payment_url):
def _consume_metadata(self, title, link, description, cover_url, payment_url, type):
self._consume_updated_title(title)
self.link = link
self.description = description
self.cover_url = cover_url
self.payment_url = payment_url
if type == 'serial':
self.download_strategy = PodcastChannel.STRATEGY_CHRONO
self.save()

def _consume_custom_feed(self, custom_feed):
Expand All @@ -707,7 +709,8 @@ def _consume_custom_feed(self, custom_feed):
custom_feed.get_link(),
custom_feed.get_description(),
custom_feed.get_image(),
custom_feed.get_payment_url())
custom_feed.get_payment_url(),
custom_feed.get_type())

self.http_etag = custom_feed.get_etag(self.http_etag)
self.http_last_modified = custom_feed.get_modified(self.http_last_modified)
Expand Down Expand Up @@ -761,8 +764,8 @@ def _consume_custom_feed(self, custom_feed):
for episode in self.episodes:
self.model.core.cover_downloader.get_cover(self, download=True, episode=episode)

# Sort episodes by pubdate, descending
self.episodes.sort(key=lambda e: e.published, reverse=True)
# Sort episodes by pubdate, descending if default, ascending if chrono
self.episodes.sort(key=lambda e: e.published, reverse=self.download_strategy != PodcastChannel.STRATEGY_CHRONO)

def update(self):
if self._updating:
Expand Down
3 changes: 3 additions & 0 deletions src/gpodder/plugins/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def get_image(self):
def get_link(self):
return self.parsed.get('link', '')

def get_type(self):
return self.parsed.get('type', 'episodic')

def get_description(self):
return self.parsed.get('description', '')

Expand Down
7 changes: 5 additions & 2 deletions src/gpodder/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import minidb

from gpodder import model
from gpodder import model, STATE_DOWNLOADED, STATE_NORMAL
from gpodder import util

import json
Expand Down Expand Up @@ -102,7 +102,10 @@ def load_podcasts(self, *args):
return model.PodcastChannel.load(self.db)(*args)

def load_episodes(self, podcast, *args):
return model.PodcastEpisode.load(self.db, podcast_id=podcast.id)(*args)
# Don't load deleted podcasts
ifpodcast = (model.PodcastEpisode.c.podcast_id==podcast.id)
ifdown = ((model.PodcastEpisode.c.state==STATE_NORMAL) | (model.PodcastEpisode.c.state==STATE_DOWNLOADED))
return model.PodcastEpisode.load(self.db, ifpodcast & ifdown)(*args)

def commit(self):
self.db.commit()
Expand Down