1{
2 lib,
3 fetchurl,
4 makeDesktopItem,
5 ffmpeg,
6 qmake,
7 qttools,
8 mkDerivation,
9 qtbase,
10 qtdeclarative,
11 qtlocation,
12 qtquickcontrols2,
13 qtwebchannel,
14 qtwebengine,
15 yt-dlp,
16}:
17
18mkDerivation rec {
19 pname = "clipgrab";
20 version = "3.9.7";
21
22 src = fetchurl {
23 sha256 = "sha256-9H8raJd6MyyFICY8WUZQGLJ4teKPJUiQfqbu1HWAVIw=";
24 # The .tar.bz2 "Download" link is a binary blob, the source is the .tar.gz!
25 url = "https://download.clipgrab.org/${pname}-${version}.tar.gz";
26 };
27
28 buildInputs = [
29 ffmpeg
30 qtbase
31 qtdeclarative
32 qtlocation
33 qtquickcontrols2
34 qtwebchannel
35 qtwebengine
36 ];
37 nativeBuildInputs = [
38 qmake
39 qttools
40 ];
41
42 patches = [
43 ./yt-dlp-path.patch
44 ];
45
46 postPatch = ''
47 substituteInPlace youtube_dl.cpp \
48 --replace 'QString YoutubeDl::path = QString();' \
49 'QString YoutubeDl::path = QString("${yt-dlp}/bin/yt-dlp");'
50 ''
51 + lib.optionalString (ffmpeg != null) ''
52 substituteInPlace converter_ffmpeg.cpp \
53 --replace '"ffmpeg"' '"${ffmpeg.bin}/bin/ffmpeg"' \
54 --replace '"ffmpeg ' '"${ffmpeg.bin}/bin/ffmpeg '
55 '';
56
57 qmakeFlags = [ "clipgrab.pro" ];
58
59 desktopItem = makeDesktopItem rec {
60 name = "clipgrab";
61 exec = name;
62 icon = name;
63 desktopName = "ClipGrab";
64 comment = meta.description;
65 genericName = "Web video downloader";
66 categories = [
67 "Qt"
68 "AudioVideo"
69 "Audio"
70 "Video"
71 ];
72 };
73
74 installPhase = ''
75 runHook preInstall
76 install -Dm755 clipgrab $out/bin/clipgrab
77 install -Dm644 icon.png $out/share/pixmaps/clipgrab.png
78 cp -r ${desktopItem}/share/applications $out/share
79 runHook postInstall
80 '';
81
82 meta = with lib; {
83 description = "Video downloader for YouTube and other sites";
84 longDescription = ''
85 ClipGrab is a free downloader and converter for YouTube, Vimeo, Metacafe,
86 Dailymotion and many other online video sites. It converts downloaded
87 videos to MPEG4, MP3 or other formats in just one easy step.
88 '';
89 homepage = "https://clipgrab.org/";
90 license = licenses.gpl3Plus;
91 platforms = platforms.linux;
92 mainProgram = "clipgrab";
93 };
94}