Created
June 19, 2024 13:38
-
-
Save polprog/aa2f8001b211ab982724dbab091b654b to your computer and use it in GitHub Desktop.
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 | |
# Convert youtube timestamps to CUE file | |
# polprog 2024 | |
# Released on 3 clause BSD License | |
# Use: ./yt2cue.sh [description.txt] > title.cue | |
filename=$1 | |
gawk ' | |
BEGIN { FS = "-"; trackid = 1; | |
print "PERFORMER \"XXX\""; | |
print "TITLE \"XXX\""; | |
print "FILE \"XXX\""; | |
} | |
/^[0-9]{0,2}:?[0-9]{1,2}:[0-9]{2}/ { | |
gsub(/^ +| +$/, "", $2); | |
gsub(/^ +| +$/, "", $3); | |
print " TRACK " trackid " AUDIO"; | |
print " TITLE \"" $3 "\""; | |
print " PERFORMER \"" $2 "\""; | |
# Handle >1 hour | |
n = split($1, time, ":"); | |
# Trim whitespace | |
for(i = 1; i <= n; i++) gsub(/ /,"",time[i]); | |
if(length(time) > 2){ | |
#print $1 " longer than 1h"; | |
#print time[1] " " time[2] " " time[3] "x"; | |
print " INDEX 01 " int(time[1])*60 + int(time[2]) ":" time[3] ":00"; | |
} else { | |
print " INDEX 01 " time[1] ":" time[2] ":00"; | |
} | |
trackid ++; | |
} | |
' < "${filename}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment