VideoDownloader is a video downloading program developed based on the yt-dlp
python library.
yt-dlp is a feature-rich command-line audio/video downloader supporting thousands of websites. This project is a fork of youtube-dl based on the now defunct youtube-dlc.
yt-dlp basically supports all common video websites. It is a command line program with very powerful functions and rich parameters. This project is developed based on the python library of yt-dlp (yt_dlp). It uses the tkinter library to build a GUI application for video downloading, eliminating the need to enter lengthy commands on the command line and giving you an easy downloading experience. .
The Windows environment is used by default, I use pycharm+Anaconda:
python>=3.8
ffmpeg is used to automatically merge audio and video after downloading. Note that it is the binary executable file of ffmpeg, not the python library. Remember to add it to the environment variable, such as: D:ffmpegbin
(1) Clone this project
git clone [email protected]:CQUPTLei/VideoDownloader.git
(2) Create a new conda virtual environment for the project, example:
conda create -n videodownload python=3.12
(3) Use pip to install the yt_dlp library:
conda activate videodownload pip install yt-dlp
Under Linux, take Ubuntu24.04 as an example, use vim to edit, python venv virtual environment (you can also use conda):
(1) Clone the project locally
git clone [email protected]:CQUPTLei/VideoDownloader.git
(2) Install python venv
apt install python3.12-venv
(3) Create a virtual environment
python3 -m venv downloader
(4) Activate virtual environment
source downloader/bin/activate
(5) Install related libraries
pip install yt-dlp sudo apt install python3-tk pip install prettytable# For packaging, use pip install pyinstaller
(6) Give main.py executable permissions
sudo chmod 775 main.py
(7) Execution (note the path)
python3 main.py
Possible modifications: If you use to obtain cookie files from the browser, you may need to modify the path, and the default storage location may need to be modified.
Windows:
Install the pyinstaller library:
pip install pyinstaller
Packaging command example, pay attention to each path. The following code is executed in the directory where main.py is located:
pyinstaller -F --paths=D:anacondaenvsvideodownloadLibsite-packages --python=D:anacondaenvsvideodownloadpythonw.exe --noconsole --icon=icon1.ico --name=Downloader main.py
Ubuntu:
A simple example:
pyinstaller -F --paths=/home/moon/VideoDownloader/downloader/lib/python3.12/site-packages --python=/home/moon/VideoDownloader/downloader/bin/python312 --noconsole --icon=icon1.ico --name=Downloader main.py
MacOS:
Add processing and downloading of video lists;
Perform multiple download tasks at the same time;
Support more custom parameters;
...
There is no special reference manual for yt_dlp on pypi. The available parameters of the yt-dlp command line program are written on both github and pypi, but you can read the specific implementation of yt_dlp: YoutubeDL.py
to get the available parameters and meanings.
The following are mainly the parameters supported by yt_dlp.YoutubeDL(download_opts)
method.
YoutubeDL objects accept a lot of parameters. In order not to saturatethe object constructor with arguments, it receives a dictionary ofoptions instead. These options are available through the paramsattribute for the InfoExtractors to use. The YoutubeDL alsoregisters itself as the downloader in charge for the InfoExtractorsthat are added to it, so this is a "mutual registration". Available options:username: Username for authentication purposes.password: Password for authentication purposes.videopassword: Password for accessing a video.ap_mso: Adobe Pass multiple-system operator identifier.ap_username: Multiple-system operator account username.ap_password: Multiple-system operator account password.usenetrc: Use netrc for authentication instead.netrc_location: Location of the netrc file. Defaults to ~/.netrc.netrc_cmd: Use a shell command to get credentialsverbose: Print additional info to stdout.quiet: Do not print messages to stdout.no_warnings: Do not print out anything for warnings.forceprint: A dict with keys WHEN mapped to a list of templates to print to stdout. The allowed keys are video or any of the items in utils.POSTPROCESS_WHEN. For compatibility, a single list is also acceptedprint_to_file : A dict with keys WHEN (same as forceprint) mapped to a list of tuples with (template, filename)forcejson: Force printing info_dict as JSON.dump_single_json: Force printing the info_dict of the whole playlist (or video) as a single JSON line.force_write_download_archive: Force writing download archive regardless of 'skip_download' or 'simulate'.simulate: Do not download the video files. If unset ( or None), simulate only if listsubtitles, listformats or list_thumbnails is usedformat: Video format code. see "FORMAT SELECTION" for more details. You can also pass a function. The function takes 'ctx' as argument and returns the formats to download. See "build_format_selector" for an implementationallow_unplayable_formats: Allow unplayable formats to be extracted and downloaded.ignore_no_formats_error: Ignore "No video formats" error. Usefull for extracting metadata even if the video is not actually available for download (experimental)format_sort: A list of fields by which to sort the video formats. See "Sorting Formats" for more details.format_sort_force: Force the given format_sort. see "Sorting Formats" for more details.prefer_free_formats: Whether to prefer video formats with free containers over non-free ones of same quality.allow_multiple_video_streams: Allow multiple video streams to be merged into a single fileallow_multiple_audio_streams: Allow multiple audio streams to be merged into a single filecheck_formats Whether to test if the formats are downloadable. Can be True (check all), False (check none), 'selected' (check selected formats), or None (check only if requested by extractor)paths: Dictionary of output paths. The allowed keys are 'home' 'temp' and the keys of OUTTMPL_TYPES (in utils/_utils.py)outtmpl : Dictionary of templates for output names. Allowed keys are 'default' and the keys of OUTTMPL_TYPES (in utils/_utils.py). For compatibility with youtube-dl, a single string can also be usedouttmpl_na_placeholder: Placeholder for unavailable meta fields.restrictfilenames: Do not allow "&" and spaces in file namestrim_file_name: Limit length of filename (extension excluded)windowsfilenames: Force the filenames to be windows compatibleignoreerrors : Do not stop on download/postprocessing errors. Can be 'only_download' to ignore only download errors. Default is 'only_download' for CLI, but False for APIskip_playlist_after_errors: Number of allowed failures until the rest of the playlist is skippedallowed_extractors: List of regexes to match against extractor names that are allowedoverwrites: Overwrite all video and metadata files if True, overwrite only non-video files if None and don't overwrite any file if Falseplaylist_items: Specific indices of playlist to download.playlistrandom: Download playlist items in random order.lazy_playlist: Process playlist entries as they are received.matchtitle: Download only matching titles.rejecttitle: Reject downloads for matching titles.logger: Log messages to a logging.Logger instance.logtostderr: Print everything to stderr instead of stdout.consoletitle: Display progress in console window's titlebar.writedescription: Write the video description to a .description filewriteinfojson: Write the video description to a .info.json fileclean_infojson: Remove internal metadata from the infojsongetcomments: Extract video comments. This will not be written to disk unless writeinfojson is also givenwriteannotations: Write the video annotations to a .annotations.xml filewritethumbnail: Write the thumbnail image to a fileallow_playlist_files: Whether to write playlists' description, infojson etc also to disk when using the 'write*' optionswrite_all_thumbnails: Write all thumbnail formats to fileswritelink: Write an internet shortcut file, depending on the current platform (.url/.webloc/.desktop)writeurllink: Write a Windows internet shortcut file (.url)writewebloclink: Write a macOS internet shortcut file (.webloc)writedesktoplink: Write a Linux internet shortcut file (.desktop)writesubtitles: Write the video subtitles to a filewriteautomaticsub: Write the automatically generated subtitles to a filelistsubtitles: Lists all available subtitles for the videosubtitlesformat: The format code for subtitlessubtitleslangs: List of languages of the subtitles to download (can be regex). The list may contain "all" to refer to all the available subtitles. The language can be prefixed with a "-" to exclude it from the requested languages, eg ['all', '-live_chat']keepvideo: Keep the video file after post-processingdaterange: A utils.DateRange object, download only if the upload_date is in the range.skip_download: Skip the actual download of the video filecachedir: Location of the cache files in the filesystem. False to disable filesystem cache .noplaylist: Download single video instead of a playlist if in doubt.age_limit: An integer representing the user's age in years. Unsuitable videos for the given age are skipped.min_views: An integer representing the minimum view count the