-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
68 lines (54 loc) · 2.82 KB
/
api.php
File metadata and controls
68 lines (54 loc) · 2.82 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
ini_set('error_reporting', E_ALL);
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
parse_str(implode('&', array_slice($argv, 1)), $params);
$channel = strval($params["channel"]);
$data = file_get_contents("data.json");
$videos = json_decode($data, true);
$video_ids = array();
foreach($videos['data'] as $video){
if(isset($video['id'])){
$video_ids[] = $video['id'];
}
}
if($channel=="0"){
$xml = simplexml_load_file("https://www.youtube.com/feeds/videos.xml?channel_id=UCBa659QWEk1AI4Tg--mrJ2A");
$output = "";
foreach ($xml->entry as $entry) {
if(!in_array(str_replace("yt:video:","",$entry->id), $video_ids)){
$output = $output . '{"id":"'.str_replace("yt:video:","",$entry->id).'", "title":"'.str_replace("\"","\\\"", str_replace("\\","\\\\", $entry->title[0])).'", "lat":"", "long":"", "category":"", "comment":"", "status":"open", "internal_comment":""},'."\n";
}
}
echo substr($output,0,strlen($output)-1);
}else if($channel=="1"){
$xml = simplexml_load_file("https://www.youtube.com/feeds/videos.xml?channel_id=UCRUULstZRWS1lDvJBzHnkXA");
$output = "";
foreach ($xml->entry as $entry) {
if(!in_array(str_replace("yt:video:","",$entry->id), $video_ids)){
$output = $output . '{"id":"'.str_replace("yt:video:","",$entry->id).'", "title":"'.str_replace("\"","\\\"", str_replace("\\","\\\\", $entry->title[0])).'", "lat":"", "long":"", "category":"ParkBench", "comment":"", "status":"open", "internal_comment":""},'."\n";
}
}
echo substr($output,0,strlen($output)-1);
}else if($channel=="2"){
$xml = simplexml_load_file("https://www.youtube.com/feeds/videos.xml?channel_id=UCHC4G4X-OR5WkY-IquRGa3Q");
$output = "";
foreach ($xml->entry as $entry) {
if(!in_array(str_replace("yt:video:","",$entry->id), $video_ids)){
$output = $output . '{"id":"'.str_replace("yt:video:","",$entry->id).'", "title":"'.str_replace("\"","\\\"", str_replace("\\","\\\\", $entry->title[0])).'", "lat":"", "long":"", "category":"Plus", "comment":"", "status":"open", "internal_comment":""},'."\n";
}
}
echo substr($output,0,strlen($output)-1);
}else if($channel=="3"){
$xml = simplexml_load_file("https://www.youtube.com/feeds/videos.xml?channel_id=UCO-zhhas4n_kAPHaeLe1qnQ");
$output = "";
foreach ($xml->entry as $entry) {
if(!in_array(str_replace("yt:video:","",$entry->id), $video_ids)){
$output = $output . '{"id":"'.str_replace("yt:video:","",$entry->id).'", "title":"'.str_replace("\"","\\\"", str_replace("\\","\\\\", $entry->title[0])).'", "lat":"", "long":"", "category":"TechDif", "comment":"", "status":"open", "internal_comment":""},'."\n";
}
}
echo substr($output,0,strlen($output)-1);
}
//{"data":[
//{"comment":"//Videos from Matt and Toms Channel"},
//{"comment":"//Videos from Tom's second channel: Tom Scott plus"},
//not yet: {"comment":"//Videos from the Technical Difficulties channel"},