Upload:
REQUIRED Registered Users - You can find your $user_token in profile page.
1. Get an Upload URL:
GET Request
https://netu.tv/plugins/cb_multiserver/api/get_upload_server.php?user_hash=".$user_token
Example
GET https://netu.tv/plugins/cb_multiserver/api/get_upload_server.php
Parameters | Values |
---|---|
user_hash * | $user_token from account, example: 465rfdgyt5t6343gret525t4ret53462 |
Example Response
{ "successful": true, "upload_server": "https://cX.netu.tv/flv/api/actions/file_uploader.php", "hash": "abcdefhg", "time_hash": "1234567890", "userid":99, "key_hash":"abcde", "upload_server_remote":"https://cX.netu.tv/flv/api/actions/file_downloader_sh.php" }
2.Send file to upload server:
POST Request with params, that you was get in last request (hash,time_hash,key_hash,userid)
https://cX.netu.tv/flv/api/actions/file_uploader.php
Example
POST https://cX.netu.tv/flv/api/actions/file_uploader.php
Parameters | Values |
---|---|
hash * | hash from response at prev step |
time_hash * | time_hash from response at prev step |
userid * | userid from response at prev step |
key_hash * | key_hash from response at prev step |
userid * | userid from response at prev step |
Filedata * | file |
upload * | 1 |
Example Response
{ "success": "yes", "file_name "1599579343u2qmi" }
3.Send filename to general server:
POST Request with params, that you was get in last request (insertVideo, title, server, user_hash and other from last responce)
https://netu.tv/actions/file_uploader.php
Example
POST https://netu.tv/actions/file_uploader.php
Parameters | Values |
---|---|
insertVideo * | 1 |
title * | title of video |
server * | server from response at first step |
user_hash * | $user_token from account, example: 465rfdgyt5t6343gret525t4ret53462 |
file_name * | file_name from response at prev step |
Example Response
{ "successful":true, "vid":"27290784", "videokey":"FA00eG0veHL9", "video_link":"https:\/\/waaw.to\/f\/FA00eG0veHL9", "embed_code": "<div id=\"07b02207602203345678654356776543456765432807704707607702207d\" style=\"height:450px;width:720px\"></div>\r\n<script src=\"data:text/javascript;base64,dmFyIHBhID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnc2NyaXB0Jyk7IAp2YXIgcyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCdzY3JpcHQnKVswXTsgCiAgICBwYS5zcmMgPSAnaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL2xvYWRlcm1haW4uYXBwc3BvdC5jb20vbWFpbi5qcyc7CiAgICBzLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHBhLCBzKTs=\"></script>", "embed_code_non_secured": "<iframe src=\"https://baiduccdn.com/player/embed_player.php?vid=grgdrtgd345f&autoplay=no\" height=\"450\" width=\"720\" webkitAllowFullScreen mozallowfullscreen allowfullscreen frameborder=\"0\" scrolling=\"no\"></iframe>"}
Example of php script, to upload files:
<?php
////////////////////////////////////////////////////////
// API version 1.2 (ssl)
//
// for php 5.6+ you need to make some changes in code
// method 1
// add the following line
// curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0);
//
// method 2
// change
// $post_fields['Filedata'] = "@".$file;
// to
// $post_fields['Filedata'] = CURLFile($file);
////////////////////////////////////////////////////////
//REQUIRED Registered Users - You can find your user token in profile page.
$user_token = "$user_token";
//$file = "/var/www/video.mp4";
$file = $argv[1];
function removeBOM($str="") {
if(substr($str, 0, 3) == pack('CCC', 0xef, 0xbb, 0xbf)) {
$str = substr($str, 3);
}
return $str;
}
$ctx = stream_context_create(array(
function curl($url="",$post_fields=array()){
'ssl'=>array(
'verify_peer'=>false,
'verify_peer_name'=>false,
),
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result=curl_exec ($ch);
$code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
return(array("result" => json_decode(removeBOM($result), true), "code" => $code));
}
if(!file_exists("$file"))
die("ERROR: Can't find '$file'!\n");
$path_parts = pathinfo($file);
$ext = $path_parts['extension'];
$title = $path_parts['basename'];
$allowed = array("flv", "avi", "rmvb", "mkv", "mp4", "wmv", "mpeg", "mpg", "mov","divx","3gp","xvid","asf","rm","dat","m4v","f4v","webm","ogv");
if (!in_array(strtolower($ext),$allowed))
die("ERROR: Video format not permitted. Formats allowed: wmv,avi,divx,3gp,mov,mpeg,mpg,xvid,flv,asf,rm,dat,mp4,mkv,m4v,f4v,webm,ogv!\n");
$con = file_get_contents("http://netu.tv/plugins/cb_multiserver/api/get_upload_server.php?user_hash=".$user_token, false, $ctx);
$converter = json_decode(removeBOM($con), true);
echo "server to upload: ".var_dump(
$converter
);
if(isset($
converter
['error']))
die("ERROR: Could not choose converter. Aborting. Error:(".$converter['error'].") \n");
if (function_exists('curl_file_create')) { // php 5.5+
$post_fields['Filedata'] = curl_file_create($file);
} else {
$post_fields['Filedata'] = "@".$file;
}
$post_fields['upload'] = "1";
foreach ($converter as $key => &$value) {
$post_fields[$key] = $value;
}
echo "upload video to server: ".
$converter['upload_server']
;
$result = curl($converter['upload_server'],$post_fields);
if($result['code'] == 200){
if(!empty($result['result']['success']))
{
$post_fields = array();
$post_fields['insertVideo'] = "yes";
$post_fields['title'] = $title;
$post_fields['server'] = $converter['upload_server'];
$post_fields['user_hash'] = $user_token;
foreach ($result['result'] as $key => &$value) {
$post_fields[$key] = $value;
}
$result_insert = curl("http://netu.tv/actions/file_uploader.php",$post_fields);
if($result_insert['code'] == 200){
if(
!empty($result_insert['result']
['video_link'])){
//SUCCESS UPLOADED
var_dump($result_insert['result']);
}else{
//error handler
var_dump($result_insert['result']);
}
}else{
//error hanler
echo $result_insert['result'];
}
}else{
//error handler
var_dump($result);
}
}else{
//error handler
if($result['code'] == 413)
echo "Error. Too big file.";
var_dump($result);
}
?>
Check video status:
REQUIRED Registered Users - You can find your $user_token in profile page.
$vid - video key of file it is may be: "ghfkdsj46dgf" or "2485624654546541561561654684786465165141648"
GET Request (params: checkVideo=1; user_hash (your user_token), vid (videokey))
Example of php script, to check video files:
REQUIRED Registered Users - You can find your $user_token in profile page.
$vid - video key of file it is may be: "ghfkdsj46dgf" or "2485624654546541561561654684786465165141648"
GET Request (params: checkVideo=1; user_hash (your user_token), vid (videokey))
https://netu.tv/actions/file_uploader.php?checkVideo=1&user_hash=".$user_token."&vid=".$vid
API - Check video status
POST https://netu.tv/actions/file_uploader.php
Parameters | Values |
---|---|
checkVideo * | 1 |
user_hash * | $user_token from account, example: 465rfdgyt5t6343gret525t4ret53462 |
vid * | Video key, example: drgdrtgd345f |
Example Response
{ "successful": true, "vid": "drgdrtgd345f", "status": "enabled", "player_type": "public" }
Example of php script, to check video files:
<?php
$user_token = "$user_token";
$vid = "videokey";
$ctx = stream_context_create(array(
'ssl'=>array(
'verify_peer'=>false,
'verify_peer_name'=>false,
),
));
$url = "
https://netu.tv/actions/file_uploader.php?checkVideo=1&user_hash=".$user_token."&vid=".$vid
;
$video = json_decode(file_get_contents(
$url
,false
, $ctx
), true);
var_dump($video);
?>
Copy video:
REQUIRED Registered Users - You can find your $user_token in profile page.
$vid - video key of file it is may be: "ghfkdsj46dgf" or "2485624654546541561561654684786465165141648"
GET Request (params: vidCopy=1 (standart); delOrig=1 (1 for delete original file, 0 to leave); user_hash (your user_token), vid (videokey))
REQUIRED Registered Users - You can find your $user_token in profile page.
$vid - video key of file it is may be: "ghfkdsj46dgf" or "2485624654546541561561654684786465165141648"
GET Request (params: vidCopy=1 (standart); delOrig=1 (1 for delete original file, 0 to leave); user_hash (your user_token), vid (videokey))
https://netu.tv/actions/file_uploader.php?vidCopy=1&delOrig=1&user_hash=".$user_token."&vid=".$vid
API - Copy video
GET https://netu.tv/actions/file_uploader.php
Parameters | Values |
---|---|
vidCopy * | 1 |
delOrig * | delete original video: 1 or dont delete original video: 0 |
user_hash * | $user_token from account, example: 465rfdgyt5t6343gret525t4ret53462 |
vid * | Video key, example: t4FRhhd35dh5 |
Example Response
{ "successful": true, "vid": "grgdrtgd345f", "title": "My cool video", "video_link": "https://hqq.tv/watch_video.php?v=grgdrtgd345f", "embed_code": "<div id=\"07b02207602203345678654356776543456765432807704707607702207d\" style=\"height:450px;width:720px\"></div>\r\n<script src=\"data:text/javascript;base64,dmFyIHBhID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnc2NyaXB0Jyk7IAp2YXIgcyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCdzY3JpcHQnKVswXTsgCiAgICBwYS5zcmMgPSAnaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL2xvYWRlcm1haW4uYXBwc3BvdC5jb20vbWFpbi5qcyc7CiAgICBzLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHBhLCBzKTs=\"></script>", "embed_code_non_secured": "<iframe src=\"https://baiduccdn.com/player/embed_player.php?vid=grgdrtgd345f&autoplay=no\" height=\"450\" width=\"720\" webkitAllowFullScreen mozallowfullscreen allowfullscreen frameborder=\"0\" scrolling=\"no\"></iframe>" }