diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index bd6680c14..462025a1b 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1441,7 +1441,8 @@ class Application_Model_Preference // SAAS-876 - Toggle indicating whether user is using custom stream settings public static function getUsingCustomStreamSettings() { - return self::getValue("using_custom_stream_settings"); + $val = self::getValue("using_custom_stream_settings"); + return empty($val) ? false : $val; } public static function setUsingCustomStreamSettings($value) { diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index bec73fc7d..f6967d254 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1019,9 +1019,11 @@ SQL; $media_id = $item['file_id']; $storedFile = Application_Model_StoredFile::RecallById($media_id); $file = $storedFile->getPropelOrm(); - $uri = $file->getAbsoluteFilePath(); + //Even local files are downloaded through the REST API in case we need to transform + //their filenames (eg. in the case of a bad file extension, because Liquidsoap won't play them) + $uri = Application_Common_HTTPHelper::getStationUrl() . "/rest/media/" . $media_id; + //$uri = $file->getAbsoluteFilePath(); - $baseUrl = Application_Common_OsPath::getBaseDir(); $filesize = $file->getFileSize(); self::createFileScheduleEvent($data, $item, $media_id, $uri, $filesize); } diff --git a/install b/install index 0a6598ca8..afb1f1b00 100755 --- a/install +++ b/install @@ -313,8 +313,10 @@ else fi # Check if composer exists and install if it doesn't +set +e eval hash "composer" 2>/dev/null commandFound=$? +set -e if [[ ! ${commandFound} -eq 0 ]]; then curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer diff --git a/python_apps/pypo/pypo/pypofetch.py b/python_apps/pypo/pypo/pypofetch.py index c6fcd2468..6406436ac 100644 --- a/python_apps/pypo/pypo/pypofetch.py +++ b/python_apps/pypo/pypo/pypofetch.py @@ -345,9 +345,8 @@ class PypoFetch(Thread): for key in media: media_item = media[key] if (media_item['type'] == 'file'): - self.sanity_check_media_item(media_item) - fileExt = os.path.splitext(media_item['uri'])[1] - dst = os.path.join(download_dir, unicode(media_item['id']) + fileExt) + fileExt = self.sanity_check_media_item(media_item) + dst = os.path.join(download_dir, unicode(media_item['id']) + unicode(fileExt)) media_item['dst'] = dst media_item['file_ready'] = False media_filtered[key] = media_item @@ -377,21 +376,10 @@ class PypoFetch(Thread): start = datetime.strptime(media_item['start'], "%Y-%m-%d-%H-%M-%S") end = datetime.strptime(media_item['end'], "%Y-%m-%d-%H-%M-%S") - root, ext = os.path.splitext(media_item['uri']) mime = media_item['metadata']['mime'] - mimetypes.init() + mimetypes.init(["%s/mime.types" % os.path.dirname(os.path.realpath(__file__))]) mime_ext = mimetypes.guess_extension(mime, strict=False) - if mime_ext is None: - mimes = mimetypes.read_mime_types("%s/mime.types" % os.path.dirname(os.path.realpath(__file__))) - for k, v in mimes.iteritems(): - if v == mime: - mime_ext = k - - if mime_ext is not None and mime_ext != ext: - self.logger.info("Invalid extension %s for file %s, changing to %s" % (ext, root, mime_ext)) - media_item['uri'] = root + mime_ext - length1 = pure.date_interval_to_seconds(end - start) length2 = media_item['cue_out'] - media_item['cue_in'] @@ -400,6 +388,10 @@ class PypoFetch(Thread): self.logger.error("cue_out - cue_in length: %s", length2) self.logger.error("Two lengths are not equal!!!") + media_item['file_ext'] = mime_ext + + return mime_ext + def is_file_opened(self, path): #Capture stderr to avoid polluting py-interpreter.log proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE) @@ -418,8 +410,7 @@ class PypoFetch(Thread): for mkey in media: media_item = media[mkey] if media_item['type'] == 'file': - fileExt = os.path.splitext(media_item['uri'])[1] - scheduled_file_set.add(unicode(media_item["id"]) + fileExt) + scheduled_file_set.add(unicode(media_item["id"]) + unicode(media_item["file_ext"])) expired_files = cached_file_set - scheduled_file_set diff --git a/python_apps/pypo/pypo/pypofile.py b/python_apps/pypo/pypo/pypofile.py index 157c8e1b5..f4288af53 100644 --- a/python_apps/pypo/pypo/pypofile.py +++ b/python_apps/pypo/pypo/pypofile.py @@ -61,7 +61,7 @@ class PypoFile(Thread): media_item['file_ready'] = not do_copy if do_copy: - self.logger.debug("copying from %s to local cache %s" % (src, dst)) + self.logger.info("copying from %s to local cache %s" % (src, dst)) try: CONFIG_SECTION = "general" username = self._config.get(CONFIG_SECTION, 'api_key')