
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
(For the Amarok 2 port of logger, see http://kde-apps.org/content/show.php?content=107836 )
logger is an Amarok script that logs all songs listened. The reason why I had to write it as a score script is that I wanted the information how long the song was listened. The script imitates the behaviour of the default score script. Additionally, each song (genre, artist, album, title) listened for more than 50 % is stored in an SQLite database (per month). So, nice statistics can be produced.
The database is located in ~/.kde/share/apps/amarok/scripts-data/logger.db.
The playstat script is an example statistics script. It can be run from a console (and will print some status messages to STDERR there) or from Amarok's script interface. It has an INI-Style configuration file at ~/.kde/share/apps/amarok/scripts-data/playstat.cfg (that will be created with the default configuration on the first run) that tells it which statistics should be made and will write the HTML output to ~/.kde/share/apps/amarok/scripts-data/playstat.htm by default. Feel free to experiment with it :-)
Version 0.3.3 introduces a few new configuration options for the playstat script. The best would perhaps be to remove your config file and let the playstat script generate a new default one.
11 years ago
2009-09-16 (Version 0.3.6)
Bugfix release. Fixed an UTF-8 problem with Python >=2.5 and made logger work again.
2009-03-08 (Version 0.3.5)
Bugfix release. Fixed a query problem when there are songs with the same name from different artists and made logger (hopefully) work if Amarok 1.* is started in KDE 4.
(See ChangeLog for the rest ;-)
2008-05-28 (Version 0.1):
Initial release
11 years ago
2009-09-16 (Version 0.3.6)
Bugfix release. Fixed an UTF-8 problem with Python >=2.5 and made logger work again.
2009-03-08 (Version 0.3.5)
Bugfix release. Fixed a query problem when there are songs with the same name from different artists and made logger (hopefully) work if Amarok 1.* is started in KDE 4.
(See ChangeLog for the rest ;-)
2008-05-28 (Version 0.1):
Initial release
tzd
12 years ago
I have one question/suggestion:
Instead of having the web site that's being generated stored in scripts-data, would it be possible to store it in directly under the home folder? E.g. /home/username/playstat.htm
That way i don't have to browse around that much to find the actual web site.
Also, for the generated script, I recently came upon a web site that seems to have covers for 99.5% of all album releases. Since the scripts original web site only knows about 65% of my different albums it would be nice to use this site (www.discogs.com) instead for cover fetching.
Actually, the script would be amazing if it could use several sources for cover fetching :)
I don't know how difficult these suggestions are to implement and I also know you've left the script open for everyone else to develop. I was just suggesting above in case you're bored and wishes to improve it :P I'll have a look on it as well, but to be honest, I'm not much of a programmer. Hopefully I'll learn something and could improve some myself. :)
Report
tzd
12 years ago
Report
tzd
12 years ago
It works as long as I avoid the characters: 'å' 'ä' 'ö'
Cheers again :)
Report
l3u
12 years ago
E. g. u"\xe4" instead of "ä".
You can find out these character sequences by starting python in a console and doing the following:
from locale import getpreferredencoding
localEncoding = getpreferredencoding()
Then, you can do something like
"ÄÖÜäöü".decode(localEncoding)
and Python will print out the escaped Unicode string, e. g.:
u'\xc4\xd6\xdc\xe4\xf6\xfc'
Report
tzd
12 years ago
I've tried pasting this in Konsole:
from locale import getpreferredencoding
localEncoding = getpreferredencoding()
but all i get is:
from: can't read /var/mail/locale
i suppose i could reuse the code from your previous post although I'm still missing the letter: 'Ã…', 'Ã¥' :)
Report
l3u
12 years ago
The missing characters should be u"\xc5" for "Ã…" and u"\xe5" for "Ã¥".
(The "u" before the string indicated that the following string is Unicode-encoded, just to have said this :-)
Perhaps, we should do a i18n via gettext? Would be pretty cool, wouldn't it?! But perhaps, one should first make the statistisc script rock and be configurable by some GUI or at least an easy-to-understand configuration file ...
Report
tzd
12 years ago
Thanks for your unicode translation! Will try to modify it now to fit my needs. I'll try to assist in any way possible to ease up the GUI for the web interface even though I'm not a programmer.
Hopefully there's something i can help with ;)
Report
tzd
12 years ago
Instead i receive a new error message after the song has finished:
The script 'logger' ended with error code 1.
Traceback (most recent call last):
File "/home/johan/.kde/share/apps/amarok/scripts/logger/logger", line 174, in <module>
db.execute('INSERT INTO log(date, genre, artist, album, title, count) VALUES(?, ?, ?, ?, ?, ?)', (date, songInfo['genre'], songInfo['artist'], songInfo['album'], songInfo['title'], 1))
sqlite3.OperationalError: no such table: log
Report
l3u
12 years ago
Report
tzd
12 years ago
Had a quick look on the playstat script which was a lot more editable than I originally thought.
I don't quite understand how I produce the web site or where it will be located?
When I try running the "playstat" script within Amarok nothing happens.
Haven't found any info regarding this so was hoping you could point me in any direction please ;)
Thanks for the amazingly fast replies and, not to forget, the patches!
Highly appreciated!
Report
l3u
12 years ago
I added this to the readme file (and to the description above): "The current progress is written to stderr and the HTML is written to stdout, so do e. g. ./playstat > stat.htm on a console to have the HTML written to stat.htm"
The playstat script was only thought to be an example how the database could be queried to produce some statistics. Perhaps, one could modify it in a way that it can be configured and run from Amarok. I'll see ... :-)
Report
tzd
12 years ago
I wanted to file another bug report though. Noticed this today actually. When playing a few classical music mp3s i get an error message from logger saying it's unable to process the mp3.
I do believe this has to do with the name of my classical mp3 files.
For instance, a typical name for one of the songs would be:
Kirov Orchestra, Valery Gergiev - Act I, Tableau 1, Clara and the Nutcracker.mp3
I don't know if logger using the album info too. IF it does then for the above example it would also be:
Tchaikovsky: The Nutcracker, Op. 71
Basically all my classical tunes are very long when it comes to name.
Other mp3s with "smaller" names seems to work well.
Report
tzd
12 years ago
I wanted to file another bug report though. Noticed this today actually. When playing a few classical music mp3s i get an error message from logger saying it's unable to process the mp3.
I do believe this has to do with the name of my classical mp3 files.
For instance, a typical name for one of the songs would be:
Kirov Orchestra, Valery Gergiev - Act I, Tableau 1, Clara and the Nutcracker.mp3
I don't know if logger using the album info too. IF it does then for the above example it would also be:
Tchaikovsky: The Nutcracker, Op. 71
Basically all my classical tunes are very long when it comes to name.
Other mp3s with "smaller" names seems to work well.
Report
l3u
12 years ago
you can also search the database by simply doing (for example):
sqlite3 ~/.kde/share/apps/amarok/collection.db "SELECT url FROM tags WHERE url LIKE '%Tchaikovsky%'"
from a console.
Report
tzd
12 years ago
When playing the same songs again it works (before it wasn't in the collection).
Now when I have added and updated the collection everything is back to normal with perfect logging etc.
Sorry about the double post, updated the web page and it was posted twice unfortunately.
Will try the latest version with the improved script later on tonight or tomorrow.
Thanks once again for your support!
Report
l3u
12 years ago
Artist, album, title and genre are logged by logger. I don't think that the length of the filename causes this error. Are you sure that the files are in the collection database? If so, it would be very interesting if the URL stored in the database differs from the actual url. If you know SQL a bit, you could search directly inside the database doing "sqlite3 ~/.kde/share/apps/amarok/collection.db", querying the table "tags". The data is not fetched from the mp3 (or whatever) files theirselves, but from Amarok's database. So the songs have to be indexed by Amarok.
Try modifying the playstat.py script from version 0.2 -- that should be way easier than modifying the previous versions :-)
Report
tzd
12 years ago
Report
l3u
12 years ago
Report
tzd
12 years ago
I've changed permissions just in case to a=wrx but that didn't help.
The error I receive in Amarok after playing the song is this:
logger: Error processing file /media/mp3/Singles/Pop/Katie Melua - Crawling up a Hill.mp3
Would love to have it up and running since the whole idea with html outputs is great imho. Thanks so far! :)
Report
tzd
12 years ago
Should also mention a few more details:
I'm on kubuntu Hardy (8.04) with kde 3.5.9 and Amarok 1.4.9.1
Report
l3u
12 years ago
Report
tzd
12 years ago
Also tried the command you told me to run and received the following output:
johan@Pingu:~$ dcop amarok collection query 'select url from tags limit 10'
./Singles/Alternative Electronic/St. Germain - La Goutte D'Or.mp3
./Singles/Alternative Electronic/St. Germain - Land Of.mp3
./Singles/Alternative Electronic/St. Germain - Montego Bay Spleen.mp3
./Singles/Alternative Electronic/St. Germain - Pont Des Arts.mp3
./Singles/Alternative Electronic/St. Germain - Rose Rouge.mp3
./Singles/Alternative Electronic/St. Germain - So Flute.mp3
./Singles/Alternative Electronic/St. Germain - Sure Thing.mp3
./Singles/Alternative Rock/Bad Cash Quartet - Big day coming.mp3
./Singles/Alternative Rock/Bad Cash Quartet - Competition ain't nothing.mp3
./Singles/Alternative Rock/Bad Cash Quartet - Heart attack.mp3
johan@Pingu:~$
Hope that might help? Thanks for your fast reply! :)
Report
l3u
12 years ago
Report
tzd
12 years ago
where X is a directory for genre, e.g. Rock and where Y is the actual song.
For instance, the full path to the song New years day by rockartist U2 would be:
/media/singles/rock/u2 - new years day.mp3
I'm afraid i don't know any python coding. If it would be possible to change it to the absolute path then perhaps it would work? Seems a little strange with the "." before /singles/..
Tell me what to do and I'll do it :)
Report
l3u
12 years ago
Report