phauer / migrate-itunes-to-rhythmbox

Script to migrate iTunes playlists, play counts and ratings to Rhythmbox.
GNU General Public License v3.0
38 stars 10 forks source link

Migrate count-ratings not working #20

Open LogicaBorealis opened 4 years ago

LogicaBorealis commented 4 years ago

Hello,

I’m trying to migrate the ratings (and my “intelligent” playlists partly based on song ratings) from my iTunes library with no success.

Context: Ubuntu 19.10 iTunes 12.8.2.3 on W10 Rhythmbox 3.4.3-2ubuntu1

migrate-itunes-to-rhythmbox has been installed following instructions given in issue #18.

Below the terminal output I get; Rhythmbox library is not modified.

XXXXXXXXXXXXXXXX:~ $ migrate-itunes-to-rhythmbox counts-ratings --itunes_library_xml="/media/Commun/Musique/Biblio_modif.xml" --rhythmdb="~/.local/share/rhythmbox/rhythmdb.xml" --source_library_root="D:/Musique/iTunes/iTunes%20Media" --target_library_root="/media/Commun/Musique/iTunes/iTunes%20Media" Reading iTunes library in /media/Commun/Musique/Biblio_modif.xml Adding play counts and ratings to Rhythmbox DB in /home/borealis/.local/share/rhythmbox/rhythmdb.xml Traceback (most recent call last): File "/home/borealis/.local/bin/migrate-itunes-to-rhythmbox", line 76, in cli() File "/home/borealis/.local/lib/python3.7/site-packages/click/core.py", line 716, in call return self.main(args, kwargs) File "/home/borealis/.local/lib/python3.7/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/home/borealis/.local/lib/python3.7/site-packages/click/core.py", line 1060, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/borealis/.local/lib/python3.7/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/borealis/.local/lib/python3.7/site-packages/click/core.py", line 534, in invoke return callback(args, **kwargs) File "/home/borealis/.local/bin/migrate-itunes-to-rhythmbox", line 66, in migrate_counts_ratings rhythmbox_library_root=target_library_root) File "/home/borealis/.local/lib/python3.7/site-packages/migrate_itunes_to_rhythmbox/rhythmbox_count_rating_integrator.py", line 32, in set_values itunes_statistics_dict = craeate_itunes_statistic_dict(itunes_songs, itunes_library_root) File "/home/borealis/.local/lib/python3.7/site-packages/migrate_itunes_to_rhythmbox/rhythmbox_count_rating_integrator.py", line 82, in create_itunes_statistic_dict mapped_rating = ITUNES_TO_RHYTHMBOX_RATINGS_MAP[itunes_rating] KeyError: 25

Thank you for the tool. Tschüss!

Dio94 commented 3 years ago

Hello,

I encountered the almost same issue while trying to migrate my iTunes library to Rhythmbox

Context: elementary OS 5.1.7 (Built on Ubuntu 18.04.4 LTS) iTunes 12.10.10.2 on Windows 10 Rhythmbox 3.4.2

The only difference is in the final terminal output line:

KeyError: 1

From what I understand: My iTunes library XML contains Rating with "1" value that cannot be mapped to Rhythmbox.

<key>Rating</key><integer>1</integer>

the current rating map (src/main/python/migrate_itunes_to_rhythmbox/rhythmbox_count_rating_integrator.py:10)

ITUNES_TO_RHYTHMBOX_RATINGS_MAP = {0: 0, 20: 1, 40: 2, 60: 3, 80: 4, 100: 5, None: None}

Looking at iTunes, all my 0-star rated songs get this rating of 1. I checked the other rating in my file: 20,40,60,80,100, but no 0.

I can't say if it is specific to my iTunes version, but it finally worked by modifying the map to

ITUNES_TO_RHYTHMBOX_RATINGS_MAP = {1: 0, 20: 1, 40: 2, 60: 3, 80: 4, 100: 5, None: None}

or by changing the values in my XML file.

Your KeyError: 25 may be a rating of 25 in your iTunes XML, not included in this map. Can't say why it happens and what is the rating displayed in your iTunes. I don't know any of Python so I can't be sure about this (I mostly do web development on Java/Javascript).

@phauer Could you confirm my answer ? I will try to make my first ever micro pull-request on GitHub if verified across different iTunes versions :).