Add thumbnail to release model

This commit is contained in:
Salt 2025-01-18 23:35:27 -06:00
parent 7c65af8a44
commit 25afd9c259
2 changed files with 28 additions and 7 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 5.1.5 on 2025-01-19 05:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('odyseescraper', '0002_alter_odyseerelease_id'),
]
operations = [
migrations.AddField(
model_name='odyseerelease',
name='thumbnail',
field=models.URLField(default='https://notadomain.notatld', max_length=512),
preserve_default=False,
),
]

View File

@ -15,13 +15,14 @@ class OdyseeChannel(models.Model):
releases = odysee.odysee_get_releases(self.handle)
for release in releases:
data = releases[release]
a = OdyseeRelease()
a.id = release
a.channel = self
a.name = data["title"]
a.description = data["description"]
a.url = data["url"]
a.save()
a = OdyseeRelease.objects.get_or_create(
id = release,
channel = self,
name = data['title'],
description = data['description'],
url = data['url'],
thumbnail = data['thumbnail']
)
except Exception as e:
print(f'Failed to get releases for this channel: {e}')
return
@ -32,3 +33,4 @@ class OdyseeRelease(models.Model):
name = models.CharField(max_length=1024)
description = models.TextField()
url = models.URLField(max_length=512)
thumbnail = models.URLField(max_length=512)