* Index a given file and its metadata. */
( $file_path, &$index, $save_duration = false )
| 218 | * Index a given file and its metadata. |
| 219 | */ |
| 220 | function index_file( $file_path, &$index, $save_duration = false ) { |
| 221 | global $base; |
| 222 | global $existing_programming; |
| 223 | |
| 224 | if ( ! isset( $index[ $file_path ] ) ) { |
| 225 | $content_data = new stdClass(); |
| 226 | |
| 227 | $index_key = substr( $file_path, max( 0, strlen( $base ) - 1 ) ); |
| 228 | |
| 229 | if ( $save_duration ) { |
| 230 | $duration = existing_duration( $index_key ); |
| 231 | |
| 232 | if ( ! $duration ) { |
| 233 | $duration = get_duration( $file_path ); |
| 234 | } |
| 235 | |
| 236 | if ( $duration ) { |
| 237 | $content_data->duration = $duration; |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | $possible_caption_files = array( |
| 242 | $file_path . ".vtt", |
| 243 | preg_replace( '/\.[^\.]+$/', '.vtt', $file_path ), |
| 244 | ); |
| 245 | |
| 246 | foreach ( $possible_caption_files as $possible_caption_file ) { |
| 247 | if ( file_exists( $possible_caption_file ) ) { |
| 248 | $content_data->captions = substr( $possible_caption_file, max( 0, strlen( $base ) - 1 ) ); |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | $index[ $index_key ] = $content_data; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Find all files in a given directory, including files within subfolders (and their subfolders, etc.) |
no test coverage detected