Source

ytb_downloader.file_loader

Load information from csv file for bulk downloading and converting.

columns_validation(columns: Sequence[str]) Optional[List[str]][source]

Validate columns of dataframe read from csv file.

To make sure the requisite column url exists, and find out existed optional columns, such as “format”, “time_start”, “time_end”, “bitrate”.

Parameters

columns (list of str) – column names of dataframe read from csv file.

Returns

return None if “url” is not included in the columns; otherwise return the list of existed optional columns.

Return type

None or list of str

load_file(file_path: str) Tuple[List[str], List[Dict]][source]

Load information from csv file for downloading video function and converting video function.

Parameters

file_path (str) – path to the csv file containing information for downloading video function and converting video function.

Returns

urls for downloading videos as a list and converting function params as a list of dictionaries.

Return type

tuple (list of str and list of dict)

ytb_downloader.file_name_collector

Extracting downloaded files’ names.

class FileNameCollectorPP[source]

Collect file names from the yt_dlp for downloaded videos as an post processing step.

file_names

file names of the downloaded videos in sequence.

Type

list of str

run(information: Dict) Tuple[List, Dict][source]

Interface function for adding the last downloaded video’s file name in the class attribute filenames.

Parameters

information (dict) – last downloaded video’s information.

Returns

last downloaded video’s information.

Return type

tuple (list and dict)

ytb_downloader.downloader

This module contains functions for downloading videos from youtube.

download(urls: List[str], ydl_opts: Optional[Dict] = None) List[str][source]

Download videos/audios from the given youtube URLs.

Parameters
  • urls (list of str) – urls to the videos in youtube, you can get it through copying the url in address bar.

  • ydl_opts (dict) – yt_dlp’s options.

Returns

Downloaded youtube video file names.

Return type

list of str

ytb_downloader.converter

This module contains functions for converting the downloaded youtube video file to the given format.

convert_to(downloaded_file: str, media_format: Media = Media.AUDIO, conversion_format: str = 'mp3', t_start: int = 0, t_end: Optional[int] = None, fps: int = 44100, bitrate: str = '3000k') Optional[str][source]

Convert the downloaded youtube video file to the given format.

Parameters
  • downloaded_file (str) – path to the download youtube video file.

  • media_format (Media) – the original file’s format.

  • conversion_format (str) – format of the output file, mp3, avi etc.

  • t_start (int) – starting point for cutting the video.

  • t_end (int, optional) – ending point for cutting the video, if not provided, the whole video will be converted.

  • fps (int) – Frames per second. It will default to 44100.

  • bitrate (str) – Audio bitrate, given as a string like ‘50k’, ‘500k’, ‘3000k’. Will determine the size and quality of the output file. Note that it mainly an indicative goal, the bitrate won’t necessarily be the this in the output file.

Returns

the converted file path, if conversion succeed, otherwise None.

Return type

None or str

ytb_downloader.main