mkv bugfix from ffmpeg (#57)
* mkv bug from ffmpeg * always have working directory with entry
This commit is contained in:
parent
1d5992f93a
commit
4994e3685e
5 changed files with 18 additions and 14 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from abc import ABC
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class BaseEntry(ABC):
|
||||
|
|
@ -9,7 +8,7 @@ class BaseEntry(ABC):
|
|||
Abstract entry object to represent anything download from ytdl (playlist metadata, media, etc).
|
||||
"""
|
||||
|
||||
def __init__(self, entry_dict: Dict, working_directory: Optional[str] = None):
|
||||
def __init__(self, entry_dict: Dict, working_directory: str):
|
||||
"""
|
||||
Initialize the entry using ytdl metadata
|
||||
|
||||
|
|
@ -38,14 +37,5 @@ class BaseEntry(ABC):
|
|||
Returns
|
||||
-------
|
||||
The working directory
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
The working directory was never defined in the init
|
||||
"""
|
||||
if self._working_directory is None:
|
||||
raise ValueError(
|
||||
"Entry working directory is not set when trying to access its download file path"
|
||||
)
|
||||
return self._working_directory
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import os.path
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from ytdl_sub.entries.entry import Entry
|
||||
|
|
@ -9,6 +11,18 @@ 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
|
||||
|
||||
|
||||
class YoutubePlaylistVideo(YoutubeVideo):
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ def mock_entry_kwargs(
|
|||
|
||||
@pytest.fixture
|
||||
def mock_entry(mock_entry_kwargs):
|
||||
return Entry(entry_dict=mock_entry_kwargs)
|
||||
return Entry(entry_dict=mock_entry_kwargs, working_directory=".")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ def mock_soundcloud_track_kwargs(mock_entry_kwargs, url):
|
|||
|
||||
@pytest.fixture
|
||||
def mock_soundcloud_track(mock_soundcloud_track_kwargs):
|
||||
return SoundcloudTrack(entry_dict=mock_soundcloud_track_kwargs)
|
||||
return SoundcloudTrack(entry_dict=mock_soundcloud_track_kwargs, working_directory=".")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ def mock_youtube_video_kwargs(
|
|||
|
||||
@pytest.fixture
|
||||
def mock_youtube_video(mock_youtube_video_kwargs):
|
||||
return YoutubeVideo(entry_dict=mock_youtube_video_kwargs)
|
||||
return YoutubeVideo(entry_dict=mock_youtube_video_kwargs, working_directory=".")
|
||||
|
||||
|
||||
class TestYoutubeVideo(object):
|
||||
|
|
|
|||
Loading…
Reference in a new issue