summaryrefslogtreecommitdiff
path: root/www/functions
diff options
context:
space:
mode:
authorroot2014-05-25 22:14:29 +0200
committerroot2014-05-25 22:14:29 +0200
commit7c8f6345ef35b6fca9283b5e1c23d22cf9466294 (patch)
tree2b0f558aa7cceb30ff59edd7efc4cc0691f72e5c /www/functions
parente5e8ee54e4b404d0cbdf69bebc3d9bdd9bd04855 (diff)
downloadrandom-7c8f6345ef35b6fca9283b5e1c23d22cf9466294.tar.gz
new style
Diffstat (limited to 'www/functions')
-rw-r--r--www/functions/func_yt.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/www/functions/func_yt.php b/www/functions/func_yt.php
new file mode 100644
index 0000000..4aa1e29
--- /dev/null
+++ b/www/functions/func_yt.php
@@ -0,0 +1,26 @@
+<?php
+
+function get_yt_data($id){
+ $data = file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$id."");
+ $data = preg_replace("/yt:statistics/", "ytstatistics", $data);
+ $data = preg_replace("/media:group/", "mediagroup", $data);
+ $data = preg_replace("/media:description/", "mediadescription", $data);
+ $data = preg_replace("/gd:rating/", "gdrating", $data);
+ $xmldata = simplexml_load_string($data);
+
+ $title = $xmldata->title[0];
+ $viewCount = $xmldata->ytstatistics["viewCount"];
+ $author = $xmldata->author->name[0];
+ $desc = $xmldata->mediagroup->mediadescription[0];
+ $date = $xmldata->published[0];
+ $rate = $xmldata->gdrating["average"];
+
+ $res["title"] = $title;
+ $res["viewCount"] = $viewCount;
+ $res["author"] = $author;
+ $res["desc"] = $desc;
+ $res["date"] = $date;
+ $res["rate"] = $rate;
+
+ return $res;
+}