Skip to content

Commit

Permalink
updated stream urls
Browse files Browse the repository at this point in the history
  • Loading branch information
buckket authored and buckket committed Jul 21, 2014
1 parent 4f75f46 commit da651e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/rfk/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def setup_permissions():


def setup_default_user(username, password):
users = []
users.append(User.add_user(username, password))
users = [User.add_user(username, password)]
for user in users:
rfk.database.session.add(user)
user.add_permission(code='manage-liquidsoap')
Expand Down
11 changes: 6 additions & 5 deletions lib/rfk/site/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@ def html5_player():
return render_template('html5player.html')


@listen.route('/<stream>')
@listen.route('/<string:stream>.m3u')
def playlist(stream):
"""Return a m3u playlist pointing to our load balancer"""

stream = Stream.query.filter(Stream.code == stream).first()
if stream is None:
return make_response('I\'m sorry ;_; (Invalid stream)', 404)

m3u = "#EXTM3U\r\n"
m3u += "#EXTINF:0, Radio freies Krautchan %s\r\n" % stream.name
m3u += "http://%s/listen/stream/%s\r\n" % (rfk.CONFIG.get('site', 'url'), stream.stream)
m3u += "#EXTINF:-1,Radio freies Krautchan %s\r\n" % stream.name
m3u += "http://%s/listen/%s\r\n" % (rfk.CONFIG.get('site', 'url'), stream.code)
return make_response(m3u, 200, {'Content-Type': 'application/x-mpegurl',
'Content-Disposition': 'attachment; filename="%s.m3u"' % stream.mount[1:]})


@listen.route('/stream/<stream>')
@listen.route('/<string:stream>')
def stream(stream):
"""Redirect listener to relay with least traffic usage"""

stream = Stream.query.get(int(stream))
stream = Stream.query.filter(Stream.code == stream).first()
if stream is None:
return make_response('I\'m sorry ;_; (Invalid stream)', 404)

Expand Down
4 changes: 2 additions & 2 deletions lib/rfk/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ <h1 style="padding:0 10px;"><i class="fa fa-music"></i> ON AIR</h1>
{% for stream in streams %}
<li>
{% if stream.get_status() %}
<a href="/listen/{{ stream.code }}"><i class="fa fa-play-circle"></i> {% trans %}Listen{% endtrans %} ({{ stream.name }})</a>
<a href="/listen/{{ stream.code }}.m3u"><i class="fa fa-play-circle"></i> {% trans %}Listen{% endtrans %} ({{ stream.name }})</a>
{% else %}
<a href="/listen/{{ stream.code }}"><i class="fa fa-frown"></i> {% trans %}Offline{% endtrans %} ({{ stream.name }})</a>
<a href="/listen/{{ stream.code }}.m3u"><i class="fa fa-frown"></i> {% trans %}Offline{% endtrans %} ({{ stream.name }})</a>
{% endif %}
</li>
{% else %}
Expand Down

0 comments on commit da651e6

Please sign in to comment.