Intelligent Playlist

Amarok 2.x Scripts

Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

3
Become a Fan
7.1

Description:
A short warning beforehand: I have written this script for an Artificial Intelligence lecture at my university. Thus, its main goal is to apply some typical algorithms and ideas from AI in a real-life software project. If you are seeking for something to integrate typical Similar Artists functionality provided by online services, you are better off with Amarok's Dynamic Playlists (and some custom biases) or something like this:
http://kde-apps.org/content/show.php/AutoPlaylist?content=120476

The plugin functions by dropping just some tracks into an initial playlist. Turn the plugin on and hit the play button. The plugin will then try to find similar tracks from your local collection. So, beneath of using a similarity comparison instead of a given (a-priory) set of rules (biases) it shall not distinguish too much in how it presents itself to the user compared to Amarok's Dynamic Playlists.

For a detailed description, please have a look at the projects homepage.

Please note, that this is currently rarely tested. This means: It might work for your music flavor and collection or not. I have made pretty good experience, but I cannot guarantee that this will apply to everyone else. So, feedback and further suggestions about how to improve the plugin are very welcome
Last changelog:

0.2.0:
* plugin is now localizable
* added Czech translations (thanks to Pavel Fric)
* added German translations
* using UniqueIds to add tracks to playlist (to preserve compatibility across versions of Amarok)

0.1.5:
* replaced some code to fix problems with Ubuntu 10.10

0.1.4:
* fixed Bug in Track module

0.1.3:
* fixed a bug that prevented the plugin from adding selected tracks to playlist (only occurred with newer versions of Amarok)

0.1.2:
* fixed bug when using match-at-last-one-track mode

0.1.1:
* little fixes in script spec
* little improvement in playlist solver

0.1:
* initial public release


Ratings & Comments

19 Comments

evel

Hey Martin! First of all, congratulations on the work you've done! I really hope that you can help me. I'm trying to write an Amarok script and I need to add some local files to the current playlist. The problem is that I don't know how to achieve this using "addMedia", since I can't find a way to select a track from its path. It should be a very easy task, but I didn't find any documentation on this!! I analyzed your code without luck. I just need something very simple, like this: getSongs = Amarok.Collection.query("SELECT `url` FROM `tracks`") for (var song in getSongs) Amarok.Playlist.addMedia(new QUrl(decodeURI(getSongs[song]))) Help me pleaseee!! Thanks you in advance. Best Alberto

pen2

Hey, the following works for me:

var songs = Amarok.Collection.query( "SELECT rpath FROM urls LIMIT 10;" );
for ( var i in songs ) {
var path = songs[ i ];
Amarok.Playlist.addMedia( new QUrl( path ) );
}
That's all. You can use Amarok's built-in Script Console for testing (go to the script manager and check the "Amarok Script Console" entry). I don't know what you already tried, however: Amarok's database tables are pretty good normalized, i.e. the table tracks contains only some rare data. The url field indeed contains a "pointer" to an entry in the urls table. So you have to use joins to get the data. Consider the following example: You have the ID of a track you want to add to the playlist. Then your query could look like this:
var id = 321;
var url = Amarok.Collection.query( "SELECT url.rpath FROM tracks AS track INNER JOIN urls AS url ON track.url = url.id WHERE track.id = " + id + ";" );
Amarok.Playlist.addMedia( new QUrl( url[ 0 ] ) );
Okay, I hope this helps so far ;) Feel free to ask if you have further questions. PS: For a good overview of Amarok's database layout, see here: http://gitweb.kde.org/amarok.git/blob/HEAD:/docs/database/amarok_db_schema.png

evel

Thank you very much for the reply!! I've tried your code, but I get an error. When putting this into the Script Console: var songs = Amarok.Collection.query("SELECT rpath FROM urls LIMIT 10;" ); for ( var i in songs ){ var path = songs[ i ]; Amarok.Playlist.addMedia( new QUrl( path ) ); } I get: not a track no match amarok: BEGIN: void Playlist::Controller::insertOptioned(Meta::TrackPtr, int) amarok: END__: void Playlist::Controller::insertOptioned(Meta::TrackPtr, int) - Took 0.00011s (one error for each track) The variable path anyway is properly filled, since if I try this: var songs = Amarok.Collection.query("SELECT rpath FROM urls LIMIT 10;" ); for ( var i in songs ){ var path = songs[ i ]; Amarok.debug( path ); } I get the right paths printed on the debug message. Any idea? Have I got to do something to make the "QUrl" work? Actually I import "qt.core" both in my script than in the Script Console...

pen2

Hm... AFAIK the above code should work out-of-the-box (and for me it does; I didn't import packages in Script Console and the example still works flawlessly). Which version of Amarok do you use? I remember there were some issues with my plugin, too. For me, I once added the "file://" prefix to the rpath. However, in recent versions, Amarok stopped accepting these. I do not really remember, but if your Amarok is a bit older, try adding the "file://" prefix, too. Finally, I also recommend contacting the Amarok developers (see http://amarok.kde.org/en/contribute). They surely know more about the issue than I do.

evel

Martin, thanks A LOOOOT for your helpfulness, now it works!! The problem was, as you suggested, in the "file://" prefix (and I also have to erase the first character from the path, because it's a point). I'm using Amarok 2.3.0, not that old... Thank you again, also for the useful link to the database structure. Keep on the good work, Alberto

schnecki

Hi, I am using the latest Ubuntu Version 10.10 and Amarok Version 2.3.2 (KDE 4.5.1). Since yesterday, the day I upgraded Ubuntu from 10.04 to 10.10, a problem with the Intelligent Playlist Plugin appears when the song switches. Errortext: ---------- There was an error in the Intelligent Playlist plugin! Error: TypeError: Result of expression 'this.m_plugin.configuration' [undefined] is not an object. Error Name: TypeError Message: Result of expression 'this.m_plugin.configuration' [undefined] is not an object. File: PlaylistSolver.js Line: 446 ---------- I guess that a important Javascript Library was deleted during the Upgrade. But I can't figure out which one it could be. Do you know what I need to do, to make the plugin working again? Thanks, schnecki P.S.: I am really disappointed by that error, because this wonderful plugin does not work anymore :(

pen2

Hey, thank you for reporting this! I'm sorry, but I cannot say for sure what the problem might be. I'm currently using Amarok 2.3.1; I'll update to a newer version, so I hope to find the problem rather soon ;) In the meantime: How exactly did you upgrade? Did you completely reinstalled your system or did you do an update out of the running system (and thus kept your existing configuration files)?

schnecki

ok, so it's probably a problem in the latest Amarok version... I just upgraded my Ubuntu and should still have my configuration files. But I deleted some gnome files, due to Desktop problems (those are solved). Command: rm -rf .gnome .gnome2 .gconf .gconfd .metacity --- I hope this helps. Best regards

pen2

Well, it indeed could be a problem with the configuration files... Meanwhile I compiled and installed Amarok from Git; however, I do not get the problem - the plugin's working fine here. For testing you could do the following: Quit Amarok and open up a terminal window, there, execute the following commands: First, make a copy of the amarokrc file: cp .kde/share/config/amarokrc ~ amarokrc is Amaroks main configuration file, where also all plugins' settings are stored. The above command will make a backup copy of it in your Home. Now edit this file, e.g. with kwrite: kwrite .kde/share/config/amarokrc Search for a line reading [Intelligent Playlist]. Delete it and the following lines until the next section. Then restart Amarok and try whether the plugin works again. If it does, the problem is indeed related to the configuration. If not, you could copy back the backed up version of the amarokrc file to restore the plugin's settings. In either case, please report back the results of that test. Thank you!

schnecki

OK, I did what you told me to do. Unfortunately it did not change anything. The same errors appear. I did not restore my backup file...I don't think it should change anything. schnecki

pen2

Okay, thank you for the information. Today I installed Ubuntu in a virtual machine for testing and indeed the script is not working there, too. However, I somehow think this is rather a problem with the script bindings than Amarok-related, as e.g. some KDE widgets are no longer working with the old code. I will review this ASAP, but I cannot say for sure when I'll release a new version (I'm currently a bit short of free time, so fixing the plugin could take a while, sorry for that).

schnecki

ok that's good for me. I just got another few playlist I have to listen to until I need your plugin ;) Take ur time.

pen2

Hi Just released version 0.1.5. This should fix your problem ;) Thanks again for reporting the problem ^^

deadbabylon

I get this error when skipping to the last track in my playlist: There was an error in the Intelligent Playlist plugin! Error: Error: QUrl::QUrl(): could not find a function match; candidates are: QUrl() QUrl(String url) QUrl(String url, ParsingMode mode) QUrl(QUrl copy) Error Name: Error Message: QUrl::QUrl(): could not find a function match; candidates are: QUrl() QUrl(String url) QUrl(String url, ParsingMode mode) QUrl(QUrl copy) File: Track.js Line: 247

pen2

Thank you for reporting this. I fixed the problem an uploaded the new version. So, hopefully it works now ;)

groo

Very nice script and work, i hope you can keep on enhancing it. it works very well in playlist mode, but if i change the settings to one track only i get this error: There was an error in the Intelligent Playlist plugin! Error: TypeError: Result of expression 'sim.setArtist' [undefined] is not a function. Error Name: TypeError Message: Result of expression 'sim.setArtist' [undefined] is not a function. File: PlaylistSolver.js Line: 395 besides that it works like a charm :) best regards

pen2

Hi Thank you for pointing this out ;) I made some restructuring recently but somehow omitted testing the second mode ^^' Already fixed the bug and uploaded a new version, so I hope it now should fully work.

groo

Hi, thanks for your swift answer.. ill test this new version asap. one other thing, could you please append the version number to the download file. i do packages for (k)ubuntu and its very hard to send them upstream when the original file doesnt have a version number. best regards and keep up the good work

pen2

No problem. Already extended my packaging scripts, so starting with the next release I'll include all necessary information in the archive file name ;)

Pling
0 Affiliates
Details
license
version 0.2.0
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 2

Other Amarok 2.x Scripts:

raya
raya1234
last update date: 15 years ago

Score 5.0

Partition Assistant
shiny521
last update date: 15 years ago

Score 5.0

google-clone
jenifferhomes
last update date: 15 years ago

Score 5.6

Quran Audio Library
boubakr92
last update date: 12 years ago

Score 4.4

Remove Current Track
alexoleshkevich
last update date: 14 years ago

Score 4.7

indoLyrics
cyrus007
last update date: 14 years ago

Score 4.7



System Tags