-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_transcript.php
More file actions
37 lines (29 loc) · 1.07 KB
/
Copy pathcreate_transcript.php
File metadata and controls
37 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// intialize
require 'Zend/Loader/Autoloader.php';
Zend_loader_Autoloader::getInstance();
// take a list of videoid
$ytlist = explode("\n", file_get_contents('videoid_list.txt'));
$j = 1;
for($i=0;$i<count($ytlist);$i++){
$videoId = $ytlist[$i];
echo "<p> ---------- Create text file including Subtitles for VideoId: " .$videoId . "----------</p>";
$videoCaption ='http://www.youtube.com/api/timedtext?v=' . $videoId . '&lang=en';
echo $videoCaption;
$xml = file_get_contents($videoCaption);
if (trim($xml) == '') {
echo "No Subtitles for " . $videoId;
}
else {
if (@simplexml_load_file($videoCaption)) {
$captionFeed = simplexml_load_file($videoCaption);
foreach ($captionFeed->text as $captionText) {
file_put_contents('cc/'. $videoId . '.txt', $captionText . " ", FILE_APPEND); } //create a file with the video transcript
}
else { echo "<p></p> ERROR= ". $videoId ;}
$j++;
}
}
echo "TOTAL VIDEOS " . $i;
echo "TOTAL XML LOAD VIDEOS " . $j;
?>