add playout section
This commit is contained in:
@@ -16,8 +16,9 @@ our %EXPORT_TAGS = ( 'all' => [ @EXPORT_OK ] );
|
||||
|
||||
# columns:
|
||||
# id, project_id, studio_id, event_id
|
||||
# created_by, created_at
|
||||
# path, md5
|
||||
# path, size, created_by, created_at
|
||||
# mastered, processed
|
||||
# audioDuration, eventDuration, rmsLeft, rmsRight
|
||||
|
||||
sub debug;
|
||||
|
||||
@@ -88,16 +89,22 @@ sub get{
|
||||
,studio_id
|
||||
,event_id
|
||||
,path
|
||||
,md5
|
||||
,size
|
||||
,created_by
|
||||
,created_at
|
||||
,modified_at
|
||||
,mastered
|
||||
,processed
|
||||
,audioDuration
|
||||
,eventDuration
|
||||
,rmsLeft
|
||||
,rmsRight
|
||||
from calcms_audio_recordings
|
||||
$whereClause
|
||||
order by created_at desc
|
||||
};
|
||||
|
||||
print STDERR Dumper($query).Dumper($bind_values);
|
||||
#print STDERR Dumper($query).Dumper($bind_values);
|
||||
my $entries=db::get($dbh, $query, $bind_values);
|
||||
return $entries;
|
||||
}
|
||||
@@ -109,21 +116,31 @@ sub update{
|
||||
my $dbh = shift;
|
||||
my $entry = shift;
|
||||
|
||||
print STDERR "update:".Dumper($entry);
|
||||
#print STDERR "update:".Dumper($entry);
|
||||
|
||||
my $day_start=$config->{date}->{day_starting_hour};
|
||||
|
||||
my $bind_values=[
|
||||
$entry->{path}, $entry->{md5}, $entry->{size}, $entry->{created_by}, $entry->{created_at},
|
||||
$entry->{path}, $entry->{size},
|
||||
$entry->{created_by}, $entry->{created_at},
|
||||
$entry->{modified_at} || time::time_to_datetime(time()),
|
||||
$entry->{processed}, $entry->{mastered},
|
||||
$entry->{eventDuration}, $entry->{audioDuration},
|
||||
$entry->{rmsLeft}, $entry->{rmsRight},
|
||||
$entry->{project_id}, $entry->{studio_id}, $entry->{event_id}
|
||||
];
|
||||
|
||||
my $query=qq{
|
||||
update calcms_audio_recordings
|
||||
set path=?, md5=?, size=?, created_by=?, created_at=?
|
||||
set path=?, size=?,
|
||||
created_by=?, created_at=?,
|
||||
modified_at=?,
|
||||
processed=?, mastered=?,
|
||||
eventDuration=?, audioDuration=?,
|
||||
rmsLeft=?, rmsRight=?
|
||||
where project_id=? and studio_id=? and event_id=?
|
||||
};
|
||||
print STDERR Dumper($query).Dumper($bind_values);
|
||||
#print STDERR Dumper($query).Dumper($bind_values);
|
||||
return db::put($dbh, $query, $bind_values);
|
||||
}
|
||||
|
||||
@@ -138,15 +155,20 @@ sub insert{
|
||||
return undef unless defined $entry->{event_id};
|
||||
return undef unless defined $entry->{path};
|
||||
|
||||
print STDERR "insert into audio_recordings:".Dumper($entry);
|
||||
#print STDERR "insert into audio_recordings:".Dumper($entry);
|
||||
return db::insert($dbh, 'calcms_audio_recordings', {
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path},
|
||||
size => $entry->{size},
|
||||
md5 => $entry->{md5},
|
||||
created_by => $entry->{created_by},
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path},
|
||||
size => $entry->{size},
|
||||
created_by => $entry->{created_by},
|
||||
eventDuration => $entry->{eventDuration},
|
||||
audioDuration => $entry->{audioDuration},
|
||||
rmsLeft => $entry->{rmsLeft},
|
||||
rmsRight => $entry->{rmsRight},
|
||||
processed => $entry->{processed},
|
||||
mastered => $entry->{mastered} || '0',
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,22 @@ use studios;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK =
|
||||
qw(init get_cached_or_render get modify_results get_query render get_running_event_id delete check_params configure_cache get_duration calc_dates get_keys add_recordings);
|
||||
our @EXPORT_OK = qw(
|
||||
init
|
||||
get_cached_or_render
|
||||
get
|
||||
modify_results
|
||||
get_query
|
||||
render
|
||||
get_running_event_id
|
||||
delete
|
||||
check_params
|
||||
configure_cache
|
||||
get_duration
|
||||
calc_dates
|
||||
get_keys
|
||||
add_recordings
|
||||
);
|
||||
our %EXPORT_TAGS = ( 'all' => [@EXPORT_OK] );
|
||||
|
||||
sub init {
|
||||
@@ -1050,7 +1064,7 @@ sub get_query {
|
||||
$query .= ', ar.path';
|
||||
$query .= ', ar.size';
|
||||
$query .= ', ar.created_by uploaded_by';
|
||||
$query .= ', ar.created_at uploaded_at';
|
||||
$query .= ', ar.modified_at uploaded_at';
|
||||
#push @$where_cond, 'e.id=ar.event_id';
|
||||
}
|
||||
|
||||
@@ -1456,10 +1470,13 @@ sub get_duration {
|
||||
my $event = shift;
|
||||
my $timezone = $config->{date}->{time_zone};
|
||||
my $start = time::get_datetime( $event->{start}, $timezone );
|
||||
my $end = time::get_datetime( $event->{end}, $timezone );
|
||||
my $end = time::get_datetime( $event->{end}, $timezone );
|
||||
#my $seconds = $end->subtract($start)->in_units("minutes");
|
||||
#return $seconds;
|
||||
return undef unless defined $start;
|
||||
return undef unless defined $end;
|
||||
my $duration = $end->epoch() - $start->epoch();
|
||||
#print STDERR "duration=$duration, end=".$end->datetime()." start=".$start->datetime()."\n";
|
||||
return $duration / 60;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,9 @@ sub get{
|
||||
|
||||
my $conditions='';
|
||||
$conditions=" where ".join(" and ",@conditions) if (@conditions>0);
|
||||
|
||||
my $order='start';
|
||||
$order=$condition->{order} if (defined $condition->{order} ) && ($condition->{order} ne'');
|
||||
|
||||
my $query=qq{
|
||||
select date(start) start_date
|
||||
@@ -111,9 +114,12 @@ sub get{
|
||||
,rms_left
|
||||
,rms_right
|
||||
,rms_image
|
||||
,modified_at
|
||||
,updated_at
|
||||
from calcms_playout
|
||||
$conditions
|
||||
order by start
|
||||
order by $order
|
||||
$limit
|
||||
};
|
||||
|
||||
#print STDERR Dumper($query).Dumper(\@bind_values);
|
||||
@@ -128,7 +134,7 @@ sub sync{
|
||||
my $options=shift;
|
||||
|
||||
#print STDERR Dumper($config);
|
||||
#print STDERR Dumper($options);
|
||||
print STDERR "upload ".Dumper($options);
|
||||
return undef unless defined $options->{project_id} ;
|
||||
return undef unless defined $options->{studio_id} ;
|
||||
return undef unless defined $options->{from} ;
|
||||
@@ -227,7 +233,7 @@ sub has_changed{
|
||||
my $newEntry=shift;
|
||||
|
||||
my $update=0;
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library'){
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library', 'modified_at'){
|
||||
return 1 if ($oldEntry->{$key}||'') ne ($newEntry->{$key}||'');
|
||||
}
|
||||
return 0;
|
||||
@@ -242,7 +248,7 @@ sub update{
|
||||
|
||||
return if has_changed($oldEntry, $newEntry)==0;
|
||||
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library', 'rms_left', 'rms_right', 'rms_image', 'replay_gain'){
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library', 'rms_left', 'rms_right', 'rms_image', 'replay_gain', 'modified_at'){
|
||||
if (($oldEntry->{$key}||'') ne ($newEntry->{$key}||'')){
|
||||
$oldEntry->{$key}=$newEntry->{$key};
|
||||
}
|
||||
@@ -257,13 +263,13 @@ sub update{
|
||||
$entry->{end_date} = time::add_hours_to_datetime($entry->{end}, -$day_start);
|
||||
|
||||
my $bind_values=[
|
||||
$entry->{end}, $entry->{duration}, $entry->{file}, $entry->{errors},
|
||||
$entry->{start_date}, $entry->{end_date},
|
||||
$entry->{channels}, $entry->{'format'}, $entry->{format_version}, $entry->{format_profile}, $entry->{format_settings}, $entry->{stream_size},
|
||||
$entry->{bitrate}, $entry->{bitrate_mode}, $entry->{sampling_rate}, $entry->{writing_library},
|
||||
$entry->{rms_left}, $entry->{rms_right}, $entry->{rms_image},
|
||||
$entry->{replay_gain},
|
||||
$entry->{project_id}, $entry->{studio_id}, $entry->{start}
|
||||
$entry->{end}, $entry->{duration}, $entry->{file}, $entry->{errors},
|
||||
$entry->{start_date}, $entry->{end_date},
|
||||
$entry->{channels}, $entry->{'format'}, $entry->{format_version}, $entry->{format_profile}, $entry->{format_settings}, $entry->{stream_size},
|
||||
$entry->{bitrate}, $entry->{bitrate_mode}, $entry->{sampling_rate}, $entry->{writing_library},
|
||||
$entry->{rms_left}, $entry->{rms_right}, $entry->{rms_image},
|
||||
$entry->{replay_gain}, $entry->{modified_at},
|
||||
$entry->{project_id}, $entry->{studio_id}, $entry->{start}
|
||||
];
|
||||
my $query=qq{
|
||||
update calcms_playout
|
||||
@@ -272,7 +278,7 @@ sub update{
|
||||
channels=?, format=?, format_version=?, format_profile=?, format_settings=?, stream_size=?,
|
||||
bitrate=?, bitrate_mode=?, sampling_rate=?, writing_library=?,
|
||||
rms_left=?, rms_right=?, rms_image=?,
|
||||
replay_gain=?
|
||||
replay_gain=?, modified_at=?
|
||||
where project_id=? and studio_id=? and start=?
|
||||
};
|
||||
return db::put($dbh, $query, $bind_values);
|
||||
@@ -318,7 +324,8 @@ sub insert{
|
||||
bitrate => $entry->{bitrate},
|
||||
bitrate_mode => $entry->{bitrate_mode},
|
||||
sampling_rate => $entry->{sampling_rate},
|
||||
writing_library => $entry->{writing_library}
|
||||
writing_library => $entry->{writing_library},
|
||||
modified_at => $entry->{modified_at}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user