Timestamp every release
This commit is contained in:
parent
b5e2a6530d
commit
e058faf49e
@ -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):
|
||||
|
@ -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'],
|
||||
)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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']}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user