Commit b7302b8d authored by Valentin Samir's avatar Valentin Samir

[tv] Parce que "250 caractères, c'est abusé"

De plus on met un password différent par radio et on n'utilise plus du tout
les annonces SAP pour la radio (parce que ça n'a plus de sens depuis que
la radio vient d'icecast). Mais elles sont toujours utilisé pour la TV
parent 920e2fa8
......@@ -72,18 +72,28 @@ def tv(request):
tnt=[(name, "udp://@%s:1234" % tv_dns.idn(name, fqdn=True, charset=None), image_url_for_channel(ip)) for (name, ip) in chaines().get('TNT', {}).items()]
sat=[(name, "udp://@%s:1234" % tv_dns.idn(name, fqdn=True, charset=None), image_url_for_channel(ip)) for (name, ip) in chaines().get('SAT', {}).items()]
# radio=[(name, "udp://@%s:1234" % tv_dns.idn(name, fqdn=True, charset=None), image_url_for_channel(ip)) for (name, ip) in chaines().get('Radio', {}).items()]
if request.user.is_authenticated():
radio=[(name, "http://%s:%s@tv.crans.org:8000/%s" % (request.user.username, radio_password(request.user), tv_config.multicast['Radio'][name.encode('utf8')][0]), image_url_for_channel(ip)) for (name, ip) in chaines().get('Radio', {}).items()]
else:
radio=[(name, "http://tv.crans.org:8000/%s" % tv_config.multicast['Radio'][name.encode('utf8')][0], image_url_for_channel(ip)) for (name, ip) in chaines().get('Radio', {}).items()]
radio = []
user_auth = request.user.is_authenticated()
for (name, params) in tv_config.multicast['Radio'].items():
if user_auth:
userpass = "%s:%s@" % (request.user.username, radio_password(request.user, params[0]))
else:
userpass = ""
radio.append(
(name,
"http://%stv.crans.org:8000/%s" % (userpass, params[0]),
image_url_for_channel(params[1]))
)
tnt.sort()
sat.sort()
radio.sort()
params={ 'tnt' : tnt, 'sat': sat, 'radio': radio, 'user': request.user }
return django.shortcuts.render_to_response("tv/index.html", params, context_instance=RequestContext(request))
def radio_password(user):
hash = hashlib.md5("%s~%s~%s" % (user.username, datetime.datetime.now().date(), settings.SECRET_KEY))
def radio_password(user, radio=""):
if radio.startswith("/"):
radio = radio[1:]
hash = hashlib.md5("%s~%s~%s~%s" % (user.username, datetime.datetime.now().date(), settings.SECRET_KEY, radio))
return hash.hexdigest()
@csrf_exempt
......@@ -106,7 +116,7 @@ def icecast_auth(request):
try:
user = User.objects.get(username=POST["user"])
# Si user/pass sont ok
if POST["pass"] == radio_password(user):
if POST["pass"] == radio_password(user, POST['mount']):
return response
except User.DoesNotExist:
return HttpResponseForbidden()
......
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