#!/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='Ahg5FiLUIuo' # 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:02:40 -i "${SRC_FILE}" -vn -acodec copy "00. A Soul as Red as a Ground Cherry!.${FILE_EXT}" ffmpeg -ss 00:02:40 -to 00:05:08 -i "${SRC_FILE}" -vn -acodec copy "01. A Tiny, Tiny, Clever Commander.${FILE_EXT}" ffmpeg -ss 00:05:08 -to 00:07:06 -i "${SRC_FILE}" -vn -acodec copy "02. Because Princess Inada is Scolding Me_1.${FILE_EXT}" ffmpeg -ss 00:07:06 -to 00:13:24 -i "${SRC_FILE}" -vn -acodec copy "03. Bloom Nobly!.${FILE_EXT}" ffmpeg -ss 00:13:24 -to 00:16:55 -i "${SRC_FILE}" -vn -acodec copy "04. Border of Life & Ultimate Truth.${FILE_EXT}" ffmpeg -ss 00:16:55 -to 00:20:11 -i "${SRC_FILE}" -vn -acodec copy "05. Candid Friend!.${FILE_EXT}" ffmpeg -ss 00:20:11 -to 00:24:02 -i "${SRC_FILE}" -vn -acodec copy "06. Carnival.${FILE_EXT}" ffmpeg -ss 00:24:02 -to 00:26:21 -i "${SRC_FILE}" -vn -acodec copy "07. Cherry Blossom.${FILE_EXT}" ffmpeg -ss 00:26:21 -to 00:28:49 -i "${SRC_FILE}" -vn -acodec copy "08. Children's Festival ~ Innocent Treasures_3.${FILE_EXT}" ffmpeg -ss 00:28:49 -to 00:29:40 -i "${SRC_FILE}" -vn -acodec copy "09. Because Princess Inada is Scolding Me_2.${FILE_EXT}" ffmpeg -ss 00:29:40 -to 00:32:53 -i "${SRC_FILE}" -vn -acodec copy "10. Cirno.${FILE_EXT}" ffmpeg -ss 00:32:53 -to 00:37:10 -i "${SRC_FILE}" -vn -acodec copy "11. Cosmic Mind.${FILE_EXT}" ffmpeg -ss 00:37:10 -to 00:40:30 -i "${SRC_FILE}" -vn -acodec copy "12. Crimson in the Black Sea.${FILE_EXT}" ffmpeg -ss 00:40:30 -to 00:42:45 -i "${SRC_FILE}" -vn -acodec copy "13. Eastern Dream.${FILE_EXT}" ffmpeg -ss 00:42:45 -to 00:46:28 -i "${SRC_FILE}" -vn -acodec copy "14. Fate of Sixty Years.${FILE_EXT}" ffmpeg -ss 00:46:28 -to 00:49:49 -i "${SRC_FILE}" -vn -acodec copy "15. Flower Village.${FILE_EXT}" ffmpeg -ss 00:49:49 -to 00:52:33 -i "${SRC_FILE}" -vn -acodec copy "16. Flowering Night_1.${FILE_EXT}" ffmpeg -ss 00:52:33 -to 00:57:29 -i "${SRC_FILE}" -vn -acodec copy "17. Bloom Nobly.${FILE_EXT}" ffmpeg -ss 00:57:29 -to 01:03:17 -i "${SRC_FILE}" -vn -acodec copy "18. History of 60 Years.${FILE_EXT}" ffmpeg -ss 01:03:17 -to 01:06:01 -i "${SRC_FILE}" -vn -acodec copy "19. History of the Moon_1.${FILE_EXT}" ffmpeg -ss 01:06:01 -to 01:09:25 -i "${SRC_FILE}" -vn -acodec copy "20. Border of Life!.${FILE_EXT}" ffmpeg -ss 01:09:25 -to 01:12:41 -i "${SRC_FILE}" -vn -acodec copy "21. Immortal Smoke_1.${FILE_EXT}" ffmpeg -ss 01:12:41 -to 01:16:57 -i "${SRC_FILE}" -vn -acodec copy "22. Invisible Full Moon.${FILE_EXT}" ffmpeg -ss 01:16:57 -to 01:18:52 -i "${SRC_FILE}" -vn -acodec copy "23. Lost Place!.${FILE_EXT}" ffmpeg -ss 01:18:52 -to 01:21:16 -i "${SRC_FILE}" -vn -acodec copy "24. Children's Festival ~ Innocent Treasures_4.${FILE_EXT}" ffmpeg -ss 01:21:16 -to 01:24:38 -i "${SRC_FILE}" -vn -acodec copy "25. Flowering Night_3.${FILE_EXT}" ffmpeg -ss 01:24:38 -to 01:28:39 -i "${SRC_FILE}" -vn -acodec copy "26. Love-Colored Master Spark.${FILE_EXT}" ffmpeg -ss 01:28:39 -to 01:31:31 -i "${SRC_FILE}" -vn -acodec copy "27. Lunatic Princess!.${FILE_EXT}" ffmpeg -ss 01:31:31 -to 01:35:40 -i "${SRC_FILE}" -vn -acodec copy "28. Maiden's Capriccio & Master Spark.${FILE_EXT}" ffmpeg -ss 01:35:40 -to 01:40:13 -i "${SRC_FILE}" -vn -acodec copy "29. Maiden's Capriccio ~ Dream Battle.${FILE_EXT}" ffmpeg -ss 01:40:13 -to 01:43:34 -i "${SRC_FILE}" -vn -acodec copy "30. Moon Insect.${FILE_EXT}" ffmpeg -ss 01:43:34 -to 01:45:46 -i "${SRC_FILE}" -vn -acodec copy "31. Mooned Insect.${FILE_EXT}" ffmpeg -ss 01:45:46 -to 01:48:55 -i "${SRC_FILE}" -vn -acodec copy "32. History of the Moon_2.${FILE_EXT}" ffmpeg -ss 01:48:55 -to 01:51:21 -i "${SRC_FILE}" -vn -acodec copy "33. Children's Festival ~ Innocent Treasures_5.${FILE_EXT}" ffmpeg -ss 01:51:21 -to 01:54:30 -i "${SRC_FILE}" -vn -acodec copy "34. Moriya Shrine.${FILE_EXT}" ffmpeg -ss 01:54:30 -to 01:58:31 -i "${SRC_FILE}" -vn -acodec copy "35. Native Faith & Youkai Mountain.${FILE_EXT}" ffmpeg -ss 01:58:31 -to 02:04:35 -i "${SRC_FILE}" -vn -acodec copy "36. Native Faith_4.${FILE_EXT}" ffmpeg -ss 02:04:35 -to 02:08:29 -i "${SRC_FILE}" -vn -acodec copy "37. Children's Festival.${FILE_EXT}" ffmpeg -ss 02:08:29 -to 02:11:32 -i "${SRC_FILE}" -vn -acodec copy "38. History of the Moon_3.${FILE_EXT}" ffmpeg -ss 02:11:32 -to 02:15:45 -i "${SRC_FILE}" -vn -acodec copy "39. Necrofantasia_1.${FILE_EXT}" ffmpeg -ss 02:15:45 -to 02:18:40 -i "${SRC_FILE}" -vn -acodec copy "40. Native Faith_5.${FILE_EXT}" ffmpeg -ss 02:18:40 -to 02:22:48 -i "${SRC_FILE}" -vn -acodec copy "41. Phantom Ensemble.${FILE_EXT}" ffmpeg -ss 02:22:48 -to 02:24:41 -i "${SRC_FILE}" -vn -acodec copy "42. Plain Asia_1.${FILE_EXT}" ffmpeg -ss 02:24:41 -to 02:28:28 -i "${SRC_FILE}" -vn -acodec copy "43. Necrofantasia_2.${FILE_EXT}" ffmpeg -ss 02:28:28 -to 02:30:01 -i "${SRC_FILE}" -vn -acodec copy "44. Shanghai Alice of Meiji 17_1.${FILE_EXT}" ffmpeg -ss 02:30:01 -to 02:32:57 -i "${SRC_FILE}" -vn -acodec copy "45. Shanghai Teahouse.${FILE_EXT}" ffmpeg -ss 02:32:57 -to 02:38:12 -i "${SRC_FILE}" -vn -acodec copy "46. Silent Ensemble.${FILE_EXT}" ffmpeg -ss 02:38:12 -to 02:40:46 -i "${SRC_FILE}" -vn -acodec copy "47. Sleepless Night of the Eastern Country.${FILE_EXT}" ffmpeg -ss 02:40:46 -to 02:45:35 -i "${SRC_FILE}" -vn -acodec copy "48. Suwa Foughten Field.${FILE_EXT}" ffmpeg -ss 02:45:35 -to 02:48:48 -i "${SRC_FILE}" -vn -acodec copy "49. The Centennial Festival for Magical Girls.${FILE_EXT}" ffmpeg -ss 02:48:48 -to 02:52:15 -i "${SRC_FILE}" -vn -acodec copy "50. The Gensokyo the Gods Loved!.${FILE_EXT}" ffmpeg -ss 02:52:15 -to 02:58:34 -i "${SRC_FILE}" -vn -acodec copy "51. The Grimoire Of Alice.${FILE_EXT}" ffmpeg -ss 02:58:34 -to 03:00:01 -i "${SRC_FILE}" -vn -acodec copy "52. The Youkai Mountain.${FILE_EXT}" ffmpeg -ss 03:00:01 -to 03:03:16 -i "${SRC_FILE}" -vn -acodec copy "53. Plain Asia_3.${FILE_EXT}" ffmpeg -ss 03:03:16 -to 03:06:22 -i "${SRC_FILE}" -vn -acodec copy "54. Tomboyish Girl in Love_1.${FILE_EXT}" ffmpeg -ss 03:06:22 -to 03:10:46 -i "${SRC_FILE}" -vn -acodec copy "55. U.N. Owen & Centennial Festival.${FILE_EXT}" ffmpeg -ss 03:10:46 -to 03:13:59 -i "${SRC_FILE}" -vn -acodec copy "56. Voile, the Magic Library.${FILE_EXT}" ffmpeg -ss 03:13:59 -to 03:18:59 -i "${SRC_FILE}" -vn -acodec copy "57. Voyage 1969.${FILE_EXT}" ffmpeg -ss 03:18:59 -to 03:23:18 -i "${SRC_FILE}" -vn -acodec copy "58. Tomboyish Girl in Love_2.${FILE_EXT}" ffmpeg -ss 03:23:18 -to 03:27:32 -i "${SRC_FILE}" -vn -acodec copy "59. Voyage 1970.${FILE_EXT}" ffmpeg -ss 03:27:32 -to 03:31:38 -i "${SRC_FILE}" -vn -acodec copy "60. White Flag of Usa Shrine.${FILE_EXT}" ffmpeg -ss 03:31:38 -to 03:34:43 -i "${SRC_FILE}" -vn -acodec copy "61. U.N. Owen was Her_1.${FILE_EXT}" ffmpeg -ss 03:34:43 -to 03:36:21 -i "${SRC_FILE}" -vn -acodec copy "62. Wind Circulation ~ Wind Tour.${FILE_EXT}" ffmpeg -ss 03:36:21 -to 03:39:16 -i "${SRC_FILE}" -vn -acodec copy "63. Wind God Girl.${FILE_EXT}" ffmpeg -ss 03:39:16 -to 03:43:20 -i "${SRC_FILE}" -vn -acodec copy "64. Withered Leaf!.${FILE_EXT}" ffmpeg -ss 03:43:20 -to 03:48:03 -i "${SRC_FILE}" -vn -acodec copy "65. U.N Owen was Her_2.${FILE_EXT}"