diff --git a/odyseescraper/migrations/0003_odyseerelease_thumbnail.py b/odyseescraper/migrations/0003_odyseerelease_thumbnail.py new file mode 100644 index 0000000..4935b53 --- /dev/null +++ b/odyseescraper/migrations/0003_odyseerelease_thumbnail.py @@ -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, + ), + ] diff --git a/odyseescraper/models.py b/odyseescraper/models.py index 681cb97..d43fb2a 100644 --- a/odyseescraper/models.py +++ b/odyseescraper/models.py @@ -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)