nixos-config/nixos/machines/chungus/media-youtube.nix

219 lines
8 KiB
Nix
Raw Normal View History

2023-08-02 06:01:22 +02:00
{ config, pkgs, lib, ... }:
with lib;
let
configuration = {
# series
# ------
2023-08-02 12:16:25 +02:00
druck1 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1RncxDFRfjkucPWRz5-8rjaH";
target = "/media/youtube/series/Druck";
output = "Druck S01E%(playlist_index)s %(title)s.%(ext)s";
};
druck2 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1RmbJojNI6lxS1Gn6UipeOdd";
target = "/media/youtube/series/Druck";
output = "Druck S02E%(playlist_index)s %(title)s.%(ext)s";
};
druck3 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1RnNv9KjVfvGCkDfIIuzSJpC";
target = "/media/youtube/series/Druck";
output = "Druck S03E%(playlist_index)s %(title)s.%(ext)s";
};
druck4 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1Rlbfz3vlmiW4EOAVZMh5kVF";
target = "/media/youtube/series/Druck";
output = "Druck S04E%(playlist_index)s %(title)s.%(ext)s";
};
druck5 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1RkacxBEWFO4jx6rOhgmMHf4";
target = "/media/youtube/series/Druck";
output = "Druck S05E%(playlist_index)s %(title)s.%(ext)s";
};
druck6 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1Rnj83qu3xujxw-LuI-2m4TS";
target = "/media/youtube/series/Druck";
output = "Druck S06E%(playlist_index)s %(title)s.%(ext)s";
};
2023-08-02 06:01:22 +02:00
druck7 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1RmN41ni6iDmBRg5Cos_bD--";
target = "/media/youtube/series/Druck";
output = "Druck S07E%(playlist_index)s %(title)s.%(ext)s";
};
druck8 = {
url = "https://www.youtube.com/watch?list=PLUQncgYMM1RlzMSECHQDOHx2A4l4G-7yX";
target = "/media/youtube/series/Druck";
output = "Druck S08E%(playlist_index)s %(title)s.%(ext)s";
};
SunkCostGalaxy = {
url = "https://www.youtube.com/watch?list=PL7SIP0NDfM2yyHKfRmCAociCcJKZHHY0E";
target = "/media/youtube/series/Sunk Cost Galaxy";
output = "Sunk Cost Galaxy S01E%(playlist_index)s %(title)s.%(ext)s";
};
2023-09-08 09:46:41 +02:00
BigLez = {
url = "https://www.youtube.com/watch?list=PLGMC7oz7XpmCR1RWxqvFWvXVO_ry6FdHI";
target = "/media/youtube/series/Big Lez";
output = "Big Lez S01E%(playlist_index)s %(title)s.%(ext)s";
};
Sassy = {
url = "https://www.youtube.com/watch?v=Dw_tGRblTXk";
target = "/media/youtube/series/Big Lez";
output = "Big Lez S02E01 %(title)s.%(ext)s";
};
# channels
# --------
2023-08-02 06:01:22 +02:00
ordinary_things = {
url = "https://www.youtube.com/@OrdinaryThings";
target = "/media/youtube/channels/Ordinary Things";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
internet_historian = {
url = "https://www.youtube.com/@InternetHistorian";
target = "/media/youtube/channels/Internet Historian";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
bigboss = {
url = "https://www.youtube.com/@bigbosstube";
target = "/media/youtube/channels/Big Boss";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
CGPGrey = {
url = "https://www.youtube.com/@CGPGrey";
target = "/media/youtube/channels/CGP Grey";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
Joeseppi = {
url = "https://www.youtube.com/@Joeseppi";
target = "/media/youtube/channels/Joeseppi";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
HungrigerHugo = {
url = "https://www.youtube.com/@HungrigerHugo";
target = "/media/youtube/channels/HungrigerHugo";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
Kurzgesagt = {
url = "https://www.youtube.com/@KurzgesagtDE";
target = "/media/youtube/channels/Kurzgesagt";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
Simplicissimus = {
url = "https://www.youtube.com/@Simplicissimus";
target = "/media/youtube/channels/Simplicissimus";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
Soosenbinder = {
url = "https://www.youtube.com/@Soosenbinder";
target = "/media/youtube/channels/Soosenbinder";
2023-08-02 06:01:22 +02:00
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
AllGasNoBreaks = {
url = "https://www.youtube.com/@allgasnobrakes2491";
target = "/media/youtube/channels/All Gas No Breaks";
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
2023-08-07 22:42:36 +02:00
Jules = {
url = "https://www.youtube.com/@Jules1";
target = "/media/youtube/channels/Jules";
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
2023-11-18 12:50:31 +01:00
#UrknallWeltallLeben = {
# url = "https://youtube.com/@UrknallWeltallLeben";
# target = "/media/youtube/channels/Urknall Weltall Leben";
# output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
#};
2023-08-14 03:08:56 +02:00
ColdMirrorProdukte = {
url = "https://www.youtube.com/watch?list=PLDvBqWb1UAGckU8CEJ8kDsk3ii8bbHT-s";
target = "/media/youtube/channels/ColdMirror ProduktBeschreibungen";
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
ColdMirror5Minuten = {
url = "https://www.youtube.com/watch?list=PLDvBqWb1UAGeEt9n6vFH_zdGw65Obf3sH";
target = "/media/youtube/channels/ColdMirror 5 Minuten Harry Potter";
output = "%(channel)s S%(upload_date>%Y)sE%(upload_date>%m%d)s %(title)s.%(ext)s";
};
# My Playlists
# ------------
2023-08-03 11:50:39 +02:00
MusicVideos = {
url = "https://www.youtube.com/playlist?list=PLP33x-q_GftakJgpD48pZNl0TkhljQI7S";
target = "/media/youtube/music-videos";
output = "%(title)s.%(ext)s";
};
Movies = {
url = "https://www.youtube.com/playlist?list=PLP33x-q_Gftb-r8eUWBS1mjMlQZgCAljE";
target = "/media/youtube/movies";
output = "%(title)s.%(ext)s";
};
# like Documentations or something
Videos = {
url = "https://www.youtube.com/playlist?list=PLP33x-q_GftZa0-UG9yltYLea5scEHxd7";
target = "/media/youtube/loot";
output = "%(title)s.%(ext)s";
};
2023-09-08 09:46:41 +02:00
FridayVideos = {
url = "https://www.youtube.com/playlist?list=PLP33x-q_GftbqHBybHABOwsRcUX7XZl_D";
target = "/media/youtube/loot";
output = "%(title)s.%(ext)s";
};
2023-08-02 06:01:22 +02:00
};
downloadScript =
name: { url
, target
, output
, sponsorBlockCategories ? [ "default" ]
, notOlderThan ? "" # e.g: 1week
, breakOnExisting ? true
2023-09-08 09:46:41 +02:00
, reverse ? false
2023-08-02 06:01:22 +02:00
}: pkgs.writers.writeDash "download-script-${name}" ''
mkdir -p "${target}"
yt-dlp \
--no-abort-on-error \
--no-mark-watched \
--continue \
${optionalString (notOlderThan != "") "--dateafter now-${notOlderThan}" } \
2023-09-08 09:46:41 +02:00
${optionalString reverse "--playlist-reverse" } \
2023-08-02 06:01:22 +02:00
--download-archive "${target}/.downloaded.txt" \
--output "${target}/${output}" \
--format "bestvideo[ext=mp4]+bestaudio[ext=m4a]" \
--merge-output-format mp4 \
--add-metadata \
--write-thumbnail \
--convert-thumbnail jpg \
--sponsorblock-mark "default" \
${optionalString (sponsorBlockCategories != []) "--sponsorblock-remove ${concatStringsSep "," sponsorBlockCategories}" } \
${optionalString breakOnExisting "--break-on-existing" } \
"${url}" || true
'';
in
{
systemd.services.youtube = {
after = [ "network.target" ];
path = [ pkgs.yt-dlp ];
serviceConfig = {
User = "media";
Group = "media";
};
script = (concatStringsSep "\n"
(mapAttrsToList downloadScript configuration)
);
};
systemd.timers.youtube = {
enable = true;
wantedBy = [ "multi-user.target" ];
timerConfig = {
OnCalendar = "daily";
Persistent = "true";
};
};
}