also playlist index reversed
This commit is contained in:
parent
30f0a69650
commit
0f999cddb3
3 changed files with 39 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from abc import ABC
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
|
|
@ -10,7 +11,9 @@ from typing import final
|
|||
|
||||
from yt_dlp.utils import sanitize_filename
|
||||
|
||||
from ytdl_sub.entries.variables.kwargs import DESCRIPTION, EPOCH, EXTRACTOR
|
||||
from ytdl_sub.entries.variables.kwargs import DESCRIPTION
|
||||
from ytdl_sub.entries.variables.kwargs import EPOCH
|
||||
from ytdl_sub.entries.variables.kwargs import EXTRACTOR
|
||||
from ytdl_sub.entries.variables.kwargs import TITLE
|
||||
from ytdl_sub.entries.variables.kwargs import UID
|
||||
from ytdl_sub.entries.variables.kwargs import UPLOADER
|
||||
|
|
@ -18,8 +21,6 @@ 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 WEBPAGE_URL
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ class BaseEntryVariables:
|
|||
str
|
||||
The epoch's date, in YYYYMMDD format.
|
||||
"""
|
||||
return datetime.utcfromtimestamp(self.epoch).strftime('%Y%m%d')
|
||||
return datetime.utcfromtimestamp(self.epoch).strftime("%Y%m%d")
|
||||
|
||||
@property
|
||||
def epoch_hour(self: "BaseEntry") -> str:
|
||||
|
|
@ -90,7 +91,7 @@ class BaseEntryVariables:
|
|||
str
|
||||
The epoch's hour, padded
|
||||
"""
|
||||
return datetime.utcfromtimestamp(self.epoch).strftime('%H')
|
||||
return datetime.utcfromtimestamp(self.epoch).strftime("%H")
|
||||
|
||||
@property
|
||||
def title(self: "BaseEntry") -> str:
|
||||
|
|
|
|||
|
|
@ -169,6 +169,16 @@ class EntryVariables(BaseEntryVariables):
|
|||
"""
|
||||
return self.kwargs_get(PLAYLIST_INDEX, 1)
|
||||
|
||||
@property
|
||||
def playlist_index_reversed(self: Self) -> int:
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
int
|
||||
Playlist index reversed via ``playlist_count - playlist_index + 1``
|
||||
"""
|
||||
return self.playlist_count - self.playlist_index + 1
|
||||
|
||||
@property
|
||||
def playlist_index_padded(self: Self) -> str:
|
||||
"""
|
||||
|
|
@ -179,6 +189,16 @@ class EntryVariables(BaseEntryVariables):
|
|||
"""
|
||||
return _pad(self.playlist_index, width=2)
|
||||
|
||||
@property
|
||||
def playlist_index_reversed_padded(self: Self) -> str:
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
str
|
||||
playlist_index_reversed padded two digits
|
||||
"""
|
||||
return _pad(self.playlist_index_reversed, width=2)
|
||||
|
||||
@property
|
||||
def playlist_index_padded6(self: Self) -> str:
|
||||
"""
|
||||
|
|
@ -189,6 +209,16 @@ class EntryVariables(BaseEntryVariables):
|
|||
"""
|
||||
return _pad(self.playlist_index, width=6)
|
||||
|
||||
@property
|
||||
def playlist_index_reversed_padded6(self: Self) -> str:
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
str
|
||||
playlist_index_reversed padded six digits.
|
||||
"""
|
||||
return _pad(self.playlist_index_reversed, width=6)
|
||||
|
||||
@property
|
||||
def playlist_count(self: Self) -> int:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ def mock_entry_to_dict(
|
|||
"playlist_index": 1,
|
||||
"playlist_index_padded": "01",
|
||||
"playlist_index_padded6": "000001",
|
||||
"playlist_index_reversed": 1,
|
||||
"playlist_index_reversed_padded": "01",
|
||||
"playlist_index_reversed_padded6": "000001",
|
||||
"playlist_count": 1,
|
||||
"playlist_max_upload_year": 2021,
|
||||
"playlist_max_upload_year_truncated": 21,
|
||||
|
|
|
|||
Loading…
Reference in a new issue