Skip to content

Commit

Permalink
Deal with committee videos properly
Browse files Browse the repository at this point in the history
Toward #33.
  • Loading branch information
waldoj committed Jan 26, 2018
1 parent aec86b3 commit 1328000
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bin/get_video.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function delete($message)
set_time_limit(0);

# Retrieve the file and store it locally.
$video->filename = $video->date . '.mp4';
$video->filename = $video->chamber . '-' . $video->type . '-' . $video->date . '.mp4';
$fp = fopen($video->filename, 'w+');
$ch = curl_init($video->url);
curl_setopt($ch, CURLOPT_FILE, $fp);
Expand All @@ -163,7 +163,14 @@ function delete($message)
/*
* Copy the file to S3.
*/
$s3_key = $video->chamber . '/' . 'floor/' . $video->date . '.mp4';
if ($video->type == 'floor')
{
$s3_key = $video->chamber . '/' . 'floor/' . $video->date . '.mp4';
}
elseif ($video->type == 'committee')
{
$s3_key = $video->chamber . '/' . 'committee/' . urlencode(strtolower($video->committee)) . '/' . $video->date . '.mp4';
}
$s3_url = 'https://s3.amazonaws.com/video.richmondsunlight.com/' . $s3_key;

try
Expand Down Expand Up @@ -198,7 +205,9 @@ function delete($message)
. substr($video->date, 6, 2);
$metadata['s3_url'] = $s3_url;
$metadata['chamber'] = $video->chamber;
$metadata['type'] = $video->type;
$metadata['committee'] = $video->committee;
file_put_contents('../video/metadata.json', json_encode($metadata));

$log->put('Found and stored new ' . ucfirst($video->chamber) . ' video, for ' . $video->date
. '.', 4);
$log->put('Found and stored new ' . ucfirst($video->chamber) . ' ' . $video->type . ' video, for '
. $video->date . '.', 4);

0 comments on commit 1328000

Please sign in to comment.