Fix: Reformatting Youtube Auto Generated Caption File

If you download auto-generated caption file from youtube and then use it in other platform like vimeo, you will see this auto-generated caption file doesn’t work. We can fix this by running a regular expression like this: $caption_raw = file_get_contents($file_path); $caption_formatted = preg_replace(‘/(<\d{2}:\d{2}:.*?(?:>)<c>)|(<\/c>)|(align:start position:\d+%)/’, ”, $caption_raw); $over_written = file_put_contents($file_path, $caption_formatted);