Stampede / itunes-navidrome-migration

Python scripts to transfer iTunes history to a new Navidrome installation
The Unlicense
14 stars 3 forks source link

write_to_annotation error when trying to write changes to database #11

Open VolkanGit opened 3 weeks ago

VolkanGit commented 3 weeks ago

I get the below error:

Writing changes to database: Traceback (most recent call last): File "/home/navidrome/Downloads/itunestoND.py", line 157, in write_to_annotation(artists, 'artist') File "/home/navidrome/Downloads/itunestoND.py", line 61, in write_to_annotation cur.executemany('INSERT INTO annotation VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', annotation_entries) sqlite3.OperationalError: table annotation has 8 columns but 9 values were supplied

c0f commented 5 days ago

It looks like the Navidrome annotation table has been changed and no longer requires the ann_id field.

In itunestoND.py the ann_id field is used in these two lines:

annotation_entries.append((generate_annotation_id(), userID, item_id, entry_type, play_count, play_date, rating, 0, None))

cur.executemany('INSERT INTO annotation VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', annotation_entries)

As a quick test I modified these lines to remove the ann_id field but the script crashes at a different point and I don't have enough understanding of the script to fix it.

This is the Navidrome change that removed the ID field in v0.53.0:

https://github.com/navidrome/navidrome/commit/47378c68828861751b9d1a05d3fc9b29ce8dd9f0

This is the new structure of the annotations table from v0.53.0:

    user_id    varchar(255) default ''    not null,
    item_id    varchar(255) default ''    not null,
    item_type  varchar(255) default ''    not null,
    play_count integer      default 0,
    play_date  datetime,
    rating     integer      default 0,
    starred    bool         default FALSE not null,
    starred_at datetime,
    unique (user_id, item_id, item_type)
VolkanGit commented 2 days ago

I installed version 0.52.5 to see if I still get the error. I don't, so @c0f, I think you were right. I haven't tried to fix the file and see if it works on 0.53.x version.