[BACKEND] epoch variables
This commit is contained in:
parent
7d29b72010
commit
30f0a69650
3 changed files with 40 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ from typing import final
|
||||||
|
|
||||||
from yt_dlp.utils import sanitize_filename
|
from yt_dlp.utils import sanitize_filename
|
||||||
|
|
||||||
from ytdl_sub.entries.variables.kwargs import DESCRIPTION
|
from ytdl_sub.entries.variables.kwargs import DESCRIPTION, EPOCH, EXTRACTOR
|
||||||
from ytdl_sub.entries.variables.kwargs import TITLE
|
from ytdl_sub.entries.variables.kwargs import TITLE
|
||||||
from ytdl_sub.entries.variables.kwargs import UID
|
from ytdl_sub.entries.variables.kwargs import UID
|
||||||
from ytdl_sub.entries.variables.kwargs import UPLOADER
|
from ytdl_sub.entries.variables.kwargs import UPLOADER
|
||||||
|
|
@ -18,6 +18,8 @@ from ytdl_sub.entries.variables.kwargs import UPLOADER_ID
|
||||||
from ytdl_sub.entries.variables.kwargs import UPLOADER_URL
|
from ytdl_sub.entries.variables.kwargs import UPLOADER_URL
|
||||||
from ytdl_sub.entries.variables.kwargs import WEBPAGE_URL
|
from ytdl_sub.entries.variables.kwargs import WEBPAGE_URL
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -58,7 +60,37 @@ class BaseEntryVariables:
|
||||||
str
|
str
|
||||||
The ytdl extractor name
|
The ytdl extractor name
|
||||||
"""
|
"""
|
||||||
return self.kwargs("extractor")
|
return self.kwargs(EXTRACTOR)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def epoch(self: "BaseEntry") -> int:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
int
|
||||||
|
The unix epoch of when the metadata was scraped by yt-dlp.
|
||||||
|
"""
|
||||||
|
return self.kwargs(EPOCH)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def epoch_date(self: "BaseEntry") -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
The epoch's date, in YYYYMMDD format.
|
||||||
|
"""
|
||||||
|
return datetime.utcfromtimestamp(self.epoch).strftime('%Y%m%d')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def epoch_hour(self: "BaseEntry") -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
The epoch's hour, padded
|
||||||
|
"""
|
||||||
|
return datetime.utcfromtimestamp(self.epoch).strftime('%H')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def title(self: "BaseEntry") -> str:
|
def title(self: "BaseEntry") -> str:
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ PLAYLIST_UPLOADER_ID = _("playlist_uploader_id")
|
||||||
PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
|
PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
|
||||||
|
|
||||||
UID = _("id")
|
UID = _("id")
|
||||||
|
EXTRACTOR = _("extractor")
|
||||||
|
EPOCH = _("epoch")
|
||||||
CHANNEL = _("channel")
|
CHANNEL = _("channel")
|
||||||
EXT = _("ext")
|
EXT = _("ext")
|
||||||
TITLE = _("title")
|
TITLE = _("title")
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,9 @@ def mock_entry_to_dict(
|
||||||
return {
|
return {
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
"uid_sanitized": uid,
|
"uid_sanitized": uid,
|
||||||
|
"epoch": 1596878400,
|
||||||
|
"epoch_date": "20200808",
|
||||||
|
"epoch_hour": "09",
|
||||||
"title": "entry {title}",
|
"title": "entry {title}",
|
||||||
"title_sanitized": "entry {title}",
|
"title_sanitized": "entry {title}",
|
||||||
"ext": ext,
|
"ext": ext,
|
||||||
|
|
@ -126,6 +129,7 @@ def mock_entry_kwargs(
|
||||||
):
|
):
|
||||||
return {
|
return {
|
||||||
"id": uid,
|
"id": uid,
|
||||||
|
"epoch": 1596878400,
|
||||||
"extractor": extractor,
|
"extractor": extractor,
|
||||||
"title": title,
|
"title": title,
|
||||||
"ext": ext,
|
"ext": ext,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue