Skip to main content

Convenient command line and library wrapper for youtube-dl.

Latest release 20220318:

  • YDLCommand.main: plumb options.parallel through to the OverYDL constructor.
  • Bump required revision for cs.cmdutils.

The youtube-dl tool and associated youtube_dl Python module are very useful for downloading media from various websites. However, as an end user who almost never streams because of my soggy internet link, I find fetching several items is quite serial and visually noisy.

This module provides a command line tool ydl which:

  • runs multiple downloads in parallel with progress bars
  • prints the downloaded filename as each completes

Interactively, I keep this shell function:

ydl(){
  ( set -ue
    dldir=${DL:-$HOME/dl}/v
    [ -d "$dldir" ] || set-x mkdir "$dldir"
    cd "$dldir"
    command ydl ${1+"$@"}
  )
}

which runs the downloader in my preferred download area without tedious manual cding.

Function main(argv=None)

Main command line.

Class OverYDL

A manager for multiple YDL instances.

Method OverYDL.queue(self, *a, **kw): Queue a fetch of url and return a Result.

Method OverYDL.queue_iter(self, urls): Queue the URLs of the iterable urls, essentially a convenience wrapper for the queue method. Returns a list of the Results for each queued URL.

Method OverYDL.report(self, Rs=None): Wrapper returning cs.result.report(.Rs). Rs defaults to list(self.Rs, the accumulated Results.

Class YDL

Manager for a download process.

Method YDL.__init__(self, url, *, fstags, upd=None, tick=None, over_progress=None, sem, **kw_opts): Initialise the manager.

Parameters:

  • url: the URL to download
  • fstags: mandatory keyword argument, a cs.fstags.FSTags instance
  • upd: optional cs.upd.Upd instance for progress reporting
  • tick: optional callback to indicate state change
  • over_progress: an OverProgress to which to add each new Progress instance
  • sem: a shared Semaphore governing download parallelism
  • kw_opts: other keyword arguments are used to initialise the options for the underlying YoutubeDL instance

Method YDL.bg(self): Return the Result for this download, starting the download if necessary.

Property YDL.output_filename: The target output filename.

Method YDL.process_info(ie_result): Process info hook called by youtube_dl, seems uncalled :-(

Class YDLCommand(cs.cmdutils.BaseCommand)

ydl command line implementation.

Command line usage:

Usage: ydl [-f] [-j jobs] {URLs|-}...
    -f      Force download - do not use the cache.
    -j jobs Number of jobs (downloads) to run in parallel.
            Default: 4

Method YDLCommand.apply_defaults(self): Initial defaults options.

Method YDLCommand.apply_opts(self, opts): Command line main switches.

Method YDLCommand.main(self, argv): Command line main programme.

Release Log

Release 20220318:

  • YDLCommand.main: plumb options.parallel through to the OverYDL constructor.
  • Bump required revision for cs.cmdutils.

Release 20210906: New -j jobs options to control parallelism, default 4.

Release 20210404: Update for recent cs.cmdutils change.

Release 20210306: Assorted internal updates.

Release 20200621:

  • YDL.run: just catch the youtube_dl DownloadError.
  • Changes to the default output filename template.
  • Other minor internal changes.

Release 20200615.1: Add usage message to docstring.

Release 20200615:

  • Initial "daemon" mode, suitable for "tail -f .ydld-queue | ydl -", handy for keeping around in a tmux session.
  • Assorted small bugfixes.

Release 20200521: Initial PyPI release.

Release files for cs.app.ydl 20220318

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs.app.ydl 20220318
File Size Uploaded
cs.app.ydl-20220318.tar.gz 7.3 kB Details

Release files / cs.app.ydl-20220318.tar.gz

Download URL cs.app.ydl-20220318.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2fc64554cd684fd8dd40920db7ccdf79defe950b7b106c5a7bfb24f21d2d9ed1
BLAKE2b-256 checksum
How to use checksums
bfda128123d850fd6130d295c746b980f72aa6ae889b772235ec054a23044709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release history Release notifications | RSS feed

This release

20220318 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page