Created
August 7, 2017 20:39
-
-
Save asathoor/59e2f7942d34891db71f16d48fe08068 to your computer and use it in GitHub Desktop.
Simple Python WWW Radio Stream Player
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 -*- | |
# file: test.py | |
# purpose: simple internet radio player for a pi or similar | |
# by: per thykjaer jensen | |
# dependencies: mplayer | |
''' | |
mplayer turns into a zombie on ctrl+z | |
if it's a problem kill them ... | |
''' | |
import subprocess as sub # OS specifikke kommandoer | |
import signal | |
''' | |
Radiokanaler | |
''' | |
channels = [ | |
("SOMA Spacestation","http://somafm.com/spacestation.pls"), | |
("SOMA Suburbs of Goa","http://somafm.com/suburbsofgoa130.pls"), | |
("SOMA Secret Agent","http://somafm.com/secretagent130.pls"), | |
("SOMA Lush","http://somafm.com/lush130.pls"), | |
("SOMA Indie Pop Rocks","http://somafm.com/indiepop130.pls"), | |
("DR P1","http://live-icy.gss.dr.dk/A/A03H.mp3.m3u"), | |
("DR Østjylland", "http://live-icy.gss.dr.dk/A/A14H.mp3.m3u"), | |
("DR Nyhederne", "http://live-icy.gss.dr.dk/A/A02L.mp3.m3u") | |
] | |
''' | |
Print alle kanaler | |
''' | |
for x in range (0, len(channels) ): | |
print str( x ) + ": " + channels[x][0] | |
''' | |
Input | |
''' | |
tune = input("Vælg en kanal\n") | |
print "Spiller stream " + channels[ tune ][0] | |
''' | |
Stream initieres | |
''' | |
p = sub.Popen( [ | |
'mplayer', | |
'-playlist', | |
channels[ tune ][1] ], | |
stdout=sub.PIPE, | |
stderr=sub.PIPE) | |
output, errors = p.communicate() | |
print output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment