Skip to content

Instantly share code, notes, and snippets.

@lkysow
Created November 11, 2014 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkysow/0fe45f25c9817381e131 to your computer and use it in GitHub Desktop.
Save lkysow/0fe45f25c9817381e131 to your computer and use it in GitHub Desktop.
Quick and dirty script to provide an API that would show the
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$files = scandir('.');
$videos = array_filter($files, function($filename) {
return strpos($filename, 'VID') !== false && strpos($filename, '-thumbnail') === false;
});
$json = [];
foreach($videos as $video) {
$json[] = [
'videoUrl' => $video,
'thumbnailUrl' => $video . '-thumbnail.jpg'
];
}
echo json_encode($json);
/** Example Response:
* [
{
"videoUrl": "VID_1415583006.mp4",
"thumbnailUrl": "VID_1415583006.mp4-thumbnail.jpg"
},
{
"videoUrl": "VID_1415592608.mp4",
"thumbnailUrl": "VID_1415592608.mp4-thumbnail.jpg"
}
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment