Neutron Music Player Song Ratings - Database transfer

Support questions for Neutron Player only.
Post Reply
tgutwin
Posts: 4
Joined: Fri Jan 20, 2017 5:33 am

Neutron Music Player Song Ratings - Database transfer

Post by tgutwin » Fri Jan 20, 2017 5:52 am

I figured out how to access and restore the song ratings in the Neutron music player (Android). I needed to transfer all the 1000s of song ratings from an old android pad to a new one.
I also posted this on by Blog page at http://links.webarts.ca/NeutronSongRatingsDB

1st off - Neutron is a fantastic music player.
but, there is next to no documentation on the forum so here is how I did it, with all the details.
Neutron stores its user settings in an SQLite database.
The settings database file is /sdcard/Android/data/com.neutroncode.mp/neutronmp.db

1st you can look at the song ratings with this SQL query:

Code: Select all

 SELECT
          s.guid, s.filename, s.title, r.user
    FROM
          plist_music_details s, rating_music r
    where
          s.guid=r.guid
    order by
          r.user desc;
Do the following AFTER you have added the folder of songs to the new installation

Copy the old existing db file AND the new one (with different names) to a desktop computer where it is easier to access with a more robust database client that will support SQLite files. I use SquirrelSQL db client.

Connect to the old database file.

The table holding the ratings is called RATING_MUSIC
but you have to relate the ratings to the song table KEY: GUID

Query the old database to get the ratings related to the song names. The song names are in one table (plist_music_details), the ratings (rating_music) in another
Here is SQL:

Code: Select all

 SELECT s.title, r.user
        FROM plist_music_details s, rating_music r
        where s.guid=r.guid;
Connect to new Database file.

I execute One query for each rating level (1-5) with a list of its songs
I used the song title to get the current/new database KEY: GUID for the song,
then I added the rating linked to that GUID key
Here is the SQL to add ratings for songs with rating=5 linked to the songs:

Code: Select all

INSERT into rating_music
            SELECT s.guid, 5, strftime('%s','now'), null
            FROM plist_music_details s
            WHERE s.title IN
            (
              '4 White Stallions / Big Yellow Taxi',
              'Light In The Tunnel',
              'Surprise Surprise',
              '4 White Stallions / Big Yellow Taxi',
              'Light In The Tunnel',
              'Surprise Surprise',
              'Premonition',
              'Vanhalen Rightnow',
              'Cadillac Ranch',
              'Birdland',
              'Spanish Fly'
           )
Add all the songs previously queried in step 3 with rating 5 (field=user) to the list of song names.

One for each rating level and change te hard-coded 5 to a 4 or 3 etc. I took the results from step 3 and, in my text editor and added the quotes, then copied into the SQL and ran it.

Backup the neutronmp.db file and Copy the newly updated neutronmp.db file back to your android device.

Restart Neutron

Now all my ratings are imported into my new Neutron installation.

GenesisBoy
Posts: 34
Joined: Tue Jul 05, 2016 6:05 am

Re: Neutron Music Player Song Ratings - Database transfer

Post by GenesisBoy » Wed Mar 08, 2017 8:56 pm

Hi,

I'm following your steps as closely as I can but I can't get this to work.

First of all you gave no tutorial on using Squirrel and I couldn't figure it out so I'm using SQLite DB Browser instead.

I have run your
SELECT s.title, r.user
FROM plist_music_details s, rating_music r
where s.guid=r.guid;
code and got a table of all my songs with ratings.

I pasted this to notepad++ and isolated all the 5 star rating songs, did a few find and replace operations and was left with a list that looks like this:
'Hurts Like Heaven',
'God Knows (The Melancholy of Haruhi Suzumiya)',
'Mine',
'How Far I''ll Go (Instrumental)',

There are 218 lines total. I opened the new db file and made sure to omit the comma for the last song so my code ends like this:
'Inter-Dimensional Tornado'
)

However, I'm getting this error:
UNIQUE constraint failed: rating_music.guid: INSERT into rating_music

Can you please help me?


EDIT: I figured out the problem. The reason I was getting this error is because I had multiple songs with the same name. These songs had been rated 5 stars when I first ran your code, and then when I tried running the code for 4 stars it saw that the songs were already rated so just spat out that error. I fixed it by removing chunks of songs until the code successfully executes, put back the songs I had removed and remove a smaller portion of it, etc. until those problem songs were all removed (trial and error.. such fun) and then manually rating those songs in the app. Thankfully only 3 songs had that issue in my case!

GenesisBoy
Posts: 34
Joined: Tue Jul 05, 2016 6:05 am

Neutron Song Ratings - Database Transfer IMAGE TUTORIAL

Post by GenesisBoy » Thu Mar 09, 2017 7:09 am

I've made my own guide with screenshots to make it easier to follow, as well as troubleshooting if you run into errors.
http://neutronmp.com/forum/viewtopic.ph ... 3729#p9091

konrad_a
Posts: 1
Joined: Sun Oct 21, 2018 7:46 pm

Re: Neutron Music Player Song Ratings - Database transfer

Post by konrad_a » Sun Oct 21, 2018 7:50 pm

I haven't tried it but I think it would be much simpler to connect both databases side-by-side and copy ratings from one to another.

See example here:
http://www.sqlitetutorial.net/sqlite-attach-database/

Quote:
"After that, create a new table named people in the contacts database and populate data from the customers table in the main database.
sqlite> CREATE TABLE contacts.people(first_name text, last_name text);
sqlite> INSERT INTO contacts.people SELECT firstName, lastName FROM customers;
"

theSplund
Posts: 16
Joined: Tue Jul 28, 2020 5:20 pm

Re: Neutron Music Player Song Ratings - Database transfer

Post by theSplund » Wed Aug 05, 2020 12:04 am

If it's of any interest (and it may serve to provide inspiration to someone else) I previously used the 'composer' tag to carry over some data from iTunes to the GoneMad Media Player app (it has Smart playlists similar to iTunes but Neutron sounds better) and so my 'composer' tag currently ends in '2', '4' or '5' (no composer tags end with a number '3' * and I don't have any '1' star ratings on my player). So I have entries such as this in my 'plist_composer' table:
guid name
-8430419694695713341 Studio2
-8073009486047502622 LiveAlbum/Set4
-6150534388217295186 Session4
-5794568792440432565 Classical4
(as you can see, I can also can categorise/filter by type of recording - I use the 'Grouping' field in iTunes for this)

Using the data in the above table, I wrote the code below to initiate** the 'ratings_music' table first for all tracks in the 'plist_music_details' table and then copy the 'composer' (as a guid) from the 'plist_music_details' to the 'ratings_music' table 'user 'field (from the 'plist_music_details' table) and then replace the guid with the 'composer' and then trim that 'composer' to just the last character, ie the rating (though for '3' I tweaked it a little).

INSERT INTO Rating_music (guid)
SELECT Plist_music_details.guid
FROM Plist_music_details
left join Rating_music on Plist_music_details.guid = rating_music.guid
WHERE rating_music.guid is null;

UPDATE rating_music
SET user = (SELECT composer
FROM plist_music_details
WHERE plist_music_details.guid = rating_music.guid);

UPDATE rating_music
SET user = (SELECT name
FROM plist_composer
WHERE rating_music.user = guid);

UPDATE rating_music
SET user = '5'
WHERE SUBSTR(user,-1)='5';

UPDATE rating_music
SET user = '4'
WHERE SUBSTR(user,-1)='4';

UPDATE rating_music
SET user = '2'
WHERE SUBSTR(user,-1)='2';

UPDATE rating_music
SET user = '3'
WHERE user <> '2' AND user <>'4' AND user <> '5';

It's not how I wanted to do it, ie with lots of lovely JOINs etc, but SQLite didn't want to do half of the things I'd normally do (I was trying to go with 1 or 2 single SQL statements to do the whole process).
FYI, in my first attempt, I had tried linking the neutronmp.db to an exported iTunes library (as an xml that was then converted to an SQLite db) and use the ratings field directly (dividing it by 20) but, whilst it sort of worked, I found far too many inconcistancies with the result - a shame as it would have served as a solution for anyone using iTunes - I may return to it one day, but this method works for me. Using this composer field that I'd set up for the GMMP app I found that it completely removed the problem of duplicates and it takes an 'nth' of a second to process 20,000+ ratings. Hopefully it's simple enough to read/understand.

I've got a crude way of looking to check for the changes made in Neutron so that I can update iTunes (smply by producing a simple list for now) with any changes.
If anyone has any idea as to what the 'auto' and 'data' fields in the 'ratings_music' table are used for then please shout out as currently I am looking to use one of those fields to allow my change-checking code to run.

I forgot to mention that I use JRT Studios iSyncr app to transfer my music to my FiiO player.
Happy reading
:)

*due to the bell curve-like distribution of of my ratings it was easier to leave 3s unchanged
**Not sure 'initiate' is the correct term ;-)

Xp98
Posts: 2
Joined: Fri Sep 09, 2022 6:11 am

Re: Neutron Music Player Song Ratings - Database transfer

Post by Xp98 » Fri Sep 09, 2022 6:21 am

Hello
I red this topic, but it's way too complicated for me :(

I have several android DAPs, all with the same media library (FLAC files) and I'd like to know if there is another and easier way to transfer my ratings of the songs from one player to another ?

theSplund
Posts: 16
Joined: Tue Jul 28, 2020 5:20 pm

Re: Neutron Music Player Song Ratings - Database transfer

Post by theSplund » Wed Sep 21, 2022 8:28 am

Xp98 wrote:
Fri Sep 09, 2022 6:21 am
Hello
I red this topic, but it's way too complicated for me :(

I have several android DAPs, all with the same media library (FLAC files) and I'd like to know if there is another and easier way to transfer my ratings of the songs from one player to another ?
I'd say that there's no way you could merge the ratings together without resorting to some program, or programming, as the NeutronMP app holds the ratings in table within its database (and the table, and track identifiers, are going to be unique to each install). A possible approach, if one device was considered to be the 'master' and held all the ratings, would be to consider a clone/copy of the music folder and the NeutronMP folder from the 'master' device to the others but I'm not at all confident that this would work without a great degree of luck - also, this still would not allow any 'synching' of ratings across devices once it was done.
A footnote: I've not found a way to easily take the rating found in the attributes/tags of a file and transfer it into the NeutronMP database either (or a method to update that attribute/tag when changes are made in the app); I feel that it's a bit of an oversight in many music apps, and I (really) hate to say that the iPod handles this problem brilliantly :(

Xp98
Posts: 2
Joined: Fri Sep 09, 2022 6:11 am

Re: Neutron Music Player Song Ratings - Database transfer

Post by Xp98 » Mon Oct 03, 2022 5:58 pm

At least, thank you for answering me :)

theSplund
Posts: 16
Joined: Tue Jul 28, 2020 5:20 pm

Re: Neutron Music Player Song Ratings - Database transfer

Post by theSplund » Mon Oct 03, 2022 10:27 pm

Xp98 wrote:
Mon Oct 03, 2022 5:58 pm
At least, thank you for answering me :)
:)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 41 guests