| 1 | # vim:fileencoding=utf-8:nomodified |
|---|
| 2 | # $Id$ |
|---|
| 3 | # |
|---|
| 4 | # Copyright 2010 Claudio Pisa (clauz at ninux dot org) |
|---|
| 5 | # |
|---|
| 6 | # This file is part of RadioMate |
|---|
| 7 | # |
|---|
| 8 | # RadioMate is free software: you can redistribute it and/or modify |
|---|
| 9 | # it under the terms of the GNU General Public License as published by |
|---|
| 10 | # the Free Software Foundation, either version 3 of the License, or |
|---|
| 11 | # (at your option) any later version. |
|---|
| 12 | # |
|---|
| 13 | # RadioMate is distributed in the hope that it will be useful, |
|---|
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | # GNU General Public License for more details. |
|---|
| 17 | # |
|---|
| 18 | # You should have received a copy of the GNU General Public License |
|---|
| 19 | # along with RadioMate. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 20 | # |
|---|
| 21 | |
|---|
| 22 | import random |
|---|
| 23 | import time |
|---|
| 24 | from base import * |
|---|
| 25 | |
|---|
| 26 | __all__ = ["LiveJukeSlot"] |
|---|
| 27 | |
|---|
| 28 | class LiveJukeSlot(JukeSlot): |
|---|
| 29 | def __init__(self, timeslot, mainpassword): |
|---|
| 30 | JukeSlot.__init__(self, mainpassword=mainpassword, timeslot=timeslot) |
|---|
| 31 | |
|---|
| 32 | def liquidsoapcode(self): |
|---|
| 33 | liq = """ |
|---|
| 34 | #live |
|---|
| 35 | |
|---|
| 36 | set("log.file.path",'/tmp/lliq.log') |
|---|
| 37 | set("server.telnet", false) |
|---|
| 38 | set("harbor.bind_addr", "0.0.0.0") |
|---|
| 39 | set("harbor.port", %d) |
|---|
| 40 | |
|---|
| 41 | transfunction = fun(a,b) -> sequence([fade.final(a, type="sin"), blank(duration=1.), fade.initial(b, type="sin")]) |
|---|
| 42 | |
|---|
| 43 | livestream = input.harbor(password="%s", "%s") |
|---|
| 44 | |
|---|
| 45 | fallbackplaylist = %s |
|---|
| 46 | |
|---|
| 47 | radio = fallback(track_sensitive=false, |
|---|
| 48 | [livestream, fallbackplaylist, blank()], |
|---|
| 49 | transitions=[transfunction, transfunction, transfunction]) |
|---|
| 50 | |
|---|
| 51 | def rewritemeta(m) = |
|---|
| 52 | [("song", "%s")] |
|---|
| 53 | end |
|---|
| 54 | radio = map_metadata(rewritemeta, radio) |
|---|
| 55 | |
|---|
| 56 | output.icecast.mp3( |
|---|
| 57 | host='127.0.0.1', |
|---|
| 58 | port = %d, |
|---|
| 59 | password = "%s", |
|---|
| 60 | mount = "radiomate.mp3", |
|---|
| 61 | restart=true, |
|---|
| 62 | description="%s", |
|---|
| 63 | radio) |
|---|
| 64 | """ % (config.LIVESTREAMPORT, self.slotparams['livepassword'], config.LIVESTREAMMOUNT, |
|---|
| 65 | self.getFallBackPlayListLiquidCode(), self.title, config.INTERNALJUKEPORT, |
|---|
| 66 | self.mainpassword, self.title) |
|---|
| 67 | return liq |
|---|
| 68 | |
|---|
| 69 | JUKESLOTTYPEDICT['simplelive'] = LiveJukeSlot |
|---|