Commit 5dacc4b0 authored by Alexander Pushkov's avatar Alexander Pushkov

initial commit

parents
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.py, *.liq]
indent_style = space
indent_size = 4
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
# rrrrradio
Requirements:
* Liquidsoap (1.1.1 recommended) with some plugins (?)
* Python 3.4+
```bash
sudo apt-get install liquidsoap liquidsoap-plugin-all python3
```
## Usage
```bash
liquidsoap app.liq
```
radiotwitter reads some env variables. You can do:
```bash
export MUSIC_PATH=~/Music
export PORT=8841
export ICECAST_HOST=example.net
export ICECAST_PORT=8080
export ICECAST_PASSWORD='something-str0ng3r_th@N-"hackme"'
export RADIO_URL="https://goo.gl/loz2gq"
export RADIO_DESCRIPTION="my cool streabm !!!11"
liquidsoap app.liq
```
## Live streams
You need an Icecast-compatible client to stream to radiotwitter.
* **Username:** *any* \*
* **Password:** *desired username*
* **Mount:** `/live`
\* — some Icecast clients have hardcoded username `source`, so we just ignore
this field altogether.
You can modify the authorization scheme by changing the [auth.py](auth.py) file.
## Prior Art
The Liquidsoap part is mostly a copycat of [Densetos's][densetos] examples
(in Russian).
[densetos]: https://dev.densetos.com/
#!/usr/bin/env liquidsoap
set("log.file.path", "/dev/null")
set("log.stdout", true)
__version__ = "0.1.0"
%include "util.liq"
PORT = int_of_string(envdef("PORT", "8001"))
MUSIC_PATH = envdef("MUSIC_PATH", "~/Music")
ICECAST_HOST = envdef("ICECAST_HOST", "localhost")
ICECAST_PORT = int_of_string(envdef("ICECAST_PORT", "8000"))
ICECAST_PASSWORD = envdef("ICECAST_PASSWORD", "hackme")
RADIO_URL = envdef("RADIO_URL", "https://iwannadie.club")
RADIO_DESCRIPTION = envdef("RADIO_DESCRIPTION", "TEAM RRRRRRRRRRADIO RADIO")
ignore([PORT])
%include "live.liq"
%include "music.liq"
radio = fallback(track_sensitive=false, transitions=[fade, fade, fade], [live, music, sine(220.)])
output.icecast(%mp3(bitrate=320), radio,
mount="320.mp3",
host=ICECAST_HOST,
password=ICECAST_PASSWORD,
port=ICECAST_PORT,
encoding="UTF-8",
url=RADIO_URL,
description=RADIO_DESCRIPTION,
headers=[
("User-Agent", "Liquidsoap/#{liquidsoap.version} rrrrradio/#{__version__}")
]
)
#!/usr/bin/python3
import sys
def auth(password):
return password
if __name__ == '__main__':
print(auth(sys.argv[1]) or "__unauthorized__")
[general]
duration=0
bufferSecs=10
realtime=yes
[input]
device=jack
sampleRate=44100
bitsPerSample=16
channel=2
jackClientName=darkice
[icecast2-0]
format=mp3
bitrateMode=cbr
bitrate=320
server=localhost
password=ale
port=8081
mountPoint=live
name=example live
description=This is my station where I do what I want
genre=Music
current_user = ref ""
def authorize(username, password) =
# username is sometimes unmodifiable (hardcoded to "stream" in some clients),
# so we use only password
ret = get_process_lines("./auth.py #{string.utf8.escape(password)}")
ret = list.hd(ret)
if ret != "__unauthorized__" then
current_user := ret
log("User '#{!current_user}' started streaming")
true
else
log("Somebody tried to log in, but supplied wrong password")
false
end
end
def deauthorize() =
log("User '#{!current_user}' stopped streaming")
current_user := ""
end
live.core = audio_to_stereo(id="live", input.harbor(
"/live",
port=PORT,
auth=authorize,
on_disconnect=deauthorize,
buffer=10.,
max=15.,
))
live = strip_blank(max_blank=30., live.core)
music = crossfade(
start_next=2.,
fade_out=3.,
fade_in=1.,
mksafe(audio_to_stereo(playlist(
reload=86400,
prefix="replay_gain:",
MUSIC_PATH
)))
)
music = random([music])
def envdef(name, default) =
val = getenv(name)
if val == "" then default else val end
end
def fade(a, b) =
add(normalize=false, [
fade.initial(duration=2., b),
fade.final(duration=2., a)
])
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment