From c5639ee890215e4e8e0f544821ea8d285ca58eb8 Mon Sep 17 00:00:00 2001
From: root
Date: Sat, 13 Sep 2014 22:26:58 +0200
Subject: init
---
info.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
create mode 100644 info.php
(limited to 'info.php')
diff --git a/info.php b/info.php
new file mode 100644
index 0000000..5689ef8
--- /dev/null
+++ b/info.php
@@ -0,0 +1,88 @@
+open();
+
+# check if we have a list specified by the video id
+if(!$db->listExists($vid)){
+ $video = $vid;
+ include("check.php");
+ $vid = getId($video);
+ $db->db->rPush($vid, $video);
+ if(!$vid)
+ failure("
No video information found.
", false);
+}
+
+# do we have already the video information stored?
+if($db->len($vid) > 1){
+ # yes, we have. fetch i direct from redis
+ $info = $db->getAll($vid);
+
+} else {
+ # no, we don't. get the url
+ $url = $db->getItem($vid, 0);
+
+ # and ask youtube-dl to get all information
+ $info = vid_info($url);
+ if(!$info){
+ failure("No video information found.
", false);
+ }
+
+ # now store it on redis
+ $db->storeList($vid, $info);
+
+ # fetch it from redis to get the right order (TODO)
+ $info = $db->getAll($vid);
+}
+
+# close the db connection
+$db->close();
+
+# free memory
+unset($db);
+
+# $info has the following schema
+/*
+ $url = $info[0]
+ $title = $info[1];
+ $vid = $info[2];
+ $dllink = $info[3];
+ $thumb = $info[4];
+ $filename = $info[5];
+ $duration = $info[6];
+ $format = $info[7];
+ // deprecated
+ $httpcode = $info[8];
+ $mime = $info[9];
+ $filesize =$info[10]
+*/
+
+/*
+if($info[8] >= 400)
+ failure("Failure. Foreign server responded with a invalid status code. (".$info[8].")
That is not an error on our side and there is nothing we can do.", false);
+*/
+
+$title = htmlentities($info[1]);
+$vid = htmlentities($info[2]);
+$thumb = htmlentities($info[4]);
+$duration = htmlentities($info[6]);
+$url = htmlentities($info[0]);
+
+# print the stuff
+print_info($title, $vid, $thumb, $duration, $url);
--
cgit v1.2.3