ytdl_subscribe.ytdl_additions package

Submodules

ytdl_subscribe.ytdl_additions.enhanced_download_archive module

class ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadArchive

Bases: object

Class to handle any operations to the ytdl download archive. Try to keep it as barebones as possible in case of future changes.

contains(entry_id: str) bool
classmethod from_file(file_path: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadArchive
classmethod from_lines(lines: List[str]) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadArchive
remove_entry(entry_id: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadArchive
to_file(file_path: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadArchive
class ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMapping(upload_date: str, extractor: str, file_names: Set[str])

Bases: object

property dict: Dict[str, Any]

DownloadMapping as a dict that is serializable

Type

return

extractor: str
file_names: Set[str]
classmethod from_dict(mapping_dict: <property object at 0x7f7b567bc1d0>) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMapping
classmethod from_entry(entry: ytdl_subscribe.entries.entry.Entry) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMapping
upload_date: str
class ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMappings

Bases: object

add_entry(entry: ytdl_subscribe.entries.entry.Entry, entry_file_path: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMappings
property entry_ids: List[str]
classmethod from_file(json_file_path: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMappings
get_entries_out_of_range(date_range: yt_dlp.utils.DateRange) Dict[str, ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMapping]
Parameters

date_range – range of dates that entries’ upload dates must be within

Returns

dict of entry_id: mapping if the upload date is not in the date range

property is_empty: bool
remove_entry(entry_id: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMappings
to_download_archive() ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadArchive
to_file(output_json_file: str) ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMappings
class ytdl_subscribe.ytdl_additions.enhanced_download_archive.EnhancedDownloadArchive(subscription_name: str, working_directory: str, output_directory: str)

Bases: object

Maintains ytdl’s download archive file as well as create an additional mapping file to map ytdl ids to multiple files. Used to delete ‘stale’ files that are out of range based on the file’s entry’s upload date.

Should be used in this order:

  1. self.prepare_download_archive()

    Internally calls… a. self._load()

    • Checks the output directory to see if an existing enhanced download archive file exists. If so, load it into the class. Otherwise, initialize an empty instance of one.

    1. self._copy_to_working_directory()
      • If the download archive was loaded successfully, create a ytdl download archive in the working directory. This will let ytdl know which files are already downloaded.

  2. ( Perform the ytdlp download using a download archive with the same name )
    • An existing archive should have been copied into the working directory for reuse

  3. self.mapping.add_entry(entry, file_path)
    • Should be called for any file created for the given entry that gets moved to the output directory

  4. OPTIONAL: self.remove_stale_files()
    • After all files have been moved over in the output directory, remove any stale files that exist in there.

  5. self.save_download_archive()
    • Save the updated mapping file to the output directory.

  6. ( Delete the working directory )

property archive_file_name: str

The download archive’s file name (no path)

Type

return

property mapping: ytdl_subscribe.ytdl_additions.enhanced_download_archive.DownloadMappings
prepare_download_archive() ytdl_subscribe.ytdl_additions.enhanced_download_archive.EnhancedDownloadArchive
remove_stale_files(date_range: yt_dlp.utils.DateRange) ytdl_subscribe.ytdl_additions.enhanced_download_archive.EnhancedDownloadArchive
save_download_archive() ytdl_subscribe.ytdl_additions.enhanced_download_archive.EnhancedDownloadArchive

Module contents