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)
|
releases = odysee.odysee_get_releases(self.handle)
|
||||||
for release in releases:
|
for release in releases:
|
||||||
data = releases[release]
|
data = releases[release]
|
||||||
a = OdyseeRelease()
|
a = OdyseeRelease.objects.get_or_create(
|
||||||
a.id = release
|
id = release,
|
||||||
a.channel = self
|
channel = self,
|
||||||
a.name = data["title"]
|
name = data['title'],
|
||||||
a.description = data["description"]
|
description = data['description'],
|
||||||
a.url = data["url"]
|
url = data['url'],
|
||||||
a.save()
|
thumbnail = data['thumbnail']
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Failed to get releases for this channel: {e}')
|
print(f'Failed to get releases for this channel: {e}')
|
||||||
return
|
return
|
||||||
@ -32,3 +33,4 @@ class OdyseeRelease(models.Model):
|
|||||||
name = models.CharField(max_length=1024)
|
name = models.CharField(max_length=1024)
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
url = models.URLField(max_length=512)
|
url = models.URLField(max_length=512)
|
||||||
|
thumbnail = models.URLField(max_length=512)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user