Skip to content

Commit

Permalink
dzr-srt return empty srt in case of lyric-less track
Browse files Browse the repository at this point in the history
Prevent MPV error: Can not open external file /dev/fd/63.
  • Loading branch information
yne committed Oct 8, 2022
1 parent b52a0ce commit c4f8202
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions dzr-srt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ USR_LIC=$(printf "%s" "$USR_NFO" | jq -r .results.USER.OPTIONS.license_token)
API_TOK=$(printf "%s" "$USR_NFO" | jq -r .results.checkForm)
#printf "SID=$DZR_SID\nAPI=$API_TOK\nLIC=$USR_LIC\nTOK=$USR_TOK\nIDS=$SNG_IDS\n" 1>&2

gw song.getLyrics "$DZR_SID" "$API_TOK" --data "{\"sng_id\":$SNG_IDS}" |
jq -r '.results.LYRICS_SYNC_JSON | map(select(.lrc_timestamp)) | to_entries | map([.key+1, "00:"+.value.lrc_timestamp[1:-1] + .value.milliseconds, (.value.duration|tonumber/1000|tostring), .value.line])[]|@tsv' |
gw song.getLyrics "$DZR_SID" "$API_TOK" --data "{\"sng_id\":$SNG_IDS}" | jq -r 'if (.results.LYRICS_SYNC_JSON) then .results.LYRICS_SYNC_JSON | map(select(.lrc_timestamp)) | to_entries | map([.key+1, "00:"+.value.lrc_timestamp[1:-1] + .value.milliseconds, (.value.duration|tonumber/1000|tostring), .value.line])[]|@tsv else "1\t00:00:00.0\t0.0\t" end' |
while IFS=$'\t' read -r id start length text; do
from=$(date +%H:%M:%S,%N --date "$start") ;
to=$(date +%H:%M:%S,%N --date "$start + $length second") ;
Expand Down

0 comments on commit c4f8202

Please sign in to comment.