Update LyricExtractor.bash
This commit is contained in:
parent
ed42afc35a
commit
96b2daa0a7
1 changed files with 28 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
scriptVersion="1.0"
|
scriptVersion="1.2"
|
||||||
scriptName="LyricExtractor"
|
scriptName="LyricExtractor"
|
||||||
|
|
||||||
#### Import Settings
|
#### Import Settings
|
||||||
|
@ -9,10 +9,6 @@ source /config/extended/functions
|
||||||
#### Create Log File
|
#### Create Log File
|
||||||
logfileSetup
|
logfileSetup
|
||||||
|
|
||||||
if [ -z "$lidarr_album_id" ]; then
|
|
||||||
lidarr_album_id="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
|
|
||||||
if [ "$lidarr_eventtype" == "Test" ]; then
|
if [ "$lidarr_eventtype" == "Test" ]; then
|
||||||
|
@ -20,10 +16,23 @@ if [ "$lidarr_eventtype" == "Test" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
getAlbumArtist="$(curl -s "$lidarrUrl/api/v1/album/$lidarr_album_id" -H "X-Api-Key: ${lidarrApiKey}" | jq -r .artist.artistName)"
|
verifyConfig
|
||||||
getAlbumArtistPath="$(curl -s "$lidarrUrl/api/v1/album/$lidarr_album_id" -H "X-Api-Key: ${lidarrApiKey}" | jq -r .artist.path)"
|
getArrAppInfo
|
||||||
getTrackPath="$(curl -s "$lidarrUrl/api/v1/trackFile?albumId=$lidarr_album_id" -H "X-Api-Key: ${lidarrApiKey}" | jq -r .[].path | head -n1)"
|
verifyApiAccess
|
||||||
|
|
||||||
|
if [ -z "$lidarr_album_id" ]; then
|
||||||
|
lidarr_album_id="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
getAlbumArtist="$(curl -s "$arrUrl/api/v1/album/$lidarr_album_id" -H "X-Api-Key: ${arrApiKey}" | jq -r .artist.artistName)"
|
||||||
|
getAlbumArtistPath="$(curl -s "$arrUrl/api/v1/album/$lidarr_album_id" -H "X-Api-Key: ${arrApiKey}" | jq -r .artist.path)"
|
||||||
|
getTrackPath="$(curl -s "$arrUrl/api/v1/trackFile?albumId=$lidarr_album_id" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].path | head -n1)"
|
||||||
getFolderPath="$(dirname "$getTrackPath")"
|
getFolderPath="$(dirname "$getTrackPath")"
|
||||||
|
getAlbumFolderName="$(basename "$getFolderPath")"
|
||||||
|
|
||||||
|
log "Processing :: $getAlbumFolderName :: Processing Files..."
|
||||||
|
|
||||||
if echo "$getFolderPath" | grep "$getAlbumArtistPath" | read; then
|
if echo "$getFolderPath" | grep "$getAlbumArtistPath" | read; then
|
||||||
if [ ! -d "$getFolderPath" ]; then
|
if [ ! -d "$getFolderPath" ]; then
|
||||||
|
@ -53,6 +62,16 @@ find "$getFolderPath" -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" -print0 |
|
||||||
log "Processing :: $getAlbumFolderName :: $fileName :: Getting Lyrics from embedded metadata"
|
log "Processing :: $getAlbumFolderName :: $fileName :: Getting Lyrics from embedded metadata"
|
||||||
getLyrics="$(ffprobe -loglevel 0 -print_format json -show_format -show_streams "$file" | jq -r ".streams[].tags.LYRICS" 2>/dev/null | sed "s/null//g" | sed "/^$/d")"
|
getLyrics="$(ffprobe -loglevel 0 -print_format json -show_format -show_streams "$file" | jq -r ".streams[].tags.LYRICS" 2>/dev/null | sed "s/null//g" | sed "/^$/d")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$getLyrics" ]; then
|
||||||
|
lrcFile="${file%.*}.lrc"
|
||||||
|
log "Processing :: $getAlbumFolderName :: $fileName :: Extracting Lyrics..."
|
||||||
|
echo -n "$getLyrics" > "$lrcFile"
|
||||||
|
log "Processing :: $getAlbumFolderName :: $fileName :: Lyrics extracted to: $fileNameNoExt.lrc"
|
||||||
|
chmod 666 "$lrcFile"
|
||||||
|
else
|
||||||
|
log "Processing :: $getAlbumFolderName :: $fileName :: Lyrics not found..."
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
duration=$SECONDS
|
duration=$SECONDS
|
||||||
|
|
Loading…
Reference in a new issue