CC-2044: remove hardcoded settings from application/configs/conf.php
-refactored some code to begin work on this...
This commit is contained in:
parent
54f378049d
commit
161505a6df
|
@ -19,10 +19,6 @@ $baseFilesDir = __DIR__.'/../../files';
|
||||||
|
|
||||||
$CC_CONFIG = array(
|
$CC_CONFIG = array(
|
||||||
|
|
||||||
// Set the URL of your installation
|
|
||||||
'storageUrlHost' => 'localhost',
|
|
||||||
'storageUrlPort' => 80,
|
|
||||||
|
|
||||||
// Name of the web server user
|
// Name of the web server user
|
||||||
'webServerUser' => 'www-data',
|
'webServerUser' => 'www-data',
|
||||||
|
|
||||||
|
|
|
@ -1481,10 +1481,7 @@ class StoredFile {
|
||||||
public function getFileUrl()
|
public function getFileUrl()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
return "http://$CC_CONFIG[storageUrlHost]"
|
return $this->gunid.".".$this->getFileExtension();
|
||||||
.":$CC_CONFIG[storageUrlPort]"
|
|
||||||
.$CC_CONFIG["apiPath"]."get-media/file/"
|
|
||||||
.$this->gunid.".".$this->getFileExtension();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,7 +117,7 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
|
|
||||||
def __get_airtime_version(self, verbose = True):
|
def __get_airtime_version(self, verbose = True):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["version_url"]
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["version_url"])
|
||||||
logger.debug("Trying to contact %s", url)
|
logger.debug("Trying to contact %s", url)
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
|
|
||||||
|
@ -198,7 +198,8 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
# Construct the URL
|
# Construct the URL
|
||||||
export_url = self.config["base_url"] + self.config["api_base"] + self.config["export_url"]
|
#export_url = self.config["base_url"] + self.config["api_base"] + self.config["export_url"]
|
||||||
|
export_url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["export_url"])
|
||||||
|
|
||||||
logger.info("Fetching schedule from %s", export_url)
|
logger.info("Fetching schedule from %s", export_url)
|
||||||
export_url = export_url.replace('%%api_key%%', self.config["api_key"])
|
export_url = export_url.replace('%%api_key%%', self.config["api_key"])
|
||||||
|
@ -215,12 +216,15 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
return status, response
|
return status, response
|
||||||
|
|
||||||
|
|
||||||
def get_media(self, src, dst):
|
def get_media(self, uri, dst):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
src = "http://%s:%s/%s/%s" % \
|
||||||
|
(self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["get_media_url"])
|
||||||
|
src = src.replace("%%file%%", uri)
|
||||||
logger.info("try to download from %s to %s", src, dst)
|
logger.info("try to download from %s to %s", src, dst)
|
||||||
src = src + "/api_key/" + self.config["api_key"]
|
src = src.replace("%%api_key%%", self.config["api_key"])
|
||||||
# check if file exists already before downloading again
|
# check if file exists already before downloading again
|
||||||
filename, headers = urllib.urlretrieve(src, dst)
|
filename, headers = urllib.urlretrieve(src, dst)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -234,7 +238,9 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
playlist = schedule[pkey]
|
playlist = schedule[pkey]
|
||||||
schedule_id = playlist["schedule_id"]
|
schedule_id = playlist["schedule_id"]
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_item_url"]
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["update_item_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["update_item_url"])
|
||||||
|
|
||||||
url = url.replace("%%schedule_id%%", str(schedule_id))
|
url = url.replace("%%schedule_id%%", str(schedule_id))
|
||||||
logger.debug(url)
|
logger.debug(url)
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
|
@ -261,7 +267,8 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
response = ''
|
response = ''
|
||||||
try:
|
try:
|
||||||
schedule_id = data
|
schedule_id = data
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"]
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["update_start_playing_url"])
|
||||||
url = url.replace("%%media_id%%", str(media_id))
|
url = url.replace("%%media_id%%", str(media_id))
|
||||||
url = url.replace("%%schedule_id%%", str(schedule_id))
|
url = url.replace("%%schedule_id%%", str(schedule_id))
|
||||||
logger.debug(url)
|
logger.debug(url)
|
||||||
|
@ -290,7 +297,8 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
response = ''
|
response = ''
|
||||||
try:
|
try:
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["show_schedule_url"]
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["show_schedule_url"])
|
||||||
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["show_schedule_url"]
|
||||||
logger.debug(url)
|
logger.debug(url)
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
|
|
||||||
|
@ -307,7 +315,9 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
response = ''
|
response = ''
|
||||||
try:
|
try:
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["upload_file_url"]
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["upload_file_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["upload_file_url"])
|
||||||
|
|
||||||
logger.debug(url)
|
logger.debug(url)
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
|
|
||||||
|
@ -368,7 +378,9 @@ class ObpApiClient():
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
# lookup OBP version
|
# lookup OBP version
|
||||||
url = self.config["base_url"] + self.config["api_base"]+ self.config["version_url"]
|
#url = self.config["base_url"] + self.config["api_base"]+ self.config["version_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["version_url"])
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.debug("Trying to contact %s", url)
|
logger.debug("Trying to contact %s", url)
|
||||||
|
@ -427,7 +439,8 @@ class ObpApiClient():
|
||||||
range['end'] = end
|
range['end'] = end
|
||||||
|
|
||||||
# Construct the URL
|
# Construct the URL
|
||||||
export_url = self.config["base_url"] + self.config["api_base"] + self.config["export_url"]
|
#export_url = self.config["base_url"] + self.config["api_base"] + self.config["export_url"]
|
||||||
|
export_url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["export_url"])
|
||||||
|
|
||||||
# Insert the start and end times into the URL
|
# Insert the start and end times into the URL
|
||||||
export_url = export_url.replace('%%api_key%%', self.config["api_key"])
|
export_url = export_url.replace('%%api_key%%', self.config["api_key"])
|
||||||
|
@ -465,7 +478,8 @@ class ObpApiClient():
|
||||||
def notify_scheduled_item_start_playing(self, pkey, schedule):
|
def notify_scheduled_item_start_playing(self, pkey, schedule):
|
||||||
#def update_scheduled_item(self, item_id, value):
|
#def update_scheduled_item(self, item_id, value):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_item_url"]
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["update_item_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["update_item_url"])
|
||||||
url = url.replace("%%item_id%%", str(schedule[pkey]["id"]))
|
url = url.replace("%%item_id%%", str(schedule[pkey]["id"]))
|
||||||
url = url.replace("%%played%%", "1")
|
url = url.replace("%%played%%", "1")
|
||||||
|
|
||||||
|
@ -495,7 +509,8 @@ class ObpApiClient():
|
||||||
playlist_id = data["playlist_id"]
|
playlist_id = data["playlist_id"]
|
||||||
transmission_id = data["transmission_id"]
|
transmission_id = data["transmission_id"]
|
||||||
|
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"]
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["update_start_playing_url"])
|
||||||
url = url.replace("%%playlist_type%%", str(playlist_type))
|
url = url.replace("%%playlist_type%%", str(playlist_type))
|
||||||
url = url.replace("%%export_source%%", str(export_source))
|
url = url.replace("%%export_source%%", str(export_source))
|
||||||
url = url.replace("%%media_id%%", str(media_id))
|
url = url.replace("%%media_id%%", str(media_id))
|
||||||
|
@ -521,7 +536,8 @@ class ObpApiClient():
|
||||||
def generate_range_dp(self):
|
def generate_range_dp(self):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
url = self.config["base_url"] + self.config["api_base"] + self.config["generate_range_url"]
|
#url = self.config["base_url"] + self.config["api_base"] + self.config["generate_range_url"]
|
||||||
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], self.config["base_port"], self.config["api_base"], self.config["generate_range_url"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = urllib.urlopen(url, self.api_auth)
|
response = urllib.urlopen(url, self.api_auth)
|
||||||
|
|
|
@ -18,7 +18,8 @@ file_dir = '/opt/pypo/files/'
|
||||||
tmp_dir = '/opt/pypo/tmp/'
|
tmp_dir = '/opt/pypo/tmp/'
|
||||||
|
|
||||||
# Hostname
|
# Hostname
|
||||||
base_url = 'http://localhost/'
|
base_url = 'localhost'
|
||||||
|
base_port = 80
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
# Liquidsoap settings #
|
# Liquidsoap settings #
|
||||||
|
@ -77,7 +78,7 @@ cue_style = 'pre'
|
||||||
api_key = 'AAA'
|
api_key = 'AAA'
|
||||||
|
|
||||||
# Path to the base of the API
|
# Path to the base of the API
|
||||||
api_base = 'api/'
|
api_base = 'api'
|
||||||
|
|
||||||
# URL to get the version number of the server API
|
# URL to get the version number of the server API
|
||||||
version_url = 'version/api_key/%%api_key%%'
|
version_url = 'version/api_key/%%api_key%%'
|
||||||
|
@ -85,7 +86,9 @@ version_url = 'version/api_key/%%api_key%%'
|
||||||
# Schedule export path.
|
# Schedule export path.
|
||||||
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||||
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||||
export_url = 'schedule/api_key/%%api_key%%'
|
export_url = 'schedule/api_key/%%api_key%%'
|
||||||
|
|
||||||
|
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
|
||||||
|
|
||||||
# Update whether a schedule group has begun playing.
|
# Update whether a schedule group has begun playing.
|
||||||
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
|
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
|
||||||
|
|
|
@ -208,12 +208,8 @@ class PypoFetch(Thread):
|
||||||
(self.cache_dir, str(pkey), str(media['id']), str(float(media['cue_in']) / 1000), str(float(media['cue_out']) / 1000), str(fileExt))
|
(self.cache_dir, str(pkey), str(media['id']), str(float(media['cue_in']) / 1000), str(float(media['cue_out']) / 1000), str(fileExt))
|
||||||
do_cue = True
|
do_cue = True
|
||||||
|
|
||||||
# check if it is a remote file, if yes download
|
# download media file
|
||||||
if media['uri'][0:4] == 'http':
|
self.handle_remote_file(media, dst, do_cue)
|
||||||
self.handle_remote_file(media, dst, do_cue)
|
|
||||||
else:
|
|
||||||
logger.debug("invalid media uri: %s", media['uri'])
|
|
||||||
|
|
||||||
|
|
||||||
if True == os.access(dst, os.R_OK):
|
if True == os.access(dst, os.R_OK):
|
||||||
# check filesize (avoid zero-byte files)
|
# check filesize (avoid zero-byte files)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
api_client = "airtime"
|
api_client = "airtime"
|
||||||
|
|
||||||
# Hostname
|
# Hostname
|
||||||
base_url = 'http://localhost/'
|
base_url = 'localhost'
|
||||||
|
|
||||||
# base path to store recordered shows at
|
# base path to store recordered shows at
|
||||||
base_recorded_files = '/home/pypo/Music/'
|
base_recorded_files = '/home/pypo/Music/'
|
||||||
|
@ -10,7 +10,7 @@ base_recorded_files = '/home/pypo/Music/'
|
||||||
api_key = 'AAA'
|
api_key = 'AAA'
|
||||||
|
|
||||||
# Path to the base of the API
|
# Path to the base of the API
|
||||||
api_base = 'api/'
|
api_base = 'api'
|
||||||
|
|
||||||
# URL to get the version number of the server API
|
# URL to get the version number of the server API
|
||||||
version_url = 'version/api_key/%%api_key%%'
|
version_url = 'version/api_key/%%api_key%%'
|
||||||
|
|
Loading…
Reference in New Issue