Created
January 30, 2017 17:30
-
-
Save wbills/c414d59236c91a91b2eae5930ba56c6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import pydoc | |
import warnings | |
import subprocess | |
#pip install pylyrics | |
from PyLyrics import * | |
#bs4 warns about the default parser used in pylyrics, mucks up the output | |
warnings.filterwarnings("ignore", category=UserWarning, module='bs4') | |
#brew install shpotify | |
out = subprocess.Popen("spotify status", shell=True, stdout=subprocess.PIPE).stdout.read() | |
artist = None | |
track = None | |
for line in out.split("\n"): | |
parts = line.split(': ') | |
if parts[0] == '\x1b(B\x1b[mArtist': | |
artist = parts[1] | |
if parts[0] == 'Track': | |
track = parts[1] | |
if artist is not None and track is not None: | |
lyrics = PyLyrics.getLyrics(artist, track) | |
pydoc.pipepager(out + "\n\n" + lyrics, cmd = 'less -R') | |
else: | |
print 'No song playing or lyrics not found.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment