Last FM plays import script
#16
Thank you Karellen, I followed your words and could import the CVS and saved the database.

Now, I have trouble with step 5 on my Mac with python --version Python 2.7.10
(I'm using Kodi 18.3 on libreelec. python --version Python 2.7.15 throws the same error.)

python last_fm_import.py
Traceback (most recent call last):
  File "last_fm_import.py", line 118, in <module>
    main()
  File "last_fm_import.py", line 94, in main
    cur.execute("SELECT DISTINCT Artist, Title FROM plays")
sqlite3.OperationalError: no such table: plays

My Kodi database is named MyMusic72.db.

2 zero byte files are created as well.
Image

This is what I have done:
Image
Image

Step 2 tells something about Artist,Album,Title,DatePlayed

Should I change it to Artist,Album,Title,plays and create the database again?

EDIT: no, that did not work either.
Reply
#17
(2019-07-29, 11:11)xbozzo Wrote: Should I change it to Artist,Album,Title,plays and create the database again?

EDIT: no, that did not work either.
The name of the field "DatePlayed" is not the problem. The clue is in the error message:
"sqlite3.OperationalError: no such table: plays"
 
The script is complaining that there is no table called "plays".

Sorry I have not read pack the rest of this thread to understand more details, and I just don't have the spare time.
Reply
#18
(2019-07-29, 13:53)DaveBlake Wrote: The script is complaining that there is no table called "plays".

I was under the impression, that a table "plays" was created, as shown in the above screenshot:
Image

Maybe the script complains about a missing table plays in the kodi database MyMusic72.db ?

Anyone?
Reply
#19
Just a thought, but I know from some of my clients how easy it can be at times to overlook something.  @xbozzo , you have clicked "Write changes" to actually write the new db back to disk ?
Learning Linux the hard way !!
Reply
#20
(2019-07-29, 14:06)black_eagle Wrote: Just a thought, but I know from some of my clients how easy it can be at times to overlook something.  @xbozzo , you have clicked "Write changes" to actually write the new db back to disk ?
Valid point :-) but the screenshot is made from the re-opened database lastfm.db on my harddrive.

(in addition, DB Browser asks for saving, when you try to close an edited/unsaved database. Also, the keyboard-shortcut CMD+S for save is working too) ;-)

When I browse the db, there is a table called plays
Image
Reply
#21
Ok, analyzing the script, I found the culprit:

    # create a database connection
    database = "databases\lastfm.db"
    conn = create_connection(database)

    # create a database2 connection
    database2 = "databases\MyMusic72.db"
    conn2 = create_connection(database2)

The script tries to open/write (or whatever) the databases from a subdirectory databases\ which is non-existant.

Moreover, the \ backslash is not working as a folder separator here on Mac, (nor on LibreElec/OpenElec/*nix). Its just part of the filename, as you can see in the above screenshot.


I had posted the screenshot before, but did not realize it could be a problem, because on Mac a filename can look this way w/o causing a problem:
Image

So, I changed the script slightly (just removed the databases\ part)
   # create a database connection
    database = "lastfm.db"
    conn = create_connection(database)

    # create a database2 connection
    database2 = "MyMusic72.db"
    conn2 = create_connection(database2)

...and voilá,  it worked :-)

Thank you all for helping me nailing it down to a point, where I can fix it :-))
Reply
#22
Awesome, great to hear it worked. Thanks all for the help...

Hopefully one day someone more skilled in python will write a Kodi Add-on which does all this automatically Smile The last.fm API works pretty good so it should be easy to bypass the export to csv bit.

I still use this script all the time with my Kodi installs and it makes Music come alive when you have the plays for the last 10 years backed up online and distributed around my Kodi clients.
Image Image
Reply
#23
(2019-07-29, 22:58)docwra Wrote: The last.fm API works pretty good
No, it does not ;-)

I tried those Browsers: Internet Explorer (Win), Google Chrome (Mac/Win), Safari (Mac), Waterfox (Win/Mac) and Vivaldi (Win) and none of them could load the whole 222,002 Scrobbles of my last.fm user.

The progress always stopped at 420/1111, so I guess, there is a strange character or some limitation, or just too less RAM involved.

I checked all the exported/saved data and they all had slighlty different content (mostly some doublettes were not exported/skipped sometimes and sometimes not).

I tried an alternate api key and request delays from 0 to 500ms,
but hey, at least the great Webservice at https://benjaminbenben.com/lastfm-to-csv/ allows to save partial states of the exported data, so I now have about 80.400 scrobbles imported in Kodi. ;-]

This is not a problem we need to discuss here, but its a pitty that things always have to be that complicated ;-/
Reply
 
Thread Rating:
  • 1 Vote(s) - 3 Average



Logout Mark Read Team Forum Stats Members Help
Last FM plays import script31