barrucadu / lainonlife

RIP lainchan radio, taken out by HDD failure.
https://lainon.life
MIT License
54 stars 12 forks source link

Script support for livestreaming #13

Closed barrucadu closed 7 years ago

barrucadu commented 7 years ago

Fortunately, Icecast makes livestreaming very simple. There's just a little work that needs to be done for it to be seamless.

  1. Some sort of schedule on the website. r/a/dio (click "Schedule") just has a box appear with javascript. We can use something like that too, with an appropriate non-javascript fallback.

  2. The playlist_for function in backend.py needs to be aware that the playlist may not come from MPD:

    • For the current track: perhaps a file at a designated location would work; even better would be extracting metadata from the stream from Icecast, if possible, with some fallback.
    • The "Last Played" and "Queue" can just be blank.
    • The duration of the current track can be unspecified, with radio.js and player.js displaying that nicely somehow.
  3. A script to start a stream:

    • Pause MPD
    • Turn off the Icecast outputs
    • Do whatever needs to be done for playlist_for in backend.py to know there is a stream
  4. A script to stop a stream:

    • Unpause MPD
    • Turn on the Icecast outputs
    • Undo whatever was done to backend.py

The MPD and Icecast configs are not very exciting, but in case they are of use:

icecast.xml:


<!-- There is nothing exciting here.  I have set the hostname and passwords, that's it.  Everything else is default. -->
<icecast>
  <hostname>lainon.life</hostname>

  <authentication>
    <admin-user>admin</admin-user>
    <admin-password>password</admin-password>
  </authentication>

  <paths>
    <logdir>/var/log/icecast</logdir>
    <!-- These paths will depend on your distro -->
    <adminroot>/nix/store/d7gk1q4crva10l8785aa8fwm79r3j62l-icecast-2.4.1/share/icecast/admin</adminroot>
    <webroot>/nix/store/d7gk1q4crva10l8785aa8fwm79r3j62l-icecast-2.4.1/share/icecast/web</webroot>
    <alias source="/" dest="/status.xsl"/>
  </paths>

  <listen-socket>
    <port>8000</port>
    <bind-address>::</bind-address>
  </listen-socket>   

  <security>
    <chroot>0</chroot>
    <changeowner>
        <user>nobody</user>
        <group>nogroup</group>
    </changeowner>
  </security>

  <authentication>
  <source-password>password</source-password>
  <relay-password>password</relay-password>
</authentication>

</icecast>

mpd-cyberia.conf:

# These paths will depend on your system
music_directory     "/srv/radio/music/cyberia"
playlist_directory  "/srv/radio/data/cyberia/playlists"
db_file             "/srv/radio/data/cyberia/db"
state_file          "/srv/radio/data/cyberia/state"
sticker_file        "/srv/radio/data/cyberia/sticker.sql"
log_file            "syslog"
bind_to_address     "127.0.0.1"
port                "6601"

audio_output {
  name        "cyberia (ogg)"
  description "classic lainchan radio: electronic, chiptune, weeb"
  type        "shout"
  encoder     "vorbis"
  host        "localhost"
  port        "8000"
  mount       "/cyberia.ogg"
  user        "source"
  password    "password"
  quality     "3"
  format      "44100:16:2"
  always_on   "yes"
}

audio_output {
  name        "cyberia (mp3)"
  description "classic lainchan radio: electronic, chiptune, weeb"
  type        "shout"
  encoder     "lame"
  host        "localhost"
  port        "8000"
  mount       "/cyberia.mp3"
  user        "source"
  password    "password"
  quality     "3"
  format      "44100:16:2"
  always_on   "yes"
}

audio_output {
  type "null"
  name "null"
}

For dealing with the MPD outputs, see the python-mpd2 docs.

pussinboot commented 7 years ago

hi #20

barrucadu commented 7 years ago

Closed in #20