Add generalized cover field for scobblable things
This commit is contained in:
20
vrobbler/apps/podcasts/migrations/0009_podcast_cover.py
Normal file
20
vrobbler/apps/podcasts/migrations/0009_podcast_cover.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 4.1.5 on 2023-03-22 22:26
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("podcasts", "0008_episode_genre"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="podcast",
|
||||
name="cover",
|
||||
field=models.ImageField(
|
||||
blank=True, null=True, upload_to="pdocasts/covers/"
|
||||
),
|
||||
),
|
||||
]
|
||||
@ -29,6 +29,7 @@ class Podcast(TimeStampedModel):
|
||||
)
|
||||
active = models.BooleanField(default=True)
|
||||
url = models.URLField(**BNULL)
|
||||
cover = models.ImageField(upload_to="pdocasts/covers/", **BNULL)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}"
|
||||
@ -53,6 +54,13 @@ class Episode(ScrobblableMixin):
|
||||
def info_link(self):
|
||||
return ""
|
||||
|
||||
@property
|
||||
def primary_image_url(self) -> str:
|
||||
url = ""
|
||||
if self.podcast.cover:
|
||||
url = self.podcast.cover.url
|
||||
return url
|
||||
|
||||
@classmethod
|
||||
def find_or_create(
|
||||
cls, podcast_dict: Dict, producer_dict: Dict, episode_dict: Dict
|
||||
|
||||
Reference in New Issue
Block a user