Created
September 23, 2010 10:04
-
-
Save tlvince/593430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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