clerk icon indicating copy to clipboard operation
clerk copied to clipboard

Can't find a way to rate albums nor songs

Open Tonus1 opened this issue 5 years ago • 5 comments

Hi, I believe I've read the whole documentation but still can't find how to use the clerk_rating_client... I saw the service file : is it because my distribution do not ship systemd thing ? Sorry if the answer is obvious but I feel lost with this !

Tonus1 avatar Nov 03 '18 22:11 Tonus1

The clerk_rating_client only serves one purpose: write ratings to your audiofiles (id3v2 or vorbiscomment). Most users most likely don't even want/need this, since mpd cannot read those ratings anyway.

Why does it exist? Because mpd loses ratings for files that have been moved/renamed. By storing it into tags, it's possible to restore ratings easily.

Anyway, this is most likely not what you are looking for. Rating itself (which will be stored in mpds sticker file) are done via clerk's album/track lists. simply hit enter on your selected tracks and then you see a submenu, which includes the ability to rate. Once tracks/albums have been rated (and clerks cache updated) you can filter album/track lists by rating. Simply add "r=foobar" to your filter.

So to make things short: There is nothing you have to do except enabling sticker_file support in your mpd config. btw: Rated tracks also appear rated in e.g. cantata

carnager avatar Nov 04 '18 18:11 carnager

On Sun, Nov 04, 2018 at 10:23:44AM -0800, Rasmus Steinke wrote:

The clerk_rating_client only serves one purpose: write ratings to your audiofiles (id3v2 or vorbiscomment). This is most likely not what you are looking for. Rating itself (which will be stored in mpds sticker file) are done via clerk's album/track lists. simply hit enter on your selected tracks and then you see a submenu, which includes the ability to rate.

So to make things short: There is nothing you have to do except enabling sticker_file support in your mpd config. btw: Rated tracks also appear rated in e.g. cantata

Thanks for your reply ! It now seems obvious, can't figure out how I've missed the "Rate this track/album" option :D

You're actually right, I think it would have be great if tracks/albums could have been rated while playing, straight from the playlist.

I'll have a look if I can bind a key to that.

Tonus1 avatar Nov 05 '18 23:11 Tonus1

At the moment I only have a bash script to do this, but yeah, I guess this should be included into clerk. PR welcome :)

#!/usr/bin/env bash

numbers="$(printf '%s\n' {0..10})"
menu=$(printf '%s\n' "${numbers}" | rofi -dmenu -p '> ')
exit_code=$?
if [[ $exit_code -eq 1 ]]; then
	exit
fi
current_uri="$(mpc current -f '%file%')"
tags=$(mpc find -f '%albumartist%\t%album%\t%date%' filename "${current_uri}")
while IFS=$'\t' read -r -a my_tags
do
	artist="${my_tags[0]}"
	album="${my_tags[1]}"
	date="${my_tags[2]}"
	mpc find albumartist "${artist}" album "${album}" date "${date}" | while read uri
	do
		if [[ $menu == "0" ]]; then
			mpc sticker "${uri}" delete albumrating
		else
			mpc sticker "${uri}" set albumrating "${menu}"
		fi
	done
done <<< "${tags}"

carnager avatar Nov 06 '18 01:11 carnager

Hi, I would rather have rated the current song. So, looking at your script I made one. It also updates the POPM id3v2 tag, using rofi. Might want a alternative to write albumrating and/or deal with other audio formats (will have a look for flac that I also use, but don't know what other format would worth a look). Need some big improvements still. Could be a start point.

As a note, I tried to make the POPM rating coherent with the star rating I found for other popular media players.

#! /bin/bash
numbers="$(printf '%s\n' {0..10})"
current_uri="$(mpc current -f '%file%')"
tags=$(mpc find -f '%title%\t%artist%\t%album%' filename "${current_uri}")
song=`mpc find -f '%title% - %artist% - %album%' filename "$(mpc current -f '%file%')"`
object=`echo "add rating to  >>>  "$song"  >>> "`
menu=$(printf '%s\n' "${numbers}" | rofi -dmenu -p "$object" -eh 1 -l 1 -columns 11 )
user=$(whoami)
file=$(mpc current -f '%file%' | sed -e 's/\ /\\ /g' | sed -e 's/(/\\(/g' | sed -e 's/)/\\)/g')
exit_code=$?
if [[ $exit_code -eq 1 ]]; then
        exit
fi

        if [[ $menu == "0" ]]; then
                mpc sticker "${current_uri}" delete songrating
                mpc sticker "${current_uri}" delete POPM
                mid3v2 --delete-frames=POPM ~/music/"$file"
        else
            	case "$menu" in
                        '1')
                        menu_value="1"
                        ;;
                        '2')
                        menu_value="30"
                        ;;
                        '3')
                        menu_value="64"
                        ;;
                        '4')
                        menu_value="90"
                        ;;
                        '5')
                        menu_value="128"
                        ;;
                        '6')
                        menu_value="150"
                        ;;
                        '7')
                        menu_value="173"
                        ;;
                        '8')
                        menu_value="196"
                        ;;
                        '9')
                        menu_value="210"
                        ;;
                        '10')
                        menu_value="255"
                        ;;
                esac

        mpc sticker "${current_uri}" set songrating "${menu}"
        mpc sticker "${current_uri}" set POPM "${menu_value}"
        mid3v2 -e --POPM "$user:$menu_value:1" ~/music/"$current_uri"
        fi
file_tag=$(mid3v2 -l ~/music/"$current_uri")
echo "$file_tag"
sticker_lines=`mpc sticker "${current_uri}" list | wc -l`
mpc sticker "${current_uri}" list | rofi -dmenu -l $sticker_lines -p "Stickers for "$song" are "

Tonus1 avatar Nov 13 '18 21:11 Tonus1

Before I can close the issue I would like to know if there is a trick to search or filter song from the ratings in the tmux view ?

I mostly use the tmux interface and would like to add my prefered songs randomly with the tmux interface.

If not possible, any hints on how tho achieve this would be welcome !

Tonus1 avatar Jan 25 '20 21:01 Tonus1