Last active 1727206403

bilibili-download.sh Raw
1#!/bin/bash
2
3user_urls=(
4 "https://space.bilibili.com/8776737/video" # 阿江君
5 "https://space.bilibili.com/20247643/video" # 拉环儿_
6 "https://space.bilibili.com/23945810/video" # 爱抽卡的白熊
7 "https://space.bilibili.com/287551041/video" # 一万根韭菜
8 "https://space.bilibili.com/15232589/video" # 白木哒哒哒
9 "https://space.bilibili.com/6768352/video" # 粥粥的奇妙冒险
10 "https://space.bilibili.com/11742550/video" # 哈米伦的弄笛者
11 "https://space.bilibili.com/4128618/video" # 大大大灯泡
12 "https://space.bilibili.com/7086255/channel/collectiondetail?sid=611502" # 超想吃番茄 - 原神二创
13 # more videos link here
14)
15cookies_path=./cookies.txt # export with https://addons.mozilla.org/en-US/firefox/addon/get-cookies-txt-locally/
16outdir_root=/volumes/jellyfin/media/Bilibili
17outpath="$outdir_root/%(uploader)s/%(title)s.%(ext)s"
18video_format="bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
19# video_format="bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" # if you want 4k or higher
20
21for url in "${user_urls[@]}"; do
22 user_id=$(echo "$url" | grep -oP '(?<=bilibili.com/)[^/]+') # Extract the user ID from the URL
23 archive="$outdir_root/archives/$user_id.txt"
24 echo "Starting download $url"
25 date
26 yt-dlp \
27 -f $video_format \
28 --download-archive $archive \
29 --cookies $cookies_path \
30 --write-description \
31 --write-info-json \
32 --write-annotations \
33 --write-thumbnail \
34 --write-sub \
35 --all-subs \
36 --ignore-errors \
37 --merge-output-format mp4 \
38 --add-metadata \
39 --embed-subs \
40 --embed-thumbnail \
41 --sleep-interval 50 \
42 --max-sleep-interval 100 \
43 -o $outpath $url
44 sleep 600
45done
46