Create a gist now

Instantly share code, notes, and snippets.

#!/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