Timestamp every release
This commit is contained in:
parent
b5e2a6530d
commit
e058faf49e
@ -11,10 +11,10 @@ class OdyseeChannelAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.register(OdyseeRelease)
|
@admin.register(OdyseeRelease)
|
||||||
class OdyseeReleaseAdmin(admin.ModelAdmin):
|
class OdyseeReleaseAdmin(admin.ModelAdmin):
|
||||||
list_display = ['name', 'channel', 'url', 'id']
|
list_display = ['name', 'channel', 'released', 'url', 'id']
|
||||||
search_fields = ['name', 'url']
|
search_fields = ['name', 'url']
|
||||||
ordering = ['channel', 'name']
|
ordering = ['channel', 'name', 'released']
|
||||||
list_filter = ['channel', 'tags']
|
list_filter = ['channel', 'tags', 'released']
|
||||||
|
|
||||||
@admin.register(Tag)
|
@admin.register(Tag)
|
||||||
class TagAdmin(admin.ModelAdmin):
|
class TagAdmin(admin.ModelAdmin):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
import uuid
|
import datetime
|
||||||
import odyseescraper
|
import odyseescraper
|
||||||
|
import uuid
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ class Command(BaseCommand):
|
|||||||
channel = channel,
|
channel = channel,
|
||||||
name = data['title'],
|
name = data['title'],
|
||||||
description = data['description'],
|
description = data['description'],
|
||||||
|
released = datetime.datetime.utcfromtimestamp(int(data['publishdate'])).strftime("%Y-%m-%d"),
|
||||||
url = data['url'],
|
url = data['url'],
|
||||||
thumbnail = data['thumbnail'],
|
thumbnail = data['thumbnail'],
|
||||||
)
|
)
|
||||||
|
@ -25,6 +25,7 @@ class OdyseeRelease(models.Model):
|
|||||||
channel = models.ForeignKey(OdyseeChannel, on_delete=models.CASCADE, db_index=True)
|
channel = models.ForeignKey(OdyseeChannel, on_delete=models.CASCADE, db_index=True)
|
||||||
name = models.CharField(max_length=1024)
|
name = models.CharField(max_length=1024)
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
|
released = models.DateField()
|
||||||
url = models.URLField(max_length=512)
|
url = models.URLField(max_length=512)
|
||||||
thumbnail = 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"),
|
"name": item.get("name", "Unnamed Release"),
|
||||||
"title": item["value"].get("title", "Untitled Release"),
|
"title": item["value"].get("title", "Untitled Release"),
|
||||||
# This field is an int in unixtime
|
# 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"),
|
"description": item["value"].get("description", "No description provided for this release"),
|
||||||
"thumbnail": item["value"].get("thumbnail", {}).get("url", ""),
|
"thumbnail": item["value"].get("thumbnail", {}).get("url", ""),
|
||||||
"url": f"{odysee_get_channel_url(handle)}/{item['name']}"
|
"url": f"{odysee_get_channel_url(handle)}/{item['name']}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user