Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Show additional fields, Export in .CSV format #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions shazam-tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import sqlite3


# Field Delimiter
delimiter = ' - ' # Default
# delimiter = ',' # CSV


db_path = os.path.expanduser(
'~/Library/Containers/com.shazam.mac.Shazam/Data/Documents/ShazamDataModel.sqlite'
)
Expand All @@ -25,14 +30,17 @@
cursor = connection.cursor()
results = cursor.execute(
'''
SELECT artist.ZNAME, tag.ZTRACKNAME
SELECT tag.Z_PK as Id, strftime('%Y-%m-%d', datetime(tag.ZDATE + 946684800 + 31536000, 'unixepoch')) as TagTime, tag.ZTRACKNAME as Title, artist.ZNAME as Artist, tag.ZSHAZAMSERVERTRACKURL as URL, tag.ZPRIVATETRACKKEY as TrackKey
FROM ZSHARTISTMO artist, ZSHTAGRESULTMO tag
WHERE artist.ZTAGRESULT = tag.Z_PK
ORDER BY tag.ZDATE
'''
)

for result in results:
print b'{0} - {1}'.format(result[0], result[1])
names = [description[0] for description in cursor.description]
print delimiter.join(names)

for row in results:
print delimiter.join(str(field) for field in row)

connection.close()