Skip to content

Instantly share code, notes, and snippets.

@ddasilva
Created April 28, 2013 12:45
Show Gist options
  • Save ddasilva/5476784 to your computer and use it in GitHub Desktop.
Save ddasilva/5476784 to your computer and use it in GitHub Desktop.
A script to print ID3 tags. (Backed up from ~/bin/print_id3). Usage: print_id3 *.mp3
#!/usr/bin/python
"""
Prints ID3 tag information about files.
Usage: print_id3 *.mp3
"""
import sys
import os
from ID3 import ID3
from termcolor import cprint
for arg in sys.argv[1:]:
cprint(arg, attrs=['bold'])
if not os.path.exists(arg):
cprint('File does not exist', 'red', attrs=['bold'])
continue
try:
tags = ID3(arg).as_dict()
except:
cprint('Error reading tags', 'red', attrs=['bold'])
continue
# Alright
for k, v in sorted(tags.items()):
cprint(k, 'green', end=': ')
print v
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment