Skip to content

Instantly share code, notes, and snippets.

@tlvince
Created September 23, 2010 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlvince/593430 to your computer and use it in GitHub Desktop.
Save tlvince/593430 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# eugene2plain.py
# Copyright 2010 Tom Vincent <http://www.tlvince.com/contact/>
import os
import sqlite3
DB = os.path.expanduser("~") + "/.mpdcron/stats.db"
OUT = os.path.expanduser("~") + "/plays.log"
PREFIX = "1970-01-01T00:00:00Z"
conn = sqlite3.connect(DB)
c = conn.cursor()
c.execute("SELECT artist,title,play_count FROM song WHERE play_count !='0'")
songs = (c.fetchall())
with open(OUT, mode='w', encoding='utf-8') as outFile:
for song in songs:
for i in range(int(song[2])):
outFile.write(PREFIX + " " + song[0] + " - " + song[1] + "\n")
conn.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment