diff --git a/odyseescraper/admin.py b/odyseescraper/admin.py index 7882482..c1a82a8 100644 --- a/odyseescraper/admin.py +++ b/odyseescraper/admin.py @@ -11,10 +11,10 @@ class OdyseeChannelAdmin(admin.ModelAdmin): @admin.register(OdyseeRelease) class OdyseeReleaseAdmin(admin.ModelAdmin): - list_display = ['name', 'channel', 'url', 'id'] + list_display = ['name', 'channel', 'released', 'url', 'id'] search_fields = ['name', 'url'] - ordering = ['channel', 'name'] - list_filter = ['channel', 'tags'] + ordering = ['channel', 'name', 'released'] + list_filter = ['channel', 'tags', 'released'] @admin.register(Tag) class TagAdmin(admin.ModelAdmin): diff --git a/odyseescraper/management/commands/odyseescrape.py b/odyseescraper/management/commands/odyseescrape.py index d791b38..14f8f5f 100644 --- a/odyseescraper/management/commands/odyseescrape.py +++ b/odyseescraper/management/commands/odyseescrape.py @@ -1,6 +1,7 @@ #! /usr/bin/env python3 -import uuid +import datetime import odyseescraper +import uuid from django.core.management.base import BaseCommand, CommandError from django.db import models @@ -24,6 +25,7 @@ class Command(BaseCommand): channel = channel, name = data['title'], description = data['description'], + released = datetime.datetime.utcfromtimestamp(int(data['publishdate'])).strftime("%Y-%m-%d"), url = data['url'], thumbnail = data['thumbnail'], ) diff --git a/odyseescraper/models.py b/odyseescraper/models.py index f4a642f..d866e14 100644 --- a/odyseescraper/models.py +++ b/odyseescraper/models.py @@ -25,6 +25,7 @@ class OdyseeRelease(models.Model): channel = models.ForeignKey(OdyseeChannel, on_delete=models.CASCADE, db_index=True) name = models.CharField(max_length=1024) description = models.TextField() + released = models.DateField() url = models.URLField(max_length=512) thumbnail = models.URLField(max_length=512) diff --git a/odyseescraper/odysee.py b/odyseescraper/odysee.py index 472975a..28924be 100644 --- a/odyseescraper/odysee.py +++ b/odyseescraper/odysee.py @@ -48,7 +48,7 @@ def odysee_get_releases(handle): "name": item.get("name", "Unnamed Release"), "title": item["value"].get("title", "Untitled Release"), # This field is an int in unixtime - "publishdate": item["value"].get("release_time", 0), + "publishdate": int(item["value"].get("release_time", 0)), "description": item["value"].get("description", "No description provided for this release"), "thumbnail": item["value"].get("thumbnail", {}).get("url", ""), "url": f"{odysee_get_channel_url(handle)}/{item['name']}"