CC-3224: "On-the-fly" stream rebroadcasting
- web interface - auth script for liquidsoap - DB changes
This commit is contained in:
parent
701ed82f40
commit
48bb19d758
26 changed files with 650 additions and 101 deletions
|
@ -101,3 +101,26 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
|
|||
#URL to update liquidsoap status
|
||||
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
||||
|
||||
#URL to checkl live stream auth
|
||||
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%'
|
||||
|
||||
##############
|
||||
# OBP config #
|
||||
##############
|
||||
|
||||
# URL to get the version number of the server API
|
||||
#version_url = 'api/pypo/status/json'
|
||||
|
||||
# Schedule export path.
|
||||
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||
|
||||
# Update whether an item has been played.
|
||||
#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%'
|
||||
|
||||
# Update whether an item is currently playing.
|
||||
#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%'
|
||||
|
||||
# ???
|
||||
#generate_range_url = 'api/pypo/generate_range_dp/'
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ from urlparse import urlparse
|
|||
import base64
|
||||
from configobj import ConfigObj
|
||||
import string
|
||||
import hashlib
|
||||
|
||||
AIRTIME_VERSION = "2.1.0"
|
||||
|
||||
|
@ -363,6 +364,28 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
time.sleep(retries_wait)
|
||||
|
||||
return response
|
||||
|
||||
def check_live_stream_auth(self, username, password):
|
||||
#logger = logging.getLogger()
|
||||
response = ''
|
||||
try:
|
||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["check_live_stream_auth"])
|
||||
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
url = url.replace("%%username%%", username)
|
||||
url = url.replace("%%password%%", hashlib.md5(password).hexdigest())
|
||||
|
||||
req = urllib2.Request(url)
|
||||
response = urllib2.urlopen(req).read()
|
||||
response = json.loads(response)
|
||||
except Exception, e:
|
||||
import traceback
|
||||
top = traceback.format_exc()
|
||||
print "Exception: %s", e
|
||||
print "traceback: %s", top
|
||||
response = None
|
||||
|
||||
return response
|
||||
|
||||
def setup_media_monitor(self):
|
||||
logger = self.logger
|
||||
|
|
19
python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py
Normal file
19
python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from api_clients import *
|
||||
from configobj import ConfigObj
|
||||
import sys
|
||||
import json
|
||||
|
||||
try:
|
||||
config = ConfigObj('/etc/airtime/pypo.cfg')
|
||||
|
||||
except Exception, e:
|
||||
print 'error: ', e
|
||||
sys.exit()
|
||||
|
||||
api_clients = api_client.api_client_factory(config)
|
||||
|
||||
username = sys.argv[1]
|
||||
password = sys.argv[2]
|
||||
response = api_clients.check_live_stream_auth(username, password)
|
||||
|
||||
print response['msg']
|
|
@ -41,15 +41,20 @@ default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
|
|||
#live stream setup
|
||||
set("harbor.bind_addr", "0.0.0.0")
|
||||
#auth function for live stream
|
||||
def auth(user, password) =
|
||||
if user == 'james' and password == 'james' then
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
def check_client(user,password) =
|
||||
#get the output of the php script
|
||||
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py #{user} #{password}")
|
||||
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
||||
ret = list.hd(ret)
|
||||
#return true to let the client transmit data, or false to tell harbor to decline
|
||||
if (ret == "True") then
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
live = input.harbor("test", port=8080, auth=auth)
|
||||
live = input.harbor("test", port=8080, auth=check_client)
|
||||
|
||||
s = fallback(track_sensitive=false, [live, queue, default])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue