This commit is contained in:
martin 2011-03-04 12:07:22 -05:00
parent afaea87319
commit d22ab329d8
7 changed files with 49 additions and 15 deletions

View File

@ -128,9 +128,8 @@ class ApiController extends Zend_Controller_Action
if (Schedule::ValidPypoTimeFormat($from) && Schedule::ValidPypoTimeFormat($to)) { if (Schedule::ValidPypoTimeFormat($from) && Schedule::ValidPypoTimeFormat($to)) {
$result = Schedule::ExportRangeAsJson($from, $to); $result = Schedule::ExportRangeAsJson($from, $to);
$result['stream_metadata'] = array(); $result['stream_metadata'] = array();
$result['stream_metadata']['format'] = "2"; $result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat();
$result['stream_metadata']['station_name'] = "z103"; $result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName();
$result['stream_metadata']['show_name'] = "dj danny D";
echo json_encode($result); echo json_encode($result);
} }
} }

View File

@ -29,6 +29,7 @@ class PreferenceController extends Zend_Controller_Action
$values = $form->getValues(); $values = $form->getValues();
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]); Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]);
Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]);
$this->view->statusMsg = "Preferences Updated."; $this->view->statusMsg = "Preferences Updated.";
} }

View File

@ -34,10 +34,20 @@ class Application_Form_Preferences extends Zend_Form
'value' => $defaultFade 'value' => $defaultFade
)); ));
$stream_format = new Zend_Form_Element_Radio('streamFormat');
$stream_format->setLabel('Stream Label:');
$stream_format->setMultiOptions(array("Artist - Title",
"Show - Artist - Title",
"Show",
"Station name - Show name"));
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
$this->addElement($stream_format);
$this->addElement('submit', 'submit', array( $this->addElement('submit', 'submit', array(
'class' => 'ui-button ui-state-default', 'class' => 'ui-button ui-state-default',
'ignore' => true, 'ignore' => true,
'label' => 'Submit', 'label' => 'Submit',
)); ));
} }
} }

View File

@ -86,5 +86,16 @@ class Application_Model_Preference
return Application_Model_Preference::GetValue("default_fade"); return Application_Model_Preference::GetValue("default_fade");
} }
public static function SetStreamLabelFormat($type){
Application_Model_Preference::SetValue("stream_label_format", $type);
}
public static function GetStreamLabelFormat(){
return Application_Model_Preference::getValue("stream_label_format");
}
public static function GetStationName(){
return Application_Model_Preference::getValue("station_name");
}
} }

View File

@ -396,14 +396,26 @@ class Schedule {
$row["id"] = $row["group_id"]; $row["id"] = $row["group_id"];
} }
} else { } else {
$sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, " $sql = "SELECT MIN(st.name) AS name,"
." SUM(clip_length) AS clip_length," ." MIN(pt.creator) AS creator,"
." MIN(file_id) AS file_id, COUNT(*) as count," ." st.group_id, "
." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends" ." SUM(st.clip_length) AS clip_length,"
." FROM $CC_CONFIG[scheduleTable]" ." MIN(st.file_id) AS file_id,"
." LEFT JOIN $CC_CONFIG[playListTable] ON playlist_id = $CC_CONFIG[playListTable].id" ." COUNT(*) as count,"
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')" ." MIN(st.playlist_id) AS playlist_id,"
." GROUP BY group_id" ." MIN(st.starts) AS starts,"
." MAX(st.ends) AS ends,"
." MIN(sh.name) AS show_name"
." FROM $CC_CONFIG[scheduleTable] as st"
." LEFT JOIN $CC_CONFIG[playListTable] as pt"
." ON st.playlist_id = pt.id"
." LEFT JOIN $CC_CONFIG[showInstances] as si"
." ON st.instance_id = si.id"
." LEFT JOIN $CC_CONFIG[showTable] as sh"
." ON si.show_id = sh.id"
." WHERE (st.starts >= TIMESTAMP '$p_fromDateTime')"
." AND (st.ends <= TIMESTAMP '$p_toDateTime')"
." GROUP BY st.group_id"
." ORDER BY starts"; ." ORDER BY starts";
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
@ -645,6 +657,7 @@ class Schedule {
$playlists[$pkey]['duration'] = $dx['clip_length']; $playlists[$pkey]['duration'] = $dx['clip_length'];
$playlists[$pkey]['played'] = '0'; $playlists[$pkey]['played'] = '0';
$playlists[$pkey]['schedule_id'] = $dx['group_id']; $playlists[$pkey]['schedule_id'] = $dx['group_id'];
$playlists[$pkey]['show_name'] = $dx['show_name'];
$playlists[$pkey]['user_id'] = 0; $playlists[$pkey]['user_id'] = 0;
$playlists[$pkey]['id'] = $dx["playlist_id"]; $playlists[$pkey]['id'] = $dx["playlist_id"];
$playlists[$pkey]['start'] = Schedule::CcTimeToPypoTime($dx["start"]); $playlists[$pkey]['start'] = Schedule::CcTimeToPypoTime($dx["start"]);

View File

@ -93,7 +93,6 @@ class PypoFetch:
#encode in latin-1 due to this bug: http://bugs.python.org/issue1772794 #encode in latin-1 due to this bug: http://bugs.python.org/issue1772794
tn.write(('vars.stream_metadata_type %s\n' % stream_metadata['format']).encode('latin-1')) tn.write(('vars.stream_metadata_type %s\n' % stream_metadata['format']).encode('latin-1'))
tn.write(('vars.show_name %s\n' % stream_metadata['show_name']).encode('latin-1'))
tn.write(('vars.station_name %s\n' % stream_metadata['station_name']).encode('latin-1')) tn.write(('vars.station_name %s\n' % stream_metadata['station_name']).encode('latin-1'))
tn.write('exit\n') tn.write('exit\n')
logger.debug(tn.read_all()) logger.debug(tn.read_all())
@ -236,6 +235,7 @@ class PypoFetch:
entry = dict() entry = dict()
entry['type'] = 'file' entry['type'] = 'file'
entry['annotate'] = pl_entry entry['annotate'] = pl_entry
entry['show_name'] = playlist['show_name']
ls_playlist.append(entry) ls_playlist.append(entry)
logger.debug("everything ok, adding %s to playlist", pl_entry) logger.debug("everything ok, adding %s to playlist", pl_entry)

View File

@ -141,13 +141,13 @@ class PypoPush:
#Sending schedule table row id string. #Sending schedule table row id string.
logger.debug("vars.pypo_data %s\n"%(str(liquidsoap_data["schedule_id"]))) logger.debug("vars.pypo_data %s\n"%(str(liquidsoap_data["schedule_id"])))
tn.write("vars.pypo_data %s\n"%(str(liquidsoap_data["schedule_id"]))) tn.write(("vars.pypo_data %s\n"%str(liquidsoap_data["schedule_id"])).encode('latin-1'))
for item in playlist: for item in playlist:
annotate = str(item['annotate']) annotate = str(item['annotate'])
logger.debug(annotate) logger.debug(annotate)
tn.write('queue.push %s' % (annotate)) tn.write(('queue.push %s\n' % annotate).encode('latin-1'))
tn.write("\n") tn.write(('vars.show_name %s\n' % item['show_name']).encode('latin-1'))
tn.write("exit\n") tn.write("exit\n")
logger.debug(tn.read_all()) logger.debug(tn.read_all())