diff options
Diffstat (limited to 'ar')
| -rw-r--r-- | ar/.config/rmpc/config.ron | 15 | ||||
| -rwxr-xr-x | ar/.config/rmpc/scripts/on_song_change | 22 | ||||
| -rwxr-xr-x | ar/.local/bin/qndl | 6 |
3 files changed, 35 insertions, 8 deletions
diff --git a/ar/.config/rmpc/config.ron b/ar/.config/rmpc/config.ron index 733baab..892c7c7 100644 --- a/ar/.config/rmpc/config.ron +++ b/ar/.config/rmpc/config.ron @@ -284,7 +284,20 @@ border_symbols: Rounded, pane: Split( direction: Vertical, - panes: [(size: "25%", pane: Pane(AlbumArt)), (size: "70%", pane: Pane(Lyrics), vertical_align: Bottom)], + panes: [ + ( + size: "30%", + pane: Split( + direction: Horizontal, + panes: [ + (pane: Pane(Empty()), size: "43%"), + (pane: Pane(AlbumArt), size: "14%"), + (pane: Pane(Empty()), size: "43%"), + ], + ), + ), + (pane: Pane(Lyrics), size: "70%", vertical_align: Bottom), + ], ), ), ( diff --git a/ar/.config/rmpc/scripts/on_song_change b/ar/.config/rmpc/scripts/on_song_change index 64e9047..2899ab8 100755 --- a/ar/.config/rmpc/scripts/on_song_change +++ b/ar/.config/rmpc/scripts/on_song_change @@ -75,19 +75,33 @@ LRCLIB_INSTANCE="https://lrclib.net" if [ "$HAS_LRC" = "false" ]; then mkdir -p "$(dirname "$LRC_FILE")" + # 1) /api/get with artist + title + album (exact match) LYRICS="$(curl -X GET -sG \ -H "Lrclib-Client: rmpc-$VERSION" \ --data-urlencode "artist_name=$ARTIST" \ --data-urlencode "track_name=$TITLE" \ --data-urlencode "album_name=$ALBUM" \ - "$LRCLIB_INSTANCE/api/get" | jq -r '.syncedLyrics')" + "$LRCLIB_INSTANCE/api/get" | jq -r '.syncedLyrics // empty')" + # 2) /api/get without album if [ -z "$LYRICS" ]; then - rmpc remote --pid "$PID" status "Failed to download lyrics for $ARTIST - $TITLE" --level error - exit + LYRICS="$(curl -X GET -sG \ + -H "Lrclib-Client: rmpc-$VERSION" \ + --data-urlencode "artist_name=$ARTIST" \ + --data-urlencode "track_name=$TITLE" \ + "$LRCLIB_INSTANCE/api/get" | jq -r '.syncedLyrics // empty')" fi - if [ "$LYRICS" = "null" ]; then + # 3) /api/search (fuzzy fallback) + if [ -z "$LYRICS" ]; then + LYRICS="$(curl -X GET -sG \ + -H "Lrclib-Client: rmpc-$VERSION" \ + --data-urlencode "artist_name=$ARTIST" \ + --data-urlencode "track_name=$TITLE" \ + "$LRCLIB_INSTANCE/api/search" | jq -r '.[0].syncedLyrics // empty')" + fi + + if [ -z "$LYRICS" ]; then rmpc remote --pid "$PID" status "Lyrics for $ARTIST - $TITLE not found" --level warn exit fi diff --git a/ar/.local/bin/qndl b/ar/.local/bin/qndl index 2757eb8..ff18e17 100755 --- a/ar/.local/bin/qndl +++ b/ar/.local/bin/qndl @@ -33,13 +33,13 @@ case $type in download_type="music" output_dir="${XDG_MUSIC_DIR:-${HOME}/Music}" archive_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/Music/.music.txt" - ytdl_output_format="${output_dir}/%(artist|)s%(artist& - |)s%(title)s.%(ext)s" + ytdl_output_format="${output_dir}/%(album_artist,artist|Unknown Artist)s/%(album|Unknown Album)s/%(title)s.%(ext)s" ytdl_cmd_base="$ytdl_cmd_base --audio-format best --audio-quality 0 --download-archive \"$archive_file\" --extract-audio --recode-video mp3" ;; -r | --restore | r | restore) output_dir="${XDG_MUSIC_DIR:-${HOME}/Music}" archive_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/Music/.music.txt" - ytdl_output_format="${output_dir}/%(artist|)s%(artist& - |)s%(title)s.%(ext)s" + ytdl_output_format="${output_dir}/%(album_artist,artist|Unknown Artist)s/%(album|Unknown Album)s/%(title)s.%(ext)s" ytdl_cmd_base="$ytdl_cmd_base --audio-format best --audio-quality 0 --extract-audio --recode-video mp3" ytdl_cmd="$ytdl_cmd_base --output \"$ytdl_output_format\"" [ ! -f "$archive_file" ] && exit 1 @@ -127,4 +127,4 @@ tsp -D "$idnum" notify-send "✅ $download_type download complete:" "$url" || notify-send "❌ Faild to download:" "$url" # Conditionally update the music database if the download type is music -[ "$download_type" = "music" ] && tsp -D "$idnum" bash -c "mpc update" +[ "$download_type" = "music" ] && tsp -D "$idnum" bash -c "mpc update --wait && find /home/si/Music -name '*.mp3' | sed 's|/home/si/Music/||' | sort > /home/si/.config/mpd/playlists/entire.m3u" |
