merge
This commit is contained in:
parent
8edca7af36
commit
3a37138ce6
7 changed files with 34 additions and 133 deletions
|
|
@ -15,6 +15,18 @@ class Entry(EntryVariables, BaseEntry):
|
||||||
Entry object to represent a single media object returned from yt-dlp.
|
Entry object to represent a single media object returned from yt-dlp.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ext(self) -> str:
|
||||||
|
"""
|
||||||
|
With ffmpeg installed, yt-dlp will sometimes merge the file into an mkv file.
|
||||||
|
This is not reflected in the entry. See if the mkv file exists and return "mkv" if so,
|
||||||
|
otherwise, return the original extension.
|
||||||
|
"""
|
||||||
|
mkv_file_path = str(Path(self.working_directory()) / f"{self.uid}.mkv")
|
||||||
|
if os.path.isfile(mkv_file_path):
|
||||||
|
return "mkv"
|
||||||
|
return super().ext
|
||||||
|
|
||||||
def get_download_file_name(self) -> str:
|
def get_download_file_name(self) -> str:
|
||||||
"""
|
"""
|
||||||
Returns
|
Returns
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
from ytdl_sub.entries.entry import Entry
|
|
||||||
from ytdl_sub.entries.variables.soundcloud_variables import SoundcloudVariables
|
|
||||||
|
|
||||||
# TODO: Delete since not used
|
|
||||||
|
|
||||||
|
|
||||||
class SoundcloudTrack(SoundcloudVariables, Entry):
|
|
||||||
"""
|
|
||||||
Entry object to represent a Soundcloud track yt-dlp that is a single, which implies
|
|
||||||
it does not belong to an album.
|
|
||||||
"""
|
|
||||||
|
|
@ -4,7 +4,7 @@ from yt_dlp.utils import sanitize_filename
|
||||||
|
|
||||||
from ytdl_sub.entries.base_entry import BaseEntry
|
from ytdl_sub.entries.base_entry import BaseEntry
|
||||||
from ytdl_sub.entries.base_entry import BaseEntryVariables
|
from ytdl_sub.entries.base_entry import BaseEntryVariables
|
||||||
from ytdl_sub.entries.variables.kwargs import EXT
|
from ytdl_sub.entries.variables.kwargs import EXT, CHANNEL
|
||||||
from ytdl_sub.entries.variables.kwargs import PLAYLIST_COUNT
|
from ytdl_sub.entries.variables.kwargs import PLAYLIST_COUNT
|
||||||
from ytdl_sub.entries.variables.kwargs import PLAYLIST_DESCRIPTION
|
from ytdl_sub.entries.variables.kwargs import PLAYLIST_DESCRIPTION
|
||||||
from ytdl_sub.entries.variables.kwargs import PLAYLIST_INDEX
|
from ytdl_sub.entries.variables.kwargs import PLAYLIST_INDEX
|
||||||
|
|
@ -304,6 +304,26 @@ class EntryVariables(BaseEntryVariables):
|
||||||
"""
|
"""
|
||||||
return self.kwargs_get(SOURCE_UPLOADER_URL, self.source_webpage_url)
|
return self.kwargs_get(SOURCE_UPLOADER_URL, self.source_webpage_url)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def channel(self: Self) -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
The channel name if it exists, otherwise returns the uploader.
|
||||||
|
"""
|
||||||
|
return self.kwargs_get(CHANNEL, self.uploader)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def channel_sanitized(self: Self) -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
The channel name, sanitized.
|
||||||
|
"""
|
||||||
|
return sanitize_filename(self.channel)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ext(self: Self) -> str:
|
def ext(self: Self) -> str:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ PLAYLIST_UPLOADER_ID = _("playlist_uploader_id")
|
||||||
PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
|
PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
|
||||||
|
|
||||||
UID = _("id")
|
UID = _("id")
|
||||||
|
CHANNEL = _("channel")
|
||||||
EXT = _("ext")
|
EXT = _("ext")
|
||||||
TITLE = _("title")
|
TITLE = _("title")
|
||||||
DESCRIPTION = _("description")
|
DESCRIPTION = _("description")
|
||||||
|
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
from yt_dlp.utils import sanitize_filename
|
|
||||||
|
|
||||||
from ytdl_sub.entries.variables.entry_variables import EntryVariables
|
|
||||||
|
|
||||||
# This file contains mixins to a BaseEntry subclass. Ignore pylint's "no kwargs member" suggestion
|
|
||||||
# pylint: disable=no-member
|
|
||||||
|
|
||||||
|
|
||||||
class SoundcloudVariables(EntryVariables):
|
|
||||||
@property
|
|
||||||
def track_number(self) -> int:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
int
|
|
||||||
The entry's track number within an album. For singles, it will always be 1.
|
|
||||||
"""
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@property
|
|
||||||
def track_number_padded(self) -> str:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's track number, padded two digits.
|
|
||||||
"""
|
|
||||||
return f"{self.track_number:02d}"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def track_count(self) -> int:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
int
|
|
||||||
The total tracks in album. For singles, it will always be 1.
|
|
||||||
"""
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@property
|
|
||||||
def album(self) -> str:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's album name. For singles, it will be the same as the title.
|
|
||||||
"""
|
|
||||||
return self.title
|
|
||||||
|
|
||||||
@property
|
|
||||||
def album_sanitized(self) -> str:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's sanitized album name, which is safe to use for Unix and Windows file names.
|
|
||||||
"""
|
|
||||||
return sanitize_filename(self.album)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def album_year(self) -> int:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
int
|
|
||||||
The entry's album year, which is determined by the latest year amongst all tracks in the
|
|
||||||
album.
|
|
||||||
"""
|
|
||||||
return self.upload_year
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
from yt_dlp.utils import sanitize_filename
|
|
||||||
|
|
||||||
from ytdl_sub.entries.base_entry import BaseEntry
|
|
||||||
from ytdl_sub.entries.variables.entry_variables import EntryVariables
|
|
||||||
|
|
||||||
# This file contains mixins to a BaseEntry subclass. Ignore pylint's "no kwargs member" suggestion
|
|
||||||
# pylint: disable=no-member
|
|
||||||
|
|
||||||
|
|
||||||
class YoutubeVideoVariables(EntryVariables):
|
|
||||||
@property
|
|
||||||
def channel(self: BaseEntry) -> str:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
str
|
|
||||||
The channel name.
|
|
||||||
"""
|
|
||||||
return self.kwargs("channel")
|
|
||||||
|
|
||||||
@property
|
|
||||||
def channel_sanitized(self) -> str:
|
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
str
|
|
||||||
The channel name, sanitized.
|
|
||||||
"""
|
|
||||||
return sanitize_filename(self.channel)
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import os.path
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from ytdl_sub.entries.entry import Entry
|
|
||||||
from ytdl_sub.entries.variables.youtube_variables import YoutubeVideoVariables
|
|
||||||
|
|
||||||
|
|
||||||
class YoutubeVideo(YoutubeVideoVariables, Entry):
|
|
||||||
"""
|
|
||||||
Entry object to represent a Youtube video. Reserved for shared Youtube entry logic.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@property
|
|
||||||
def ext(self) -> str:
|
|
||||||
"""
|
|
||||||
With ffmpeg installed, yt-dlp will sometimes merge the file into an mkv file.
|
|
||||||
This is not reflected in the entry. See if the mkv file exists and return "mkv" if so,
|
|
||||||
otherwise, return the original extension.
|
|
||||||
"""
|
|
||||||
mkv_file_path = str(Path(self.working_directory()) / f"{self.uid}.mkv")
|
|
||||||
if os.path.isfile(mkv_file_path):
|
|
||||||
return "mkv"
|
|
||||||
return super().ext
|
|
||||||
Loading…
Reference in a new issue