Image 01
profile-image

evel

Alberto Testolin
Intelligent Playlist

Amarok 2.x Scripts by pen2 19 comments


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 - Nov 19 2010
Intelligent Playlist

Amarok 2.x Scripts by pen2 19 comments


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...
- Nov 19 2010
Intelligent Playlist

Amarok 2.x Scripts by pen2 19 comments

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 - Nov 18 2010