Add thumbnail to release model
This commit is contained in:
parent
7c65af8a44
commit
25afd9c259
19
odyseescraper/migrations/0003_odyseerelease_thumbnail.py
Normal file
19
odyseescraper/migrations/0003_odyseerelease_thumbnail.py
Normal 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,
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user