Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
d534f22ce4
|
@ -901,7 +901,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
foreach ($data as $pair) {
|
foreach ($data as $pair) {
|
||||||
list($id, $gain) = $pair;
|
list($id, $gain) = $pair;
|
||||||
|
// TODO : move this code into model -- RG
|
||||||
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
|
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
|
||||||
$file->setDbReplayGain($gain);
|
$file->setDbReplayGain($gain);
|
||||||
$file->save();
|
$file->save();
|
||||||
|
|
|
@ -61,11 +61,13 @@ SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the database for the set of schedules one hour before and after the given time.
|
* Queries the database for the set of schedules one hour before
|
||||||
* If a show starts and ends within that time that is considered the current show. Then the
|
* and after the given time. If a show starts and ends within that
|
||||||
* scheduled item before it is the previous show, and the scheduled item after it is the next
|
* time that is considered the current show. Then the scheduled item
|
||||||
* show. This way the dashboard getCurrentPlaylist is very fast. But if any one of the three
|
* before it is the previous show, and the scheduled item after it
|
||||||
* show types are not found through this mechanism a call is made to the old way of querying
|
* is the next show. This way the dashboard getCurrentPlaylist is
|
||||||
|
* very fast. But if any one of the three show types are not found
|
||||||
|
* through this mechanism a call is made to the old way of querying
|
||||||
* the database to find the track info.
|
* the database to find the track info.
|
||||||
**/
|
**/
|
||||||
public static function GetPrevCurrentNext($p_previousShowID, $p_currentShowID, $p_nextShowID, $p_timeNow)
|
public static function GetPrevCurrentNext($p_previousShowID, $p_currentShowID, $p_nextShowID, $p_timeNow)
|
||||||
|
@ -83,10 +85,16 @@ SQL;
|
||||||
LEFT JOIN cc_show_instances si ON st.instance_id = si.id";
|
LEFT JOIN cc_show_instances si ON st.instance_id = si.id";
|
||||||
|
|
||||||
$streamColumns = "ws.name AS artist_name, wm.liquidsoap_data AS track_title, ";
|
$streamColumns = "ws.name AS artist_name, wm.liquidsoap_data AS track_title, ";
|
||||||
$streamJoin = "FROM cc_schedule AS st JOIN cc_webstream ws ON st.stream_id = ws.id
|
$streamJoin = <<<SQL
|
||||||
LEFT JOIN cc_show_instances AS si ON st.instance_id = si.id
|
FROM cc_schedule AS st
|
||||||
LEFT JOIN cc_subjs AS sub on sub.id = ws.creator_id
|
JOIN cc_webstream ws ON st.stream_id = ws.id
|
||||||
LEFT JOIN (SELECT * FROM cc_webstream_metadata ORDER BY start_time DESC LIMIT 1) AS wm on st.id = wm.instance_id";
|
LEFT JOIN cc_show_instances AS si ON st.instance_id = si.id
|
||||||
|
LEFT JOIN cc_subjs AS sub ON sub.id = ws.creator_id
|
||||||
|
LEFT JOIN
|
||||||
|
(SELECT *
|
||||||
|
FROM cc_webstream_metadata
|
||||||
|
ORDER BY start_time DESC LIMIT 1) AS wm ON st.id = wm.instance_id
|
||||||
|
SQL;
|
||||||
|
|
||||||
$predicateArr = array();
|
$predicateArr = array();
|
||||||
$paramMap = array();
|
$paramMap = array();
|
||||||
|
@ -118,8 +126,8 @@ SQL;
|
||||||
$numberOfRows = count($rows);
|
$numberOfRows = count($rows);
|
||||||
|
|
||||||
$results['previous'] = null;
|
$results['previous'] = null;
|
||||||
$results['current'] = null;
|
$results['current'] = null;
|
||||||
$results['next'] = null;
|
$results['next'] = null;
|
||||||
|
|
||||||
$timeNowAsMillis = strtotime($p_timeNow);
|
$timeNowAsMillis = strtotime($p_timeNow);
|
||||||
for ($i = 0; $i < $numberOfRows; ++$i) {
|
for ($i = 0; $i < $numberOfRows; ++$i) {
|
||||||
|
@ -478,8 +486,9 @@ SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
|
* Compute the difference between two times in the format .
|
||||||
* Note: currently only supports calculating millisec differences.
|
* "HH:MM:SS.mmmmmm" Note: currently only supports calculating .
|
||||||
|
* millisec differences .
|
||||||
*
|
*
|
||||||
* @param string $p_time1
|
* @param string $p_time1
|
||||||
* @param string $p_time2
|
* @param string $p_time2
|
||||||
|
|
|
@ -41,6 +41,18 @@ airtime2mutagen = {
|
||||||
"MDATA_KEY_COPYRIGHT" : "copyright",
|
"MDATA_KEY_COPYRIGHT" : "copyright",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FakeMutagen(dict):
|
||||||
|
"""
|
||||||
|
Need this fake mutagen object so that airtime_special functions return a
|
||||||
|
proper default value instead of throwing an exceptions for files that
|
||||||
|
mutagen doesn't recognize
|
||||||
|
"""
|
||||||
|
def __init__(self,path):
|
||||||
|
self.path = path
|
||||||
|
self.mime = True
|
||||||
|
self.info = True
|
||||||
|
dict.__init__(self)
|
||||||
|
|
||||||
# Some airtime attributes are special because they must use the mutagen object
|
# Some airtime attributes are special because they must use the mutagen object
|
||||||
# itself to calculate the value that they need. The lambda associated with each
|
# itself to calculate the value that they need. The lambda associated with each
|
||||||
# key should attempt to extract the corresponding value from the mutagen object
|
# key should attempt to extract the corresponding value from the mutagen object
|
||||||
|
@ -178,14 +190,20 @@ class Metadata(Loggable):
|
||||||
return
|
return
|
||||||
# TODO : Simplify the way all of these rules are handled right not it's
|
# TODO : Simplify the way all of these rules are handled right not it's
|
||||||
# extremely unclear and needs to be refactored.
|
# extremely unclear and needs to be refactored.
|
||||||
if full_mutagen is None: raise BadSongFile(fpath)
|
#if full_mutagen is None: raise BadSongFile(fpath)
|
||||||
|
if full_mutagen is None: full_mutagen = FakeMutagen(fpath)
|
||||||
self.__metadata = Metadata.airtime_dict(full_mutagen)
|
self.__metadata = Metadata.airtime_dict(full_mutagen)
|
||||||
# Now we extra the special values that are calculated from the mutagen
|
# Now we extra the special values that are calculated from the mutagen
|
||||||
# object itself:
|
# object itself:
|
||||||
for special_key,f in airtime_special.iteritems():
|
for special_key,f in airtime_special.iteritems():
|
||||||
new_val = f(full_mutagen)
|
try:
|
||||||
if new_val is not None:
|
new_val = f(full_mutagen)
|
||||||
self.__metadata[special_key] = new_val
|
if new_val is not None:
|
||||||
|
self.__metadata[special_key] = new_val
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.info("Could not get special key %s for %s" %
|
||||||
|
(special_key, fpath))
|
||||||
|
self.logger.info(str(e))
|
||||||
# Finally, we "normalize" all the metadata here:
|
# Finally, we "normalize" all the metadata here:
|
||||||
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
|
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
|
||||||
# Now we must load the md5:
|
# Now we must load the md5:
|
||||||
|
|
Loading…
Reference in New Issue