exaile / exaile-ideas

Repository that holds ideas for Exaile submitted by users
0 stars 0 forks source link

feature request: for intelligent play list #4

Open ghost opened 9 years ago

ghost commented 9 years ago

Sorry if I don't put this feature request in the right place.

I would like new feature for intelligent play list.

Consider for example 3 play list (list A, B, C) I would like to make a intelligent play list like that: -max 10 tracks -4 random tracks from plalist A -3 random tracks from plalist B -3 random tracks from plalist C -and never twice same track

Thank you for this great soft!

virtuald commented 9 years ago

This sounds like a niche usecase, and I'm not particularly interested in implementing it myself. However, if someone else wants to implement it I'll gladly accept a pull request.

sjohannes commented 9 years ago

If this is something you won't do very often, you can run code such as the following in the IPython Console plugin:

import random
import xl.playlist

playlists = ["Playlist A", "Playlist B", "Playlist C"]
take_from_playlists = [4, 3, 3]

playlists = map(exaile.playlists.get_playlist, playlists)  # Get the named playlists
playlists = map(list, playlists)  # Copy as lists
playlists = map(random.shuffle, playlists)  # Shuffle each list

combined = xl.playlist.Playlist("Combined")
combined_set = set()  # To check for duplicates
for pl, wanted in zip(playlists, take_from_playlists):
    while wanted:
        t = pl.pop()
        if t not in combined_set:
            combined.append(t)
            combined_set.add(t)
            wanted -= 1
exaile.playlists.save_playlist(combined, True)

I haven't tested this code, but it should do what you describe and save the result in a new playlist named "Combined".

ghost commented 9 years ago

Thanks, but this is something I'll like to do every days! :D Also I got Exaile 3.4.4 and the python modul looks broken: http://www.zimagez.com/zimage/capturedcran-16062015-145342.php