youtube-dl 配置备忘

youtube-dl 下载配置:

/etc/youtube-dl.conf

1
2
3
4
5
6
7
8
9
-f bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio
--merge-output-format mp4
--add-metadata
--embed-thumbnail --embed-subs --all-subs --xattrs
--yes-playlist
--write-info-json
--output "%(uploader)s/%(playlist).40s/[%(upload_date)s] %(title).68s [%(id)s].%(ext)s"
--output-na-placeholder ""
--ignore-errors

创建 systemd 定时任务,每一小时执行一次:

/usr/lib/systemd/system/youtube-dl.timer/etc/systemd/system/youtube-dl.timer

1
2
3
4
5
6
7
8
9
[Unit]
Description=youtube-dl timer

[Timer]
OnUnitActiveSec=1h
Unit=youtube-dl.service

[Install]
WantedBy=multi-user.target

创建 systemd 服务:

/usr/lib/systemd/system/youtube-dl.service/etc/systemd/system/youtube-dl.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=youtube-dl

[Service]
WorkingDirectory=/home/whypro/youtube-dl
Environment=http_proxy=http://127.0.0.1:1080
Environment=https_proxy=http://127.0.0.1:1080
#ExecStart=/usr/bin/youtube-dl --batch-file=todo.txt --download-archive=archive.txt
ExecStart=/usr/local/bin/youtube-dl --batch-file=/home/whypro/youtube-dl/todo.txt --download-archive=/home/whypro/youtube-dl/
User=whypro
Group=whypro

[Install]
WantedBy=multi-user.target

参考:
Systemd 定时器教程 - 阮一峰的网络日志

Author

whypro

Posted on

2021-01-22

Updated on

2021-03-13

Licensed under

Comments

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×