
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
An amarok script that monitors the playlist, and, when it's finished, repopulates it with a random album from the collection. Differently from amarok's built-in "random album" mode, you don't need to keep the whole collection in the playlist; so when you add new stuff to the collection the script will automatically pick it up, and it's easy to manually enqueue songs into the current playlist without the "random mode" triggering whenever the current album finishes playing.
This script is inspired and very loosely based on the randomalbum.py script for amarok 1.4, available at the following URL:
http://www.kde-apps.org/content/show.php?content=42764
10 years ago
* Version 1.0:
. some tweaking to the monitoring code to make the script behave better in amarok 2.4.
* Version 0.9:
. monitor track changes, so that skipping the last track on a playlist will also make the script load a new album. Suggested by kronos003 (irc.freenode.net).
* Version 0.8:
. add support for genre filtering (contributed by Ghislain Mary)
* Version 0.7:
. minor update to work around an issue where playback wouldn't start when loading a new album. Delay the start of the playback a little to let amarok's UI properly refresh.
* Version 0.6:
. persist the list of played albums so that the same album isn't played after restarting amarok.
. if running in amarok 2.3.1, respect the "stop playing after current track" setting.
* Version 0.5:
. fix an issue with path filtering not doing what it was supposed to do in some cases
. remove some code that caused the script to freak out when stopping playback when the last track of a playlist was active.
* Version 0.4:
. Reworked the SQL queries; they should work better on databases that did not look like mine.
. Added option to filter the albums being loaded according to a string (matched against the album path).
* Version 0.3:
. Add new action to enable / disable the playlist monitor.
* Version 0.2:
. Updated to work with amarok 2.1. Hasn't been tested with 2.0.2...
* Version 0.1:
Initial version. What works:
. loading and enqueueing a random album.
Known issues:
. the playlist sometimes doesn't repaint correctly after an update. Clicking somewhere on the playlist fixes it (looks like an Amarok problem).
. only tested on my setup, so I don't know how it will work with collections spanning different devices, etc.
10 years ago
* Version 1.0:
. some tweaking to the monitoring code to make the script behave better in amarok 2.4.
* Version 0.9:
. monitor track changes, so that skipping the last track on a playlist will also make the script load a new album. Suggested by kronos003 (irc.freenode.net).
* Version 0.8:
. add support for genre filtering (contributed by Ghislain Mary)
* Version 0.7:
. minor update to work around an issue where playback wouldn't start when loading a new album. Delay the start of the playback a little to let amarok's UI properly refresh.
* Version 0.6:
. persist the list of played albums so that the same album isn't played after restarting amarok.
. if running in amarok 2.3.1, respect the "stop playing after current track" setting.
* Version 0.5:
. fix an issue with path filtering not doing what it was supposed to do in some cases
. remove some code that caused the script to freak out when stopping playback when the last track of a playlist was active.
* Version 0.4:
. Reworked the SQL queries; they should work better on databases that did not look like mine.
. Added option to filter the albums being loaded according to a string (matched against the album path).
* Version 0.3:
. Add new action to enable / disable the playlist monitor.
* Version 0.2:
. Updated to work with amarok 2.1. Hasn't been tested with 2.0.2...
* Version 0.1:
Initial version. What works:
. loading and enqueueing a random album.
Known issues:
. the playlist sometimes doesn't repaint correctly after an update. Clicking somewhere on the playlist fixes it (looks like an Amarok problem).
. only tested on my setup, so I don't know how it will work with collections spanning different devices, etc.
agt499
8 years ago
Just had the first-i-have-ever-noticed experience where two albums by different artists got randomly selected due to the same Album Name, and playt Track 1 Artist 1,Track 1 Artist 2,Track 2 Artist 1,Track 2 Artist 2.
Not sure if this is the script or Amarok (which I'm certain used to discern separate albums with the same name?)
Thanks for the cool script!
Report
mvanzin
8 years ago
As for the problem, it's funny because I have code to work around exactly that situation... if you know how to do it, it would be nice if you were able to manually run the queries used by the getAlbum() function (in main.js) on your database, for the offending album.
Report
agt499
8 years ago
Not too sure how I should have done it, but here's what I've done:
Right at the start of function getAlbum, I hard-coded aid=1290, and that returned that artists.length=1.
Doesn't sound like the right answer, as the resulting playlist below shows multiple artists (with AlbumArtist tagged also).
If I sort my collection by Album I get the same result -one album with tracks intermingled, so it looks like the schema has regressed to the old 1.4 behavior you reference in the code comments, except that the your just-in-case is no longer working.
If I get more real work done tomorrow I may look to open a bug on Amarok (Version 2.5.0 here).
/m/flac/D/Daft Punk/Daft Punk - 2001 - Discovery/01 - One More Time.flac
/m/flac/E/Electric Light Orchestra/Electric Light Orchestra - 1979 - Discovery/01 - Shine a Little Love.flac
/m/flac/D/Daft Punk/Daft Punk - 2001 - Discovery/02 - Aerodynamic.flac
/m/flac/E/Electric Light Orchestra/Electric Light Orchestra - 1979 - Discovery/02 - Confusion.flac
/m/flac/D/Daft Punk/Daft Punk - 2001 - Discovery/03 - Digital Love.flac
/m/flac/E/Electric Light Orchestra/Electric Light Orchestra - 1979 - Discovery/03 - Need Her Love.flac
/m/flac/D/Daft Punk/Daft Punk - 2001 - Discovery/04 - Harder, Better, Faster, Stronger.flac
/m/flac/E/Electric Light Orchestra/Electric Light Orchestra - 1979 - Discovery/04 - The Diary of Horace Wimp.flac
Report
arch0njw
8 years ago
I am running Kubuntu 12.04 and Amarok 2.5.0. When I use this script, it is now adding tracks with a "Collection" value of "None" on the "Summary" tab. This means the play could isn't being updated correctly for the tracks which are technically in my "Local Collection".
I hope this is simple to fix. This script is awesome!
Report
bitcrazy
9 years ago
Report
mvanzin
8 years ago
Report
bitcrazy
8 years ago
Report
mvanzin
9 years ago
Report
mvanzin
8 years ago
Report
arch0njw
9 years ago
Report
bwo
10 years ago
Ah, and also the "automatic load new random album" mode could be easier to turn on/off (menu entry and shortcut, not in the script settings).
Report
mvanzin
10 years ago
I moved the "turn off auto load" option to the config after amarok implemented support to detect "stop after track" from the script API. That way the script can stop easily when you use that option. I'd rather keep the menus less cluttered (since the script API doesn't seem to have support for adding sub-menus, only menu items).
Report
bwo
10 years ago
Report
mvanzin
10 years ago
Report
WillS
10 years ago
I would like to request a feature. Could you enable your script recognising symlinks, please!? I think this could simplify filtering. For me it is symlinking albums to a 'heavy-rotation-folder'. Would this be possible?
btw.:
What do you exactly mean with
Quote:. persist the list of played albums so that the same album isn't played after restarting amarok.??
and when it is reseted?
thanks for audience,
will;
Report
mvanzin
10 years ago
Doing it differently would require the script to have its own list of places where to find songs. While doable, that's kinda against the purpose of the plugin - it would be reimplementing a lot of logic already inside amarok.
Some previous suggesting of adding bias controls could probably help you, but I really don't know if I'll get to that (since it's not something that really interests me).
About the change you ask about, it just means the script keeps track of albums it has chosen even across sessions. So if you close amarok, open it up again, and choose a new random album, the script will not choose the album that was playing before you closed amarok (something that actually happened to me).
Report
jajaxor
11 years ago
I have got a problem with amarok 2.3 and ramdom album 0.5.
album loading is ok.
but, this album have got no cover, no stat !
Report
mvanzin
11 years ago
(To break the pattern for me, I just upgraded to 2.3 and this time it didn't lose all my covers. And the script still works. Yay!)
Report
Hilikus
11 years ago
When i have something in my list and click load random album the list is cleared but nothing appears in it
if i hit play after that nothing happens so the list is really empty
Report
mvanzin
11 years ago
I'd need more info to figure out what's wrong in your case; running "amarok --debug" from a terminal and sending me the output would be a start, but better yet would be to send me your ~/.kde/share/apps/amarok/mysqle directory (or the whole of ~/.kde/share/apps/amarok).
Report
Hilikus
11 years ago
anyway, i took the liberty to fix it myself. the problem was your sql query since in my case the "devices" table is empty so "devices.id = urls.deviceid" was making it return nothing.
urls.deviceid in my case is -1 for every song in my collection
I also added a feature i needed that you can remove if you want to. It uses only albums from a certain directory hierarchy specified in the script since i don't want to have randomly selected "albums" that are only a single song I bought. i want to limit it to *full* albums, which i have in separate directories from singles
Just writing the beginning of the path for full albums will work; to disable this just make the string empty ""
mmm i just realized you can't attach files here. Let me know if you want to see the patch and how i can send it to you
Cheers,
Alejandro
Report
mvanzin
11 years ago
You can send your patches to my e-mail (it's at the top of main.js) and I can look at integrating them with the code.
Report
jajaxor
11 years ago
nice script ;)
I see that is in amarok nightly :P
But I can't load album with amarok 2.1 and your script :-/ (same problem on amarok nightly...)
Report
mvanzin
11 years ago
Report
jajaxor
11 years ago
nice !! it's ok now ;)
but; stupid question, how stop loading of random album ?
I activate "stop after this track" but another album was loading et continu playing :-/
Report