From 6157fa5d4854709730f2a6b9aeb77bbce03cbd6d Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 22 Dec 2023 12:26:15 +0100 Subject: [PATCH] youtubedl: remove podcast download (#636) Reviewed-on: https://git.mgrote.net/mg/homeserver/pulls/636 Co-authored-by: Michael Grote Co-committed-by: Michael Grote --- host_vars/fileserver3.mgrote.net.yml | 10 ++--- roles/mgrote_youtubedl/defaults/main.yml | 3 ++ roles/mgrote_youtubedl/tasks/main.yml | 41 ++++++++++++++++--- .../templates/youtubedl.service.j2 | 4 ++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/host_vars/fileserver3.mgrote.net.yml b/host_vars/fileserver3.mgrote.net.yml index 420ee758..09dc167f 100644 --- a/host_vars/fileserver3.mgrote.net.yml +++ b/host_vars/fileserver3.mgrote.net.yml @@ -24,18 +24,18 @@ ytdl_video_urls: - https://www.youtube.com/playlist?list=PLs4hTtftqnlAkiQNdWn6bbKUr-P1wuSm0 # jimmy kimmel mean tweets - https://www.youtube.com/tomstantonengineering - https://www.youtube.com/@liamcarps #englandvideos ironisch -ytdl_podcast_urls: - - https://sternengeschichten.podigee.io/feed/aac # Sternengeschichten - - https://feeds.br.de/radiowissen/feed.xml # BR2 RadioWissen -ytdl_video_output: "/shares_videos/Youtube/%(uploader)s/%(title)s-%(id)s.%(ext)s" # Videos werden jetzt IMMEr nach "Uploader/Name.ext" geschrieben +ytdl_video_output: "/shares_videos/Youtube/%(uploader)s/%(title)s-%(id)s.%(ext)s" # Videos werden jetzt IMMER nach "Uploader/Name.ext" geschrieben + +ytdl_enable_video_download: true +ytdl_enable_podcast_download: false ytdl_podcast_output: "/shares_music/Podcasts/%(playlist)s/%(id)s.%(ext)s" ytdl_video_log_output: "/shares_videos/Youtube/archive-youtube.log" ytdl_podcast_log_output: "/shares_music/Podcasts/archive-podcast.log" ytdl_youtube_username: "{{ lookup('keepass', 'youtubedl_youtube_login', 'username') }}" ytdl_youtube_password: "{{ lookup('keepass', 'youtubedl_youtube_login', 'password') }}" -ytdl_conf_dir: "/etc/youtubedl" #ohne / am ende +ytdl_conf_dir: "/etc/youtubedl" # ohne / am ende ytdl_download_limit: "10000K" ### mgrote_fileserver_smb diff --git a/roles/mgrote_youtubedl/defaults/main.yml b/roles/mgrote_youtubedl/defaults/main.yml index c25b896e..a53f8b48 100644 --- a/roles/mgrote_youtubedl/defaults/main.yml +++ b/roles/mgrote_youtubedl/defaults/main.yml @@ -35,3 +35,6 @@ ytdl_youtube_password: "{{ lookup('keepass', 'youtubedl_youtube_login', 'passwor ytdl_conf_dir: "/etc/youtubedl" #ohne / am ende ytdl_download_limit: "10000K" ytdl_active: false # damit werden die systemd-Units nicht angelegt + +ytdl_enable_video_download: true +ytdl_enable_podcast_download: false diff --git a/roles/mgrote_youtubedl/tasks/main.yml b/roles/mgrote_youtubedl/tasks/main.yml index 6d296e69..c4f4f39b 100644 --- a/roles/mgrote_youtubedl/tasks/main.yml +++ b/roles/mgrote_youtubedl/tasks/main.yml @@ -24,19 +24,29 @@ group: root mode: "0755" -- name: template youtubedl config +- name: template youtubedl video config become: true ansible.builtin.template: - src: "{{ item }}" - dest: "{{ ytdl_conf_dir }}/{{ item }}" + src: youtube.txt + dest: "{{ ytdl_conf_dir }}/youtube.txt" owner: root group: root mode: "0644" notify: - systemctl daemon-reload - loop: - - podcast.txt - - youtube.txt + when: ytdl_enable_video_download + +- name: template youtubedl podcast config + become: true + ansible.builtin.template: + src: podcast.txt + dest: "{{ ytdl_conf_dir }}/podcast.txt" + owner: root + group: root + mode: "0644" + notify: + - systemctl daemon-reload + when: ytdl_enable_podcast_download - name: template systemd services become: true @@ -84,3 +94,22 @@ notify: - systemctl daemon-reload when: ytdl_active + +- name: ensure youtubedl video config is absent + become: true + ansible.builtin.file: + state: absent + path: "{{ ytdl_conf_dir }}/youtube.txt" + notify: + - systemctl daemon-reload + when: not ytdl_enable_video_download + +- name: ensure youtubedl podcast config is absent + become: true + ansible.builtin.file: + state: absent + path: "{{ ytdl_conf_dir }}/podcast.txt" + notify: + - systemctl daemon-reload + when: not ytdl_enable_podcast_download +... diff --git a/roles/mgrote_youtubedl/templates/youtubedl.service.j2 b/roles/mgrote_youtubedl/templates/youtubedl.service.j2 index 75c17f0a..ccd74d34 100644 --- a/roles/mgrote_youtubedl/templates/youtubedl.service.j2 +++ b/roles/mgrote_youtubedl/templates/youtubedl.service.j2 @@ -6,8 +6,12 @@ OnFailure=youtubedl_mail.service [Service] Type=oneshot +{% if ytdl_enable_podcast_download is sameas true %} ExecStart=-{{ ytdl_bin_path }} --config-location "{{ ytdl_conf_dir }}/podcast.txt" +{% endif %} +{% if ytdl_enable_video_download is sameas true %} ExecStart=-{{ ytdl_bin_path }} --config-location "{{ ytdl_conf_dir }}/youtube.txt" +{% endif %} Restart=on-failure RestartSec=10min