Skip to content

Instantly share code, notes, and snippets.

@MikeiLL
Created February 2, 2016 03:39
Show Gist options
  • Select an option

  • Save MikeiLL/bcde01283fcdf61bb163 to your computer and use it in GitHub Desktop.

Select an option

Save MikeiLL/bcde01283fcdf61bb163 to your computer and use it in GitHub Desktop.
Quodlibet Plugin to generate playlists based on tracks played through end, per day.
'''
This plugin creates a playlist of all the tracks that have played through the end on any given day.
TODO: Add an enable disable button in GUI?
'''
from quodlibet.plugins.events import EventPlugin
import time
import os
from os.path import expanduser
class GenerateList(EventPlugin):
PLUGIN_ID = "generatelist"
PLUGIN_NAME = _("Generate List")
PLUGIN_DESC = _("Automatically add to playlist for current date."
"Well for now let's just print song name out.")
def plugin_on_song_ended(self, song, skipped):
if song is not None:
print song._song['~filename']
self.write_to_playlist(song._song['~filename'])
def write_to_playlist(self, filename):
today = time.strftime("%F")
home = expanduser("~")
name = os.path.join(home, '.quodlibet/playlists', today)
try:
file = open(name, 'a')
file.write(filename+'\n')
file.close()
except:
print("Could not write file name out")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment