From d29a451780d49cfd5ef5cb2a9de9b4f714540a85 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 9 Mar 2024 11:40:34 +0800 Subject: [PATCH] tests/modules/home-manager: init services.gallery-dl --- tests/modules/home-manager/default.nix | 1 + .../services/gallery-dl/basic-job.nix | 32 +++++++++++++ .../services/gallery-dl/default.nix | 4 ++ .../services/gallery-dl/multiple-jobs.nix | 47 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 tests/modules/home-manager/services/gallery-dl/basic-job.nix create mode 100644 tests/modules/home-manager/services/gallery-dl/default.nix create mode 100644 tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix diff --git a/tests/modules/home-manager/default.nix b/tests/modules/home-manager/default.nix index 14eea902..8ce1b1d1 100644 --- a/tests/modules/home-manager/default.nix +++ b/tests/modules/home-manager/default.nix @@ -57,6 +57,7 @@ import nmt { ] ++ lib.optionals isLinux [ ./services/archivebox + ./services/gallery-dl ./services/matcha ./services/plover ./services/yt-dlp diff --git a/tests/modules/home-manager/services/gallery-dl/basic-job.nix b/tests/modules/home-manager/services/gallery-dl/basic-job.nix new file mode 100644 index 00000000..7e9f6525 --- /dev/null +++ b/tests/modules/home-manager/services/gallery-dl/basic-job.nix @@ -0,0 +1,32 @@ +{ config, ... }: + +{ + services.gallery-dl = { + enable = true; + archivePath = "${config.xdg.userDirs.pictures}/gallery-dl"; + + extraArgs = [ + # Record all downloaded files in an archive file. + "--download-archive" + "${config.services.gallery-dl.archivePath}/photos" + + "--date" "today-1week" # get only videos from a week ago + "--output" "%(uploader)s/%(title)s.%(ext)s" # download them in the respective directory + ]; + + jobs.art = { + urls = [ + "https://www.pixiv.net/en/users/60562229" + "https://www.deviantart.com/xezeno" + ]; + startAt = "weekly"; + }; + }; + + test.stubs.gallery-dl = { }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/gallery-dl-job-art.service + assertFileExists home-files/.config/systemd/user/gallery-dl-job-art.timer + ''; +} diff --git a/tests/modules/home-manager/services/gallery-dl/default.nix b/tests/modules/home-manager/services/gallery-dl/default.nix new file mode 100644 index 00000000..4ab9458d --- /dev/null +++ b/tests/modules/home-manager/services/gallery-dl/default.nix @@ -0,0 +1,4 @@ +{ + gallery-dl-basic-job = ./basic-job.nix; + gallery-dl-multiple-jobs = ./multiple-jobs.nix; +} diff --git a/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix b/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix new file mode 100644 index 00000000..172c082c --- /dev/null +++ b/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix @@ -0,0 +1,47 @@ +{ config, ... }: + +{ + services.gallery-dl = { + enable = true; + archivePath = "${config.xdg.userDirs.pictures}/gallery-dl"; + + extraArgs = [ + # Record all downloaded files in an archive file. + "--download-archive" + "${config.services.gallery-dl.archivePath}/photos" + + "--date" "today-1week" # get only videos from a week ago + "--output" "%(uploader)s/%(title)s.%(ext)s" # download them in the respective directory + ]; + + jobs = { + art = { + urls = [ + "https://www.pixiv.net/en/users/60562229" + "https://www.deviantart.com/xezeno" + ]; + startAt = "weekly"; + }; + + webcomics = { + urls = [ + "https://www.webtoons.com/en/comedy/mono-and-mochi/list?title_no=6019" + ]; + startAt = "daily"; + extraArgs = [ + "--date" "today-2week" # get only videos from a week ago + ]; + }; + }; + }; + + test.stubs.gallery-dl = { }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/gallery-dl-job-art.service + assertFileExists home-files/.config/systemd/user/gallery-dl-job-art.timer + + assertFileExists home-files/.config/systemd/user/gallery-dl-job-webcomics.service + assertFileExists home-files/.config/systemd/user/gallery-dl-job-webcomics.timer + ''; +}