
Random Album
Source (link to git-repo or to original if based on someone elses unmodified work):
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
* 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.
Ratings & Comments
30 Comments
Hi -awesome script for a function that should really be mandatory everywhere. 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!
Thanks! 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.
Hey, thanks for the quick reply. 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
This is a nit-pick because I like my "play count" to be updated properly. 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!
Since Amarok 2.5 the randomly selected album stays in the playlist and is played in a loop. I'm not sure, if it is caused by the script or amarok.
Finally got to run amarok 2.5, and I don't see the behavior you're describing. Everything seems to be working like before for me.
I'm hitting this now with Kubuntu 12.04, so at least I have a system where to debug the issue now.
Just FYI, Amarok 2.6 (or the updated Phonon backend package) seems to make the script behave a lot better.
Yeah, but I'm already at 2.7 GIT. Your script is working fine here.
It makes Amarok 2 more useful! Awesome!
Great script! The only thing missing is ability to assign global shortcut to "play random album". Now to skip to next random album you have to open Amarok window. 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).
I see an option in amarok's keyboard shortcut configuration dialog to assign shortcuts to all of the scripts options. Do you not see that? 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).
I see the script options in the list in this dialog, but I can only assign the normal shortcuts (first and alternative), but not the global one (there are no tree expanders in the the 'global shortcut' column for these options). Please check it, maybe it's something with my system. Thank you.
Ah, I see what you mean. Unfortunately this is not something I can control from the script. If you really want that feature, I'd suggest you file a feature request for amarok (at bugs.kde.org).
First of all, many thanks for this great script. Playing random albums, for me, is the only way to listen music since years. Thanks a million for making it possible with Amarok. 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;
If I understand what you're asking for, that would require a significant rewrite of the plugin. Right now the script works with just the information in the amarok database; so if amarok is tracking your symlinks, then the script will pick them up. If it's not, the script has no way of knowing about them. 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).
hi ! (sorry for my bad english) 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 !
I don't think that has any relation to this script. I've had it happen to me in the past even before I had the script. It's pretty annoying having to redownload a lot of cover art, I'll give that to you. (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!)
The script is not working for me under amarok 2.1.1 on ubuntu 9.01 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
Hmm... I'm running 2.1.1 (didn't even notice it was upgraded) and the script is running fine for me. 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).
Sorry i didn't reply before. I've been busy 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
Yeah, I figured it would be something related to the SQL queries... amarok's DB schema is quite confusing where it relates to URLs, and I haven't yet been able to grok the C++ code enough to understand how to use it correctly. 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.
hi ! (sorry for my bad english) 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...)
Good timing on your part since I just upgraded to 2.1 and had to fix the script. :-)
HI ! 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 :-/