all downloaders seem to be working
This commit is contained in:
parent
77c2cce739
commit
4ef6898e05
8 changed files with 66 additions and 38 deletions
|
|
@ -33,7 +33,6 @@ presets:
|
||||||
ignoreerrors: True
|
ignoreerrors: True
|
||||||
output_options:
|
output_options:
|
||||||
file_name: "{sanitized_artist} - {sanitized_title}.{ext}"
|
file_name: "{sanitized_artist} - {sanitized_title}.{ext}"
|
||||||
convert_thumbnail: "jpeg"
|
|
||||||
thumbnail_name: "{sanitized_artist} - {sanitized_title}.jpg"
|
thumbnail_name: "{sanitized_artist} - {sanitized_title}.jpg"
|
||||||
convert_thumbnail:
|
convert_thumbnail:
|
||||||
to: "jpg"
|
to: "jpg"
|
||||||
|
|
@ -53,7 +52,6 @@ presets:
|
||||||
ignoreerrors: True
|
ignoreerrors: True
|
||||||
output_options:
|
output_options:
|
||||||
file_name: "{output_file_name}.{ext}"
|
file_name: "{output_file_name}.{ext}"
|
||||||
convert_thumbnail: "jpeg"
|
|
||||||
thumbnail_name: "{output_file_name}.jpg"
|
thumbnail_name: "{output_file_name}.jpg"
|
||||||
convert_thumbnail:
|
convert_thumbnail:
|
||||||
to: "jpg"
|
to: "jpg"
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
# artist: "DeLorra"
|
# artist: "DeLorra"
|
||||||
# genre: "Synthwave / Electronic"
|
# genre: "Synthwave / Electronic"
|
||||||
#
|
#
|
||||||
bl00dwave:
|
#bl00dwave:
|
||||||
preset: "soundcloud_with_id3_tags"
|
# preset: "soundcloud_with_id3_tags"
|
||||||
soundcloud:
|
# soundcloud:
|
||||||
username: bl00dwave
|
# username: bl00dwave
|
||||||
overrides:
|
# overrides:
|
||||||
artist: "bl00dwave"
|
# artist: "bl00dwave"
|
||||||
genre: "Synthwave / Electronic"
|
# genre: "Synthwave / Electronic"
|
||||||
#
|
#
|
||||||
#tom_petty:
|
#tom_petty:
|
||||||
# preset: "music_videos"
|
# preset: "music_videos"
|
||||||
|
|
@ -56,15 +56,17 @@ bl00dwave:
|
||||||
# overrides:
|
# overrides:
|
||||||
# artist: "The Gogos"
|
# artist: "The Gogos"
|
||||||
|
|
||||||
#recent_channel_test:
|
recent_channel_test:
|
||||||
# preset: "yt_channel"
|
preset: "yt_channel"
|
||||||
# ytdl_options:
|
ytdl_options:
|
||||||
# break_on_reject: True
|
break_on_reject: True
|
||||||
# youtube:
|
youtube:
|
||||||
# download_strategy: "channel"
|
download_strategy: "channel"
|
||||||
# channel_id: "UCRcCVDu_4oARsAKFkKYydAQ"
|
channel_id: "UCsvn_Po0SmunchJYOWpOxMg"
|
||||||
# after: today-2days
|
after: today-13days
|
||||||
# output_options:
|
output_options:
|
||||||
# output_directory: "/tmp/dunkey"
|
output_directory: "/tmp/dunkey"
|
||||||
# overrides:
|
keep_files:
|
||||||
# tv_show_name: "Youtube: Dunkey"
|
after: today-3days
|
||||||
|
overrides:
|
||||||
|
tv_show_name: "Youtube: Dunkey"
|
||||||
|
|
@ -52,7 +52,7 @@ class OutputOptions(StrictDictValidator):
|
||||||
_optional_keys = {
|
_optional_keys = {
|
||||||
"thumbnail_name",
|
"thumbnail_name",
|
||||||
"maintain_download_archive",
|
"maintain_download_archive",
|
||||||
"maintain_stale_file_deletion",
|
"keep_files",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, name, value):
|
def __init__(self, name, value):
|
||||||
|
|
@ -75,11 +75,11 @@ class OutputOptions(StrictDictValidator):
|
||||||
self.maintain_download_archive = self._validate_key_if_present(
|
self.maintain_download_archive = self._validate_key_if_present(
|
||||||
key="maintain_download_archive", validator=BoolValidator, default=False
|
key="maintain_download_archive", validator=BoolValidator, default=False
|
||||||
)
|
)
|
||||||
self.maintain_stale_file_deletion = self._validate_key_if_present(
|
self.delete_stale_files = self._validate_key_if_present(
|
||||||
key="maintain_stale_file_deletion", validator=DateRangeValidator
|
key="keep_files", validator=DateRangeValidator
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.maintain_stale_file_deletion and not self.maintain_download_archive:
|
if self.delete_stale_files and not self.maintain_download_archive:
|
||||||
raise self._validation_exception(
|
raise self._validation_exception(
|
||||||
"maintain_stale_file_deletion requires maintain_download_archive set to True"
|
"keep_files requires maintain_download_archive set to True"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
import os.path
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from ytdl_subscribe.entries.entry import Entry
|
from ytdl_subscribe.entries.entry import Entry
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -17,3 +20,26 @@ class YoutubeVideo(Entry):
|
||||||
return self.kwargs("track")
|
return self.kwargs("track")
|
||||||
|
|
||||||
return super().title
|
return super().title
|
||||||
|
|
||||||
|
@property
|
||||||
|
def download_thumbnail_path(self) -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
The entry's thumbnail's file path to where it was downloaded. Ytdl has a bug where the
|
||||||
|
thumbnail entry is not the actual thumbnail it downloaded. So check all the possible
|
||||||
|
extensions that it may have downloaded, and see if that thumbnail's extension exists.
|
||||||
|
|
||||||
|
TODO: move this into the init so the thumbnail_ext variable can be set accordingly
|
||||||
|
"""
|
||||||
|
thumbnails = self.kwargs("thumbnails")
|
||||||
|
possible_thumbnail_exts = set()
|
||||||
|
for thumbnail in thumbnails:
|
||||||
|
possible_thumbnail_exts.add(thumbnail["url"].split(".")[-1])
|
||||||
|
|
||||||
|
for ext in possible_thumbnail_exts:
|
||||||
|
possible_thumbnail_path = str(Path(self.working_directory) / f"{self.uid}.{ext}")
|
||||||
|
if os.path.isfile(possible_thumbnail_path):
|
||||||
|
return possible_thumbnail_path
|
||||||
|
|
||||||
|
return super().download_thumbnail_path
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import dicttoxml
|
import dicttoxml
|
||||||
|
|
@ -53,6 +54,7 @@ class NfoTagsPlugin(Plugin[NfoTagsOptions]):
|
||||||
|
|
||||||
# Save the nfo's XML to file
|
# Save the nfo's XML to file
|
||||||
nfo_file_path = Path(self.output_directory) / nfo_file_name
|
nfo_file_path = Path(self.output_directory) / nfo_file_name
|
||||||
|
os.makedirs(os.path.dirname(nfo_file_path), exist_ok=True)
|
||||||
with open(nfo_file_path, "wb") as nfo_file:
|
with open(nfo_file_path, "wb") as nfo_file:
|
||||||
nfo_file.write(xml)
|
nfo_file.write(xml)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import dicttoxml
|
import dicttoxml
|
||||||
|
|
@ -53,5 +54,6 @@ class OutputDirectoryNfoTagsPlugin(Plugin[OutputDirectoryNfoTagsOptions]):
|
||||||
|
|
||||||
# Save the nfo's XML to file
|
# Save the nfo's XML to file
|
||||||
nfo_file_path = Path(self.output_directory) / nfo_file_name
|
nfo_file_path = Path(self.output_directory) / nfo_file_name
|
||||||
|
os.makedirs(os.path.dirname(nfo_file_path), exist_ok=True)
|
||||||
with open(nfo_file_path, "wb") as nfo_file:
|
with open(nfo_file_path, "wb") as nfo_file:
|
||||||
nfo_file.write(xml)
|
nfo_file.write(xml)
|
||||||
|
|
|
||||||
|
|
@ -134,21 +134,20 @@ class Subscription:
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _maintain_archive_file(self):
|
def _maintain_archive_file(self):
|
||||||
if not self.output_options.maintain_download_archive:
|
if self.output_options.maintain_download_archive:
|
||||||
return
|
self._enhanced_download_archive.prepare_download_archive()
|
||||||
|
|
||||||
self._enhanced_download_archive.prepare_download_archive()
|
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
# If output options maintains stale file deletion, perform the delete here prior to saving
|
# If output options maintains stale file deletion, perform the delete here prior to saving
|
||||||
# the download archive
|
# the download archive
|
||||||
if self.output_options.maintain_stale_file_deletion:
|
if self.output_options.maintain_download_archive:
|
||||||
self._enhanced_download_archive.remove_stale_files(
|
if self.output_options.delete_stale_files:
|
||||||
date_range=self.output_options.maintain_stale_file_deletion.get_date_range()
|
self._enhanced_download_archive.remove_stale_files(
|
||||||
)
|
date_range=self.output_options.delete_stale_files.get_date_range()
|
||||||
|
)
|
||||||
|
|
||||||
self._enhanced_download_archive.save_download_archive()
|
self._enhanced_download_archive.save_download_archive()
|
||||||
|
|
||||||
def _initialize_plugins(self) -> List[Plugin]:
|
def _initialize_plugins(self) -> List[Plugin]:
|
||||||
plugins: List[Plugin] = []
|
plugins: List[Plugin] = []
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
from abc import ABC
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from yt_dlp import DateRange
|
from yt_dlp import DateRange
|
||||||
|
|
@ -7,8 +6,8 @@ from ytdl_subscribe.validators.strict_dict_validator import StrictDictValidator
|
||||||
from ytdl_subscribe.validators.string_datetime import StringDatetimeValidator
|
from ytdl_subscribe.validators.string_datetime import StringDatetimeValidator
|
||||||
|
|
||||||
|
|
||||||
class DateRangeValidator(StrictDictValidator, ABC):
|
class DateRangeValidator(StrictDictValidator):
|
||||||
optional_keys = {"before", "after"}
|
_optional_keys = {"before", "after"}
|
||||||
|
|
||||||
def __init__(self, name, value):
|
def __init__(self, name, value):
|
||||||
super().__init__(name, value)
|
super().__init__(name, value)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue