@@ -0,0 +1,62 @@
1+{ lib, fetchurl, buildPythonPackage
2+, zip, ffmpeg, rtmpdump, phantomjs2, atomicparsley, pycryptodome, pandoc
3+, fetchFromGitHub
4+, websockets, mutagen
5+, ffmpegSupport ? true
6+, rtmpSupport ? true
7+, phantomjsSupport ? false
8+, hlsEncryptedSupport ? true
9+, installShellFiles, makeWrapper }:
10+
11+buildPythonPackage rec {
12+ pname = "yt-dlp";
13+ # The websites yt-dlp deals with are a very moving target. That means that
14+ # downloads break constantly. Because of that, updates should always be backported
15+ # to the latest stable release.
16+ version = "2021.07.21";
17+
18+ src = fetchFromGitHub {
19+ owner = "yt-dlp";
20+ repo = "yt-dlp";
21+ rev = version;
22+ sha256 = "ziOW52LJUBe0j7ru8GYgiUCE6YJeBTTjm+H6W8EZjuY=";
23+ };
24+
25+ nativeBuildInputs = [ installShellFiles makeWrapper ];
26+ buildInputs = [ zip pandoc ];
27+ propagatedBuildInputs = [ websockets mutagen ]
28+ ++ lib.optional hlsEncryptedSupport pycryptodome;
29+
30+ # Ensure these utilities are available in $PATH:
31+ # - ffmpeg: post-processing & transcoding support
32+ # - rtmpdump: download files over RTMP
33+ # - atomicparsley: embedding thumbnails
34+ makeWrapperArgs = let
35+ packagesToBinPath = [ atomicparsley ]
36+ ++ lib.optional ffmpegSupport ffmpeg
37+ ++ lib.optional rtmpSupport rtmpdump
38+ ++ lib.optional phantomjsSupport phantomjs2;
39+ in [ ''--prefix PATH : "${lib.makeBinPath packagesToBinPath}"'' ];
40+
41+ setupPyBuildFlags = [
42+ "build_lazy_extractors"
43+ ];
44+
45+ # Requires network
46+ doCheck = false;
47+
48+ meta = with lib; {
49+ homepage = "https://github.com/yt-dlp/yt-dlp/";
50+ description = "Command-line tool to download videos from YouTube.com and other sites (youtube-dl fork)";
51+ longDescription = ''
52+ yt-dlp is a youtube-dl fork based on the now inactive youtube-dlc.
53+
54+ youtube-dl is a small, Python-based command-line program
55+ to download videos from YouTube.com and a few more sites.
56+ youtube-dl is released to the public domain, which means
57+ you can modify it, redistribute it or use it however you like.
58+ '';
59+ license = licenses.publicDomain;
60+ maintainers = with maintainers; [ mkg20001 ];
61+ };
62+}