#!/bin/bash # __ __ # ____ ___ ______ / /___ ____ _____/ /__ _____ # / __ `/ / / / __ \/ / __ \/ __ `/ __ / _ \/ ___/ # / /_/ / /_/ / / / / / /_/ / /_/ / /_/ / __/ / # \__, /\__,_/_/ /_/_/\____/\__,_/\__,_/\___/_/ # /____/ # --------------------------------------------------- # Author :: Miris /// GitHub :: MirisWisdom/Albumin # --------------------------------------------------- # This simple Bash script lets you download the video # using yt-dlp, and then takes care of extracting its # audio into a file for each song w/ ffmpeg! # It does not re-encode or tag any of the audio files # due to raw preservation being its purpose. # You should run it line by line rather than blindly! # Feel free to tweak & suggest improvements! # --------------------------------------------------- # We'll be using the ID for both file and directory. VIDEO_ID='9uL2yqwvQNM' # Create and enter the new directory. mkdir -p "${VIDEO_ID}" && cd "${VIDEO_ID}" # Download the audio file using yt-dlp. yt-dlp -x -f bestaudio "${VIDEO_ID}" -o "${VIDEO_ID}.%%(ext)s" # Figure out the downloaded file name and extension. SRC_FILE=$(ls "${VIDEO_ID}".*) # ls command should only output the downloaded file name! FILE_EXT=${SRC_FILE:12} # file id + dot = 12 characters; extension length varies! ffmpeg -ss 00:00:00 -to 00:04:00 -i "${SRC_FILE}" -vn -acodec copy "01. 悲しみよこんにちは.${FILE_EXT}" ffmpeg -ss 00:04:00 -to 00:08:30 -i "${SRC_FILE}" -vn -acodec copy "02. あした晴れるか.${FILE_EXT}" ffmpeg -ss 00:08:30 -to 00:12:25 -i "${SRC_FILE}" -vn -acodec copy "03. シ・ネ・マ.${FILE_EXT}" ffmpeg -ss 00:12:25 -to 00:16:05 -i "${SRC_FILE}" -vn -acodec copy "04. Alone Again.${FILE_EXT}" ffmpeg -ss 00:16:05 -to 00:18:45 -i "${SRC_FILE}" -vn -acodec copy "05. Get Down.${FILE_EXT}" ffmpeg -ss 00:18:45 -to 00:21:22 -i "${SRC_FILE}" -vn -acodec copy "06. 好きさ.${FILE_EXT}" ffmpeg -ss 00:21:22 -to 00:25:34 -i "${SRC_FILE}" -vn -acodec copy "07. ファンタジー.${FILE_EXT}" ffmpeg -ss 00:25:34 -to 00:29:22 -i "${SRC_FILE}" -vn -acodec copy "08. サニーシャイニーモーニング.${FILE_EXT}" ffmpeg -ss 00:29:22 -to 00:33:42 -i "${SRC_FILE}" -vn -acodec copy "09. サヨナラの素描(デッサン).${FILE_EXT}" ffmpeg -ss 00:33:42 -to 00:37:44 -i "${SRC_FILE}" -vn -acodec copy "10. 陽だまり.${FILE_EXT}" ffmpeg -ss 00:37:44 -to 00:42:17 -i "${SRC_FILE}" -vn -acodec copy "11. ビギン・ザ・ナイト.${FILE_EXT}" ffmpeg -ss 00:42:17 -to 00:46:43 -i "${SRC_FILE}" -vn -acodec copy "12. 予感.${FILE_EXT}" ffmpeg -ss 00:46:43 -to 00:50:35 -i "${SRC_FILE}" -vn -acodec copy "13. 夢の入口へ.${FILE_EXT}"