This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Updating Statistics with my own script

Tags: None
(comma "," separated)
User avatar
grubs
Registered Member
Posts
3
Karma
0
Hello,

I was hoping someone could give me some general information about statistics in Amarok. A broad question, let me explain what I want to do.

I listen to music all day on my media player and would like to roughly capture my playcounts. Assuming that I will take the time to note how often I listen to the various albums, I want to write a quick python/mysql script I can aim at a directory and (given a number) will increase the playcount of said file.

I noticed that there are three statistics tables in the Amarok database:
[*] statistics
[*] statistics_tag
[*] statistics_permanent

Updating the first one doesn't look to be too bad, but I'm curious if I need to worry about the other two? Are there any other fields that I should update while I'm at it.
User avatar
grubs
Registered Member
Posts
3
Karma
0
To answer my own question, updating the that playcount and accessdate for the statistics table seems to work. In my limited testing, I have not noticed any malfunctions.

(note all this is for Amarok 2.3.1)
User avatar
grubs
Registered Member
Posts
3
Karma
0
OK, here is a script 'bumping' a file's playcount with Amarok 2. The script does the following:

  • For each file in the directory, check if it is a audio file (mp3, flac, ogg, m4a).
  • Find the id of the file’s url by looking in the urls table.
  • Next look for an entry in the statistics table.
  • If there is an entry, increase the playcount by the given number and update the date of the last access to now.
  • If there is not an entry, set the playcount to the given number and set both the create and access date to now. Additionally, set the score and rating to 0 (feel free to adjust these your desired hard-code number).

http://blog.lostpaperclips.com/2010/11/06/python-script-for-bumping-playcount-in-amarok2-version-001
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS
Could you please upload this script to http://kde-apps.org so it can be downloaded with the Script Manager? Please also check you put it in the correct section of "Multimedia", there is "Amarok Scripts" which are for Amarok 1.4.x and "Amarok 2.0 Scripts" for Amarok 2.x. The Script Manager will not search elsewhere than in "Amarok 2.0 Scripts".

Also please test your script with the latest Amarok version which is Amarok 2.3.2 currently.


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], Sogou [Bot]