From ede8407fa4ecc172ec4cd9bdce8dc09bba1e4d88 Mon Sep 17 00:00:00 2001 From: ScriptFanix <62394-ScriptFanix@users.noreply.framagit.org> Date: Sun, 5 Apr 2026 19:57:48 +0200 Subject: [PATCH] Read and copy files ratings (`fmps_rating`) --- atom | 4 +++ lib/database/checkVersion | 2 +- lib/database/upgradedatabase_8_9 | 51 ++++++++++++++++++++++++++++++++ lib/encode/mp3 | 1 + lib/encode/opus | 1 + lib/encode/vorbis | 1 + lib/tags/getInfos::FLAC | 4 ++- lib/tags/getInfos::Opus | 3 +- lib/tags/getInfos::ffmpeg | 4 ++- lib/tags/getInfos::soxi | 3 +- lib/tags/update | 8 +++++ share/schema.sql | 2 ++ 12 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 lib/database/upgradedatabase_8_9 diff --git a/atom b/atom index d903313..3e13606 100755 --- a/atom +++ b/atom @@ -416,6 +416,7 @@ echo ' tags.genre, tags.performer, tags.rate, + tags.rating, tags.releasecountry, tags.replaygain_alb, tags.replaygain_trk, @@ -486,6 +487,8 @@ do rest=${rest#*::AtOM:SQL:Sep::} rate=${rest%%::AtOM:SQL:Sep::*} rest=${rest#*::AtOM:SQL:Sep::} + rating=${rest%%::AtOM:SQL:Sep::*} + rest=${rest#*::AtOM:SQL:Sep::} releasecountry=${rest%%::AtOM:SQL:Sep::*} rest=${rest#*::AtOM:SQL:Sep::} replaygain_alb=${rest%%::AtOM:SQL:Sep::*} @@ -539,6 +542,7 @@ do mimetype \ performer \ rate \ + rating \ releasecountry \ replaygain_alb \ replaygain_trk \ diff --git a/lib/database/checkVersion b/lib/database/checkVersion index 17d12d6..6358273 100644 --- a/lib/database/checkVersion +++ b/lib/database/checkVersion @@ -1,5 +1,5 @@ #!/usr/bin/env bash -currentdbversion=8 +currentdbversion=9 checkDatabaseVersion() { local dbversion if dbversion=$(Select atom version <<<"\"1\" = 1") diff --git a/lib/database/upgradedatabase_8_9 b/lib/database/upgradedatabase_8_9 new file mode 100644 index 0000000..e95cd22 --- /dev/null +++ b/lib/database/upgradedatabase_8_9 @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Copyright © 2012-2026 ScriptFanix +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License v3 is includded in the LICENSE file +# at the root of the project. + +upgradedatabase_8_9() { + echo "Upgrading database to version 9... (backup is $database.bak_v8)" + cp "$database" "$database.bak_v8" + + echo ' + ALTER TABLE tags ADD COLUMN rating FLOAT; + DROP TRIGGER force_destination_update_on_tag_update; + CREATE TRIGGER IF NOT EXISTS force_destination_update_on_tag_update + AFTER UPDATE OF + genre, + albumartist, + year, + album, + disc, + artist, + track, + title, + composer, + performer, + rating, + releasecountry, + replaygain_alb, + replaygain_trk, + rate, + channels, + bitrate, + depth + ON tags + BEGIN + UPDATE destination_files SET last_change=0 + WHERE source_file_id=old.source_file; + END; + ' >&3 + + Update atom version 9 <<<"1 = 1" +} diff --git a/lib/encode/mp3 b/lib/encode/mp3 index d9fdc36..3a1ee25 100644 --- a/lib/encode/mp3 +++ b/lib/encode/mp3 @@ -11,6 +11,7 @@ encodeFile::mp3() { [ -n "$albumartist" ] && lameopts+=(--tv TPE2="$albumartist") [ -n "$composer" ] && lameopts+=(--tv TCOM="$composer") [ -n "$performer" ] && lameopts+=(--tv TOPE="$performer") + [ -n "$rating" ] && lameopts+=(--tv "FMPS_RATING=$rating") [ -n "$releasecountry" ] \ && lameopts+=(--tv TXXX="MusicBrainz Album Release Country=$releasecountry") [ -n "$replaygain_alb" ] \ diff --git a/lib/encode/opus b/lib/encode/opus index 29b833e..02bbb75 100644 --- a/lib/encode/opus +++ b/lib/encode/opus @@ -11,6 +11,7 @@ encodeFile::opus() { [ -n "$disc" ] && opusencopts+=(--comment "DISCNUMBER=$disc") [ -n "$genre" ] && opusencopts+=(--comment "GENRE=$genre") [ -n "$performer" ] && opusencopts+=(--comment "PERFORMER=$performer") + [ -n "$rating" ] && opusencopts+=(--comment "FMPS_RATING=$rating") [ -n "$releasecountry" ] \ && opusencopts+=(--comment "RELEASECOUNTRY=$releasecountry") [ -n "$replaygain_alb" ] \ diff --git a/lib/encode/vorbis b/lib/encode/vorbis index 40007c6..3033315 100644 --- a/lib/encode/vorbis +++ b/lib/encode/vorbis @@ -8,6 +8,7 @@ encodeFile::vorbis() { [ -n "$disc" ] && oggencopts+=(-c "DISCNUMBER=$disc") [ -n "$genre" ] && oggencopts+=(-G "$genre") [ -n "$performer" ] && oggencopts+=(-c "PERFORMER=$performer") + [ -n "$rating" ] && oggencopts+=(--comment "FMPS_RATING=$rating") [ -n "$releasecountry" ] \ && oggencopts+=(-c "RELEASECOUNTRY=$releasecountry") [ -n "$replaygain_alb" ] \ diff --git a/lib/tags/getInfos::FLAC b/lib/tags/getInfos::FLAC index db6e3ac..4c90454 100644 --- a/lib/tags/getInfos::FLAC +++ b/lib/tags/getInfos::FLAC @@ -1,5 +1,5 @@ #!/usr/bin/env bash -getInfosFLAC_version='FLAC-5' +getInfosFLAC_version='FLAC-6' tagreaders+=( "$getInfosFLAC_version" ) getInfos::FLAC() { local \ @@ -17,6 +17,7 @@ getInfos::FLAC() { --show-tag=COMPOSER \ --show-tag=DATE \ --show-tag=DISCNUMBER \ + --show-tag=FMPS_RATING \ --show-tag=GENRE \ --show-tag=PERFORMER \ --show-tag=RELEASECOUNTRY \ @@ -34,6 +35,7 @@ getInfos::FLAC() { disc=$(gettag discnumber) genre=$(gettag genre) performer=$(gettag performer) + rating=$((gettag fmps_rating)) releasecountry=$(gettag releasecountry) replaygain_alb=$(gettag replaygain_album_gain) replaygain_trk=$(gettag replaygain_track_gain) diff --git a/lib/tags/getInfos::Opus b/lib/tags/getInfos::Opus index 0736762..1f8e8ea 100644 --- a/lib/tags/getInfos::Opus +++ b/lib/tags/getInfos::Opus @@ -1,5 +1,5 @@ #!/usr/bin/env bash -getInfosOpus_version='Opus-4' +getInfosOpus_version='Opus-5' tagreaders+=( "$getInfosOpus_version" ) getInfos::Opus() { tagreader="$getInfosOpus_version" @@ -15,6 +15,7 @@ getInfos::Opus() { artist=$(gettag artist) composer=$(gettag composer) disc=$(gettag discnumber) + rating=$(gettag fmps_rating) genre=$(gettag genre) performer=$(gettag performer) releasecountry=$(gettag releasecountry) diff --git a/lib/tags/getInfos::ffmpeg b/lib/tags/getInfos::ffmpeg index f98709d..4813c1b 100644 --- a/lib/tags/getInfos::ffmpeg +++ b/lib/tags/getInfos::ffmpeg @@ -1,5 +1,5 @@ #!/usr/bin/env bash -getInfosffmpeg_version='ffmpeg-9' +getInfosffmpeg_version='ffmpeg-10' tagreaders+=( "$getInfosffmpeg_version" ) getInfos::ffmpeg() { tagreader="$getInfosffmpeg_version" @@ -15,6 +15,7 @@ getInfos::ffmpeg() { artist, \ composer, \ disc, \ + fmps_rating, genre, \ TOPE, \ releasecountry, \ @@ -40,6 +41,7 @@ getInfos::ffmpeg() { disc=$(gettag TAG:disc) genre=$(gettag TAG:genre) performer=$(gettag TAG:TOPE) + rating=$((gettag fmps_rationg)) releasecountry=$(gettag TAG:releasecountry) [[ -z "$releasecountry" ]] \ && releasecountry=$(gettag "TAG:MusicBrainz Album Release Country") diff --git a/lib/tags/getInfos::soxi b/lib/tags/getInfos::soxi index 97e6a4f..3725c7e 100644 --- a/lib/tags/getInfos::soxi +++ b/lib/tags/getInfos::soxi @@ -1,5 +1,5 @@ #!/usr/bin/env bash -getInfosSoxi_version='soxi-3' +getInfosSoxi_version='soxi-4' tagreaders+=( "$getInfosSoxi_version" ) getInfos::soxi() { tagreader="$getInfosSoxi_version" @@ -15,6 +15,7 @@ getInfos::soxi() { artist=$(gettag artist) composer=$(gettag composer) disc=$(gettag discnumber) + rating=$(gettag fmps_rating) genre=$(gettag genre) performer=$(gettag performer) releasecountry=$(gettag releasecountry) diff --git a/lib/tags/update b/lib/tags/update index ad82207..90681a7 100644 --- a/lib/tags/update +++ b/lib/tags/update @@ -20,6 +20,7 @@ updateTags() { tags.disc, tags.genre, tags.performer, + tags.rating, tags.releasecountry, tags.replaygain_alb, tags.replaygain_trk, @@ -86,6 +87,8 @@ echo ' rest=${rest#*::AtOM:SQL:Sep::} oldperformer=${rest%%::AtOM:SQL:Sep::*} rest=${rest#*::AtOM:SQL:Sep::} + oldrating=${rest%%::AtOM:SQL:Sep::*} + rest=${rest#*::AtOM:SQL:Sep::} oldreleasecountry=${rest%%::AtOM:SQL:Sep::*} rest=${rest#*::AtOM:SQL:Sep::} oldreplaygain_alb=${rest%%::AtOM:SQL:Sep::*} @@ -139,6 +142,8 @@ echo ' ${udi:+disc "${disc:-NULL}"} \ ${uge:+genre "${genre:-NULL}"} \ ${upe:+performer "${performer:+::AtOM:FT::}${performer:-NULL}"}\ + ${urr:+rating "${rating:+::AtOM:FT::}${rating:-NULL}"}\ + ${urc:+releasecountry "${releasecountry:+::AtOM:FT::}${releasecountry:-NULL}"}\ ${urc:+releasecountry "${releasecountry:+::AtOM:FT::}${releasecountry:-NULL}"}\ ${urpa:+replaygain_alb "${replaygain_alb:-NULL}"}\ ${urpt:+replaygain_trk "${replaygain_trk:-NULL}"}\ @@ -161,6 +166,7 @@ echo ' title \ composer \ performer \ + rating \ releasecountry \ replaygain_alb \ replaygain_trk \ @@ -178,6 +184,7 @@ echo ' oldtitle \ oldcomposer \ oldperformer \ + oldrating \ oldreleasecountry \ oldreplaygain_alb \ oldreplaygain_trk \ @@ -193,6 +200,7 @@ echo ' udi \ uge \ upe \ + urr \ urc \ urpa \ urpt \ diff --git a/share/schema.sql b/share/schema.sql index d60edaf..17bbfeb 100644 --- a/share/schema.sql +++ b/share/schema.sql @@ -57,6 +57,7 @@ CREATE TABLE IF NOT EXISTS tags ( title TEXT, composer TEXT, performer TEXT, + rating FLOAT, releasecountry TEXT, replaygain_alb TEXT, replaygain_trk TEXT, @@ -131,6 +132,7 @@ CREATE TRIGGER IF NOT EXISTS force_destination_update_on_tag_update title, composer, performer, + rating, releasecountry, replaygain_alb, replaygain_trk,