diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-07-02 17:52:15 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-07-02 17:52:15 +0200 |
commit | a2ffdc2fc5efb66d0143f5a6959fb271a9b42fea (patch) | |
tree | 6283f1266b579990dac77bed062294f7ba31239a /icy-info.py | |
parent | bb7fd26a46a076a0057fbd2296a4ac4e1af73c27 (diff) | |
download | mmbtools-aux-a2ffdc2fc5efb66d0143f5a6959fb271a9b42fea.tar.gz mmbtools-aux-a2ffdc2fc5efb66d0143f5a6959fb271a9b42fea.tar.bz2 mmbtools-aux-a2ffdc2fc5efb66d0143f5a6959fb271a9b42fea.zip |
Add script to create dls.txt from ICY info
Diffstat (limited to 'icy-info.py')
-rw-r--r-- | icy-info.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/icy-info.py b/icy-info.py new file mode 100644 index 0000000..2929ed0 --- /dev/null +++ b/icy-info.py @@ -0,0 +1,37 @@ +#!/usr/bin/python2 +# +# Pipe mplayer into this script + +import re +import sys + +re_icy = re.compile(r"""ICY Info: StreamTitle='([^']*)'.*""") + +if len(sys.argv) < 3: + print("Please specify dls output file, and default text") + sys.exit(1) + +dls_file = sys.argv[1] + +default_text = sys.argv[2] + +while True: + new_data = sys.stdin.readline() + + match = re_icy.match(new_data) + + if match: + artist_title = match.groups()[0] + + if artist_title.strip() == "": + artist_title = default_text + + print("New artist: {}".format(artist_title)) + + fd = open(dls_file, "w") + fd.write(artist_title) + fd.close() + else: + print("{}".format(new_data.strip())) + + |