Created
June 14, 2022 18:19
-
-
Save uahim/38ddf940b2042b787a31665ae81ba71f to your computer and use it in GitHub Desktop.
converts YouTube 00:00 Track 1 format to tracklist and .cue files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # usage: | |
| # yt2cue.sh source_file "artist" "album title" | |
| # set to 1 to debug :=) | |
| debug=0 | |
| i="0" | |
| > yt2cue.cue | |
| > yt2cue.txt | |
| # chapters="${chapters//$'\r'/}" | |
| if [[ -z "$2" ]]; then | |
| performer=PERFORMERPLACEHOLDER | |
| else | |
| performer=$2 | |
| fi | |
| if [[ -z "$3" ]]; then | |
| release=RELEASEPLACEHOLDER | |
| else | |
| release=$3 | |
| fi | |
| echo "PERFORMER \"$performer\"" > yt2cue.cue | |
| echo "TITLE \"$release\"" >> yt2cue.cue | |
| echo "FILE \"\" MP3" >> yt2cue.cue | |
| printf "\n" >> yt2cue.cue | |
| while read -r line; do | |
| i=$((i+1)) | |
| number="$i" | |
| prefix="" | |
| # timecode=$(echo ${line}|sed "s#\([0-9]*:[0-9]*\) .*#\1#g") | |
| #tracklist=$(echo ${line}|sed "s#\([0-9]*:[0-9]*\) \(.*\)#\2#g") | |
| line="${line//$'\r'/}" | |
| line="${line//$'\n'/}" | |
| [[ $line =~ ^([0-9][0-9]\:[0-9][0-9])( .*) ]] | |
| timecode="${BASH_REMATCH[1]}" | |
| tracklist="${BASH_REMATCH[2]}" | |
| tracklist=${tracklist:1:200} | |
| match='^([0-9][0-9]:[0-9][0-9]) (.*)' | |
| [[ $line =~ $match ]] | |
| timecode="${BASH_REMATCH[1]}" | |
| tracklist="${BASH_REMATCH[2]}" | |
| if [[ $tracklist == *" - "* ]]; then | |
| match='(.*) - (.*)' | |
| [[ $tracklist =~ $match ]] | |
| performert="${BASH_REMATCH[1]}" | |
| title="${BASH_REMATCH[2]}" | |
| else | |
| performert=${performer} | |
| title=${tracklist} | |
| fi | |
| if ((number<=9));then | |
| prefix="0" | |
| fi | |
| echo " TRACK $prefix$number AUDIO" | |
| echo " PERFORMER \"$performert\"" | |
| echo " TITLE \"$title\"" | |
| echo " INDEX 01 $timecode:00" | |
| printf "\n" | |
| echo "$prefix$number. $tracklist" >> yt2cue.txt | |
| done < "$1" >> yt2cue.cue | |
| echo "cue written" | |
| echo "tracklist written" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment