2026-03-19 13:39:59 +01:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PodcastFeed(models.Model):
|
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='podcast_feeds')
|
|
|
|
|
rss_url = models.URLField(max_length=1000)
|
|
|
|
|
title = models.CharField(max_length=300)
|
|
|
|
|
description = models.TextField(blank=True)
|
|
|
|
|
artwork_url = models.URLField(max_length=1000, blank=True)
|
|
|
|
|
author = models.CharField(max_length=300, blank=True)
|
|
|
|
|
link = models.URLField(max_length=1000, blank=True)
|
|
|
|
|
last_refreshed_at = models.DateTimeField(null=True, blank=True)
|
|
|
|
|
added_at = models.DateTimeField(auto_now_add=True)
|
Add podcast enhancements: AntennaPod parity features + inbox management
- Auto-play next episode from queue when current episode ends
- Sleep timer (N minutes or end-of-episode) with countdown in button
- In-feed episode filter (client-side search)
- Auto-queue new episodes per feed (⚡Q toggle, inserts at top of queue)
- More playback speeds: 1¾× and 2½× added
- Progress bars + structured meta line in all episode list views (feed, inbox, queue)
- Queue drag-and-drop reorder
- Feed list search filter and sort options (A–Z, Z–A, recently added/refreshed)
- DB migration: PodcastFeed.auto_queue, EpisodeProgress.dismissed
- Inbox: dismiss episodes without marking played, checkboxes for multi-select,
bulk actions (add to queue, mark played, download, dismiss), load-more pagination
- Refresh button in single feed view header
- Hourly background refresh of all subscribed feeds
- Full Media Session API for radio and podcast: Windows taskbar thumbnail buttons
(play/pause/stop/next/seek) now work correctly for both modes
- Playing an episode auto-adds it to the queue if not already there
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 08:55:11 +01:00
|
|
|
auto_queue = models.BooleanField(default=False)
|
2026-03-19 13:39:59 +01:00
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
unique_together = ('user', 'rss_url')
|
|
|
|
|
ordering = ['title']
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PodcastEpisode(models.Model):
|
|
|
|
|
feed = models.ForeignKey(PodcastFeed, on_delete=models.CASCADE, related_name='episodes')
|
|
|
|
|
guid = models.CharField(max_length=1000)
|
|
|
|
|
title = models.CharField(max_length=500)
|
|
|
|
|
description = models.TextField(blank=True)
|
|
|
|
|
audio_url = models.URLField(max_length=1000)
|
|
|
|
|
duration_seconds = models.IntegerField(default=0)
|
|
|
|
|
pub_date = models.DateTimeField(null=True, blank=True)
|
|
|
|
|
episode_number = models.IntegerField(null=True, blank=True)
|
|
|
|
|
season_number = models.IntegerField(null=True, blank=True)
|
|
|
|
|
artwork_url = models.URLField(max_length=1000, blank=True)
|
|
|
|
|
discovered_at = models.DateTimeField(auto_now_add=True)
|
Podcasts: Kapitel, Shownotes und Transkripte für die Apps
- Feeds liefern jetzt Podlove-Kapitel (psc:chapters), Podcasting-2.0-Kapitel
(podcast:chapters, JSON-URL) und Transkripte (podcast:transcript, auch
mehrere); als Beschreibung wird content:encoded bevorzugt.
- Bekannte Folgen werden beim Aktualisieren nachgezogen, aber nur die Zeilen,
die sich wirklich geändert haben.
- Neuer Endpunkt GET /podcasts/episodes/<id>/ mit bereinigten Shownotes,
Zeitmarken, Kapiteln, Transkripten und Fortschritt. JSON-Kapitel werden
einmal serverseitig geholt (nur öffentliche Adressen, max. 1 MB) und an
der Folge gespeichert.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 07:56:44 +02:00
|
|
|
# Podcasting 2.0 <podcast:chapters url=…>: a JSON file, loaded on demand.
|
|
|
|
|
chapters_url = models.URLField(max_length=1000, blank=True)
|
|
|
|
|
# [{start: seconds, title, url?, img?}], from Podlove Simple Chapters in
|
|
|
|
|
# the feed, or the JSON at chapters_url once it has been fetched.
|
|
|
|
|
chapters = models.JSONField(default=list, blank=True)
|
|
|
|
|
# When chapters_url was fetched into `chapters`; null = not yet.
|
|
|
|
|
chapters_fetched_at = models.DateTimeField(null=True, blank=True)
|
|
|
|
|
# [{url, type, language}] from <podcast:transcript>.
|
|
|
|
|
transcripts = models.JSONField(default=list, blank=True)
|
2026-03-19 13:39:59 +01:00
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
unique_together = ('feed', 'guid')
|
|
|
|
|
ordering = ['-pub_date']
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
|
|
2026-10-02 08:26:28 +02:00
|
|
|
# An episode counts as played this close to its end (AntennaPod's default),
|
|
|
|
|
# the same rule as the apps' "als gehört zählen".
|
|
|
|
|
PLAYED_BEFORE_END_SECONDS = 30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def counts_as_played(position_seconds, duration_seconds):
|
|
|
|
|
return bool(duration_seconds) and duration_seconds > 0 and \
|
|
|
|
|
position_seconds >= max(duration_seconds - PLAYED_BEFORE_END_SECONDS, 1)
|
|
|
|
|
|
|
|
|
|
|
2026-03-19 13:39:59 +01:00
|
|
|
class EpisodeProgress(models.Model):
|
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='episode_progress')
|
|
|
|
|
episode = models.ForeignKey(PodcastEpisode, on_delete=models.CASCADE, related_name='progress')
|
|
|
|
|
position_seconds = models.IntegerField(default=0)
|
|
|
|
|
played = models.BooleanField(default=False)
|
Add podcast enhancements: AntennaPod parity features + inbox management
- Auto-play next episode from queue when current episode ends
- Sleep timer (N minutes or end-of-episode) with countdown in button
- In-feed episode filter (client-side search)
- Auto-queue new episodes per feed (⚡Q toggle, inserts at top of queue)
- More playback speeds: 1¾× and 2½× added
- Progress bars + structured meta line in all episode list views (feed, inbox, queue)
- Queue drag-and-drop reorder
- Feed list search filter and sort options (A–Z, Z–A, recently added/refreshed)
- DB migration: PodcastFeed.auto_queue, EpisodeProgress.dismissed
- Inbox: dismiss episodes without marking played, checkboxes for multi-select,
bulk actions (add to queue, mark played, download, dismiss), load-more pagination
- Refresh button in single feed view header
- Hourly background refresh of all subscribed feeds
- Full Media Session API for radio and podcast: Windows taskbar thumbnail buttons
(play/pause/stop/next/seek) now work correctly for both modes
- Playing an episode auto-adds it to the queue if not already there
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 08:55:11 +01:00
|
|
|
dismissed = models.BooleanField(default=False)
|
Podcasts: Favoriten, Folgenliste mit Filtern und Verlauf, Hörstatistik, OPML-Export
- EpisodeProgress.favorite (Migration 0006) und POST episodes/<id>/favorite/
(setzen oder umschalten; ändert updated_at nicht, damit Verlauf und
Statistik nicht verfälscht werden)
- GET episodes/: alle Folgen aller Abos, Filter all/unplayed/in_progress/
played/favorites/history, feed_id, q, offset/limit/total; zwei Abfragen
pro Seite, ohne Shownotes
- Folgendetails liefern zusätzlich favorite und last_played_at
- GET stats/: Hörzeit gesamt und pro Podcast, optional nur die letzten N Tage
- GET feeds/export.opml: Abos als OPML 2.0 (lässt sich wieder importieren)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 08:12:27 +02:00
|
|
|
favorite = models.BooleanField(default=False)
|
2026-03-19 13:39:59 +01:00
|
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
unique_together = ('user', 'episode')
|
|
|
|
|
ordering = ['-updated_at']
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return f'{self.user} - {self.episode}'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PodcastQueue(models.Model):
|
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='podcast_queue')
|
|
|
|
|
episode = models.ForeignKey(PodcastEpisode, on_delete=models.CASCADE, related_name='queued_by')
|
|
|
|
|
position = models.PositiveIntegerField(default=0)
|
|
|
|
|
added_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
unique_together = ('user', 'episode')
|
|
|
|
|
ordering = ['position']
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return f'{self.user} queue pos {self.position}: {self.episode}'
|
Podcasts: Position in der Warteschlange einstellbar; Feeds nur noch auf dem Server holen (SW v51)
Warteschlange
- PodcastSettings: wohin neue Folgen kommen, getrennt für Hinzufügen von
Hand (auch beim Abspielen einer Folge außerhalb der Warteschlange) und
für automatisch eingereihte neue Folgen: ans Ende, an den Anfang oder
nach die laufende Folge. Voreinstellung wie bisher (Hand: Ende,
automatisch: Anfang). GET/POST /podcasts/settings/.
- queue/add nimmt auch mehrere Folgen (episode_ids), eine Position
(where) und die laufende Folge (current_episode_id); ohne Angabe gilt
die zuletzt angehörte, nicht fertige Folge als laufende.
- Positionen werden lückenlos neu durchnummeriert.
Feeds
- POST /podcasts/feeds/refresh-all/ aktualisiert alle Feeds des Nutzers
auf dem Server: Downloads parallel, jede Feed-Adresse nur einmal (auch
über Nutzer hinweg), mit Timeout; kürzlich aktualisierte werden
übersprungen. Der stündliche Cron-Job nutzt dasselbe.
- GET /podcasts/state/ liefert Abos, Warteschlange, Inbox und
Einstellungen in einer Antwort (für die Apps).
- Web: „↻ All“ ist eine Anfrage statt einer pro Feed; die stündliche
Schleife im Browser lädt nur noch die Listen neu, statt jeden Feed
selbst anzustoßen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 07:26:16 +02:00
|
|
|
|
|
|
|
|
class PodcastSettings(models.Model):
|
|
|
|
|
"""A user's podcast preferences. Where episodes go in the queue: when added
|
|
|
|
|
by hand (also when played from outside the queue), and when a feed with
|
|
|
|
|
auto_queue brings new ones."""
|
|
|
|
|
BACK = 'back'
|
|
|
|
|
FRONT = 'front'
|
|
|
|
|
AFTER_CURRENT = 'after_current'
|
|
|
|
|
POSITIONS = [
|
|
|
|
|
(BACK, 'Ans Ende'),
|
|
|
|
|
(FRONT, 'An den Anfang'),
|
|
|
|
|
(AFTER_CURRENT, 'Nach der laufenden Folge'),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='podcast_settings')
|
|
|
|
|
enqueue_position = models.CharField(max_length=20, choices=POSITIONS, default=BACK)
|
|
|
|
|
# front = how auto-queue always worked before this setting existed
|
|
|
|
|
auto_queue_position = models.CharField(max_length=20, choices=POSITIONS, default=FRONT)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def for_user(cls, user):
|
|
|
|
|
obj, _ = cls.objects.get_or_create(user=user)
|
|
|
|
|
return obj
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return f'Podcast settings of {self.user}'
|