diora-web/gpodder/models.py
marwin 824b77a033
All checks were successful
Build and push Docker image / build (push) Successful in 15s
Test / test (push) Successful in 17s
Add gPodder sync API and bump SW cache to v5
- Implement gPodder API v2 compatible endpoints at /api/2/:
  - Auth: login/logout via HTTP Basic Auth or session
  - Devices: list and register sync devices
  - Subscriptions: get/add/remove per device, delta sync with ?since=
  - Episode actions: upload play/position events, syncs to EpisodeProgress
- Server URL for AntennaPod: https://diora.creamfresh.xyz/api/2/
- Bump SW cache diora-v4 → v5 to force re-fetch of updated app.js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 06:36:41 +01:00

47 lines
1.7 KiB
Python

from django.db import models
from django.contrib.auth.models import User
class GpodderDevice(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='gpodder_devices')
device_id = models.CharField(max_length=64)
caption = models.CharField(max_length=100, blank=True)
type = models.CharField(max_length=20, default='other')
updated_at = models.DateTimeField(auto_now=True)
class Meta:
unique_together = ('user', 'device_id')
def __str__(self):
return f"{self.user.username}/{self.device_id}"
class GpodderSubscriptionChange(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='gpodder_sub_changes')
url = models.URLField(max_length=1000)
action = models.CharField(max_length=6) # 'add' or 'remove'
timestamp = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['timestamp']
def __str__(self):
return f"{self.action} {self.url} ({self.user.username})"
class GpodderEpisodeAction(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='gpodder_episode_actions')
device = models.ForeignKey(GpodderDevice, on_delete=models.SET_NULL, null=True, blank=True)
podcast = models.URLField(max_length=1000)
episode = models.URLField(max_length=1000)
action = models.CharField(max_length=10) # play, download, delete, new
timestamp = models.DateTimeField()
started = models.IntegerField(null=True, blank=True)
position = models.IntegerField(null=True, blank=True)
total = models.IntegerField(null=True, blank=True)
class Meta:
ordering = ['-timestamp']
def __str__(self):
return f"{self.action} {self.episode} ({self.user.username})"