Last active
December 21, 2015 01:39
-
-
Save breunigs/6229411 to your computer and use it in GitHub Desktop.
displays lyrics of currently playing song. Works in existing shell or opens a new terminal. Keywords: cmus urxvt mutagen
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/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
if not sys.stdout.isatty() and os.environ.get('iherduleikterms') != 'no': | |
os.environ['iherduleikterms'] = 'no' | |
os.system('urxvtcd -title "Lyrics Viewer™" -e sh -c "lyrics-currently-playing | less"') | |
exit | |
import subprocess | |
import re | |
from mutagen.id3 import ID3 | |
stats = subprocess.check_output(["cmus-remote", "-Q"]) | |
path = re.search('file (.*)', stats).group(1) | |
tags = ID3(path) | |
lyrics = tags.getall("USLT") | |
print path | |
for x in lyrics: | |
print "\n--------" | |
print (x.lang + " " + x.desc).replace('\x00', '') | |
print x.text.encode('utf-8').strip() | |
print "\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment