diff --git a/240split.py b/240split.py new file mode 100755 index 0000000..64ebc4e --- /dev/null +++ b/240split.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +#this script splits text on space with a maximum of 240 characters +#but on whole words. because icy_medata has a max of 255 characters. +import sys + +text = sys.stdin.readlines() +output = [] +line = [] +sentence = "" +for words in text: + for word in words.split(): + if len(word) + len(" ".join(line)) < 240: + line.append(word) + else: + output.append(" ".join(line)) + line = [] + line.append(word) + +"#add the last word" +output.append(" ".join(line)) + +for line in output: + print(line.replace(',', '')) diff --git a/README.md b/README.md index e69de29..12059b9 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,12 @@ +# Bag of radio scripts + +This are some messy scripts. They don't work out of the box. +You need maybe another tool like pallangana and maybe some +python code to generate a radio html +[palanggana](https://git.vvvvvvaria.org/crunk/palanggana) + +It assumes you have icecast2, liquidsoap and python installed. + +This repo is meant to inspire other radio streamers that want to +tie together a few tools. + diff --git a/buildplaylist.py b/buildplaylist.py new file mode 100644 index 0000000..741e5df --- /dev/null +++ b/buildplaylist.py @@ -0,0 +1,19 @@ +#This is a pretty weird script, it gets lines of text from somewhere +#And it makes a playlist, to keep the amount of tracks loosely connected +#To the amount of text. +import sys +from subprocess import Popen, PIPE + +magic = sys.stdin.readlines() +lines = [] + +for line in magic: + lines.append(line) + +pfind = Popen(["find", "/media/mp3" ], stdout=PIPE) +pgrep = Popen(["grep", "mp3"], stdin=pfind.stdout, stdout=PIPE) +pfind.stdout.close() # Allow pfind to receive a SIGPIPE if pgrep exits. + +pshuf = Popen(["shuf", "-n {0}".format(len(lines))], stdin=pgrep.stdout) +pgrep.stdout.close() + diff --git a/fireup.sh b/fireup.sh new file mode 100755 index 0000000..01f9f95 --- /dev/null +++ b/fireup.sh @@ -0,0 +1,12 @@ +#!/bin/zsh + +echo "let's go" +find $PWD /home/user/incoming | grep .mp3 | shuf > /media/mp3/playlist.m3u +source .venv/bin/activate +python palanggana.py --magic shoutout | \ +python renderradiopage.py | \ +python buildplaylist.py >> /media/mp3/playlist.m3u; +liquidsoap ../radio/radio.liq && +echo "the radio is currently off" | python renderradiopage.py; +deactivate; + diff --git a/radio.liq b/radio.liq new file mode 100644 index 0000000..223611d --- /dev/null +++ b/radio.liq @@ -0,0 +1,71 @@ +#!/usr/bin/liquidsoap +set("log.file.path","/tmp/