crunk
4 years ago
7 changed files with 150 additions and 0 deletions
@ -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(',', '')) |
@ -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. |
||||
|
|
@ -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() |
||||
|
|
@ -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; |
||||
|
|
@ -0,0 +1,71 @@ |
|||||
|
#!/usr/bin/liquidsoap |
||||
|
set("log.file.path","/tmp/<script>.log") |
||||
|
%include "passwords.liq" |
||||
|
# Print log messages to the console, |
||||
|
set("log.stdout", true) |
||||
|
set("server.telnet",true) |
||||
|
|
||||
|
#If the playlist crashes |
||||
|
security = single("~/radio/default.ogg") |
||||
|
#Regular playlist |
||||
|
go = playlist.once("/media/vault/playlist.m3u") |
||||
|
|
||||
|
#1. this doesn't work and |
||||
|
#2. who the fuck makes a list read from the back? |
||||
|
#radio = sequence([go, first]) |
||||
|
radio = fallback(track_sensitive = false, [go, security]) |
||||
|
|
||||
|
###======================= update metadata from telnet============== |
||||
|
def icy_update(v) = |
||||
|
# Parse the argument |
||||
|
l = string.split(separator=",",v) |
||||
|
def split(l,v) = |
||||
|
v = string.split(separator="=",v) |
||||
|
if list.length(v) >= 2 then |
||||
|
list.append(l,[(list.nth(v,0,default=""),list.nth(v,1,default=""))]) |
||||
|
else |
||||
|
l |
||||
|
end |
||||
|
end |
||||
|
meta = list.fold(split,[],l) |
||||
|
|
||||
|
# Update metadata |
||||
|
icy.update_metadata(mount="/radio",password=ICECAST_SERVER_PASSWORD, |
||||
|
host=ICECAST_SERVER_HOST,meta) |
||||
|
icy.update_metadata(mount="/radio.ogg",password=ICECAST_SERVER_PASSWORD, |
||||
|
host=ICECAST_SERVER_HOST,meta) |
||||
|
"Done !" |
||||
|
end |
||||
|
|
||||
|
###============ register the ability for telnet metadata update ===== |
||||
|
server.register("update",namespace="metadata", |
||||
|
description="Update metadata", |
||||
|
usage="update song=..", |
||||
|
icy_update) |
||||
|
|
||||
|
###======= sound collage of 5 seconds(for testing lists) ============ |
||||
|
def add_cue_out (m) = |
||||
|
[("liq_cue_in","0"),("liq_cue_out","5")] |
||||
|
end |
||||
|
|
||||
|
#==turn on to test playlist generation etc.========================= |
||||
|
#=========== will only play 5 seconds per track =================== |
||||
|
#radio = map_metadata(add_cue_out, radio) |
||||
|
#radio = cue_cut(radio) |
||||
|
|
||||
|
#============= shutdown function =================================== |
||||
|
def shutdownhandler() |
||||
|
print("blank detected and shutting down stream") |
||||
|
shutdown() |
||||
|
end |
||||
|
|
||||
|
#========= upon 20 seconds of silence shutdown the radio =========== |
||||
|
#====== (end of stream or other problem) =========================== |
||||
|
radio = on_blank(shutdownhandler, radio) |
||||
|
|
||||
|
output.icecast(%mp3, |
||||
|
icy_metadata="true",host=ICECAST_SERVER_HOST,port=ICECAST_SERVER_PORT,password=ICECAST_SERVER_PASSWORD, |
||||
|
mount="radio",radio) |
||||
|
output.icecast(%vorbis, |
||||
|
icy_metadata="true",host=ICECAST_SERVER_HOST,port=ICECAST_SERVER_PORT,password=ICECAST_SERVER_PASSWORD, |
||||
|
mount="radio.ogg",radio) |
@ -0,0 +1,12 @@ |
|||||
|
#!/bin/sh |
||||
|
# script to inject any text into icy_metadata of icecast |
||||
|
# using telnet and liquidsoap. |
||||
|
IFS=$"\n" |
||||
|
|
||||
|
while read -r line; |
||||
|
do |
||||
|
echo "$line" |
||||
|
(sleep 2; echo "metadata.update song=$line";echo quit) | \ |
||||
|
nc localhost 1234; |
||||
|
sleep 30; |
||||
|
done |
@ -0,0 +1 @@ |
|||||
|
youtube-dl -x -o '%(title)s.%(ext)s' 'youtube-id' --audio-format mp3 --ignore-errors |
Loading…
Reference in new issue