├── example
├── readme.md
├── upload.php
└── page.html
├── README.md
└── doodstream.php
/example/readme.md:
--------------------------------------------------------------------------------
1 | # Example of uploading file using the API library
2 | ###### page.html and upload.php are the example of an successful `Upload()` API.
3 |
--------------------------------------------------------------------------------
/example/upload.php:
--------------------------------------------------------------------------------
1 | Setup($key);
13 | $result = $ds->Upload($tempfile, $type, $name);
14 | print_r($result);
15 | }
16 | else{
17 | die('No file uploaded');
18 | }
19 |
20 |
21 | ?>
22 |
--------------------------------------------------------------------------------
/example/page.html:
--------------------------------------------------------------------------------
1 |
2 |
Test Upload Template Doodstream API
3 |
4 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # doodstream-PHP-library
2 | Unofficial PHP API library for Doodstream.com
3 | Minimum PHP version : 5.5
4 |
5 |
6 | ## Initializing
7 | *doodstream.php* needs to be included into the code and initialized using the following way:-
8 |
9 | ```php
10 | require('doodstream.php');
11 | $key = "your-key-here";
12 | $ds = new DoodstreamAPI();
13 | $ds->Setup($key);
14 | ```
15 |
16 | ## Example Usage
17 |
18 | ```php
19 | require('doodstream.php');
20 | $ds = new DoodstreamAPI();
21 | $key = "your-key-here";
22 | $ds->Setup($key);
23 | $uploads = $ds->List("1", "100"); //Lists the first page of the recent uploads(100 per page as defined)
24 | print_r($uploads);
25 | ```
26 | Example of uploading a file using API can be found inside `example folder`
27 |
28 |
29 | ## Functions
30 |
31 | Following are the functions supported by the library
32 | ###### Account
33 | Get's account Information
34 | ```php
35 | $ds->AccountInfo(); // No parameters required
36 | ```
37 | Get's report of your account (default last 7 days)
38 | ```php
39 | $ds->AccountReport($last); // Optional Parameter:- last - Get repost of last x days
40 | ```
41 | Get's DMCA reported files list (500 results per page)
42 | ```php
43 | $ds->DMCAList(); // No parameters required
44 | ```
45 |
46 | ###### Upload
47 | Upload Local File to DoodSteam
48 | ```php
49 | $ds->Upload($tempfile, $type, $name); // Parameters(Required):-1) tempfile - Location of the file's temporary location on the server, called using $_FILES['video']['tmp_name']
50 | // 2) type - Video Extention, called using $_FILES['video']['type']
51 | // 3) name - Name you want to save the video with, needs to full name with extention for example :- Video1.mp4
52 | ```
53 | ###### Copy or Clone
54 | Copy / Clone your's or other's file
55 | ```php
56 | $ds->Copy($file_code, $fld_id(Optional)); // Parameters:- 1)(Required) file_code - File code of the video you want to copy
57 | // 2)(Optional) fld_id - Folder ID to store inside
58 | ```
59 |
60 | ###### Remote Upload
61 | Remote Upload (Add Link)
62 | ```php
63 | $ds->RUpload($url, $new_title(Optional)); // Parameters:- 1)(Required) url - URL to remote upload
64 | // 2)(Optional) new_title - Set a custom video title
65 | ```
66 | Get Remote Upload List/Queue
67 | ```php
68 | $ds->RUploadList(); // No parameters required
69 | ```
70 |
71 | Get Remote Upload File Status
72 | ```php
73 | $ds->RUploadStatus($file_code); // Parameters:- (Required) file_code - File code of the file in Remote Upload Queue
74 | ```
75 |
76 | Get total & used remote upload slots
77 | ```php
78 | $ds->RUploadSlots(); // No parameters required
79 | ```
80 |
81 | ###### Remote Upload Actions
82 |
83 | Restart Errors In Remote Upload List/Queue
84 | ```php
85 | $ds->RestartErrors(); // No parameters required
86 | ```
87 |
88 | Clear All Errors In Remote Upload List/Queue
89 | ```php
90 | $ds->ClearErrors(); // No parameters required
91 | ```
92 |
93 | Clear All Pending Files In Remote Upload List/Queue
94 | ```php
95 | $ds->ClearAll(); // No parameters required
96 | ```
97 |
98 | Remove a Specific File from Remote Upload List/Queue
99 | ```php
100 | $ds->DeleteCode($file_code); // Parameters:- (Required) file_code - File code to be removed from Remote Upload List/Queue
101 | ```
102 | ###### Manage Folders
103 |
104 | Create a folder
105 | ```php
106 | $ds->CreateFolder($name, $parent_id(Optional)); // Parameters:- 1)(Required) name - Name of the folder to be created
107 | // 2)(Optional) parent_id - Parent folder ID
108 | ```
109 |
110 | Rename a folder
111 | ```php
112 | $ds->RenameFolder($fld_id, $name); // Parameters:- 1)(Required) fld_id - Folder ID
113 | // 2)(Required) name - New name of the folder
114 | ```
115 |
116 | ###### Manage Files
117 |
118 | Get List of Videos Uploaded with info
119 | ```php
120 | $ds->List($page, $per_page, $fld_id(Optional)); // Parameters:- 1)(Required) page - Pagination , page number from which results have to shown (1 for the most recent uploads; Ascending Order followed)
121 | // 2)(Required) per_page - Max videos per page (Cannot be more than 200)
122 | // 3)(Optional) fld_id - Show videos inside a specific folder
123 | ```
124 |
125 | Check status of an uploaded file
126 | ```php
127 | $ds->FileStatus($file_code); // Parameters:- 1)(Required) file_code - File Code
128 | ```
129 |
130 | Get File Info
131 | ```php
132 | $ds->FileInfo($file_code); // Parameters:- 1)(Required) file_code - File Code
133 | ```
134 |
135 | Get file splash, single or thumbnail image
136 | ```php
137 | $ds->FileImage($file_code); // Parameters:- 1)(Required) file_code - File Code
138 | ```
139 |
140 | Rename a file
141 | ```php
142 | $ds->FileRename($file_code, $name); //Parameters:- 1)(Required) file_code - File Code
143 | // 2)(Required) name - New File Name
144 | ```
145 |
146 | Search your files
147 | ```php
148 | $ds->Search($search_term); // Parameters:- 1)(Required) search_term - Search term
149 | ```
150 |
151 |
152 | ###### Extras
153 |
154 | Remote Splash/Single Image (Functions returns embed link with added parameters)
155 | ```php
156 | $ds->CustomEmbedImage($code, $imgurl, $protected(Optional)); // Parameters:- 1)(Required) code/url - File code of the video OR insert an embed url of the video in the parameter(If using a url, make sure it includes https://, do not pass protected embed link)
157 | // 2)(Required) imgurl - URL of the image you want to set as the splash/single image
158 | // 3)(Optional) protected - Return protected embed url if set this parameter to 1, defaults to Null/Static URL if not set.
159 | ```
160 |
161 | Remote subitles (custom subtitles; Functions returns embed link with added parameters)
162 | ```php
163 | $ds->RemoteSubtitles($code, $c1_file, $c1_label); // Parameters:- 1)(Required) code/url - File code of the video OR insert an embed url of the video in the parameter(If using a url, make sure it includes https://, do not pass protected embed link)
164 | // 2)(Required) c1_file - Subtitle URL (srt or vtt)
165 | // 3)(Required) c1_label - Subtitle language or any lable
166 | ```
167 |
168 | Remote subtitle JSON (Load multiple subtitles via URL in JSON format; Functions returns embed link with added parameters)
169 | ```php
170 | $ds->RemoteJSONSubtitles($code, $subtitle_json); // Parameters:- 1)(Required) code/url - File code of the video OR insert an embed url of the video in the parameter(If using a url, make sure it includes https://, do not pass protected embed link)
171 | // 2)(Required) subtitle_json - Multiple subtitle in JSON format (Look at https://doodstream.com/api-docs#remote-subtitle-json for example)
172 | ```
173 |
--------------------------------------------------------------------------------
/doodstream.php:
--------------------------------------------------------------------------------
1 | api_key = $api_key;
12 | }
13 |
14 | /**
15 | * Get basic info of your account
16 | * @param No parameters required
17 | */
18 | public function AccountInfo() {
19 | return $this->api_call('account', 'info', array());
20 | }
21 |
22 | /**
23 | * Get report of your account (default last 7 days)
24 | * @param (Optional) last - Last x days report
25 | */
26 | public function AccountReport($last = NULL) {
27 | $req = array(
28 | 'last' => $last
29 | );
30 | return $this->api_call('account', 'stats', $req);
31 | }
32 |
33 | /**
34 | * Get DMCA reported files list (500 results per page)
35 | * @param No parameters required
36 | */
37 | public function DMCAList() {
38 | return $this->api_call('dmca', 'list', array());
39 | }
40 |
41 | /**
42 | * Upload Local File to DoodSteam
43 | * @param (Required) tempfile - Location of the file's temporary location on the server, called using $_FILES['video']['tmp_name']
44 | * @param (Required) type - Video Extention, called using $_FILES['video']['type']
45 | * @param (Required) name - Name you want to save the video with, needs to full name with extention for example :- Video1.mp4
46 | */
47 | public function Upload($tempfile, $type, $name) {
48 | $upload = $this->api_call('upload', 'server', array());
49 | $json = json_decode($upload, true);
50 | return $this->post_call($tempfile, $type, $name, $json["result"]);
51 | }
52 |
53 | /**
54 | * Copy / Clone your's or other's file
55 | * @param (Required) file_code - File code of the video you want to copy
56 | * @param (Optional) fld_id - Folder ID to store inside
57 | */
58 | public function Copy($file_code, $fld_id = NULL) {
59 | $req = array(
60 | 'file_code' => $file_code,
61 | 'fld_id' => $fld_id
62 | );
63 | return $this->api_call('file', 'clone', $req);
64 | }
65 |
66 | /**
67 | * Remote Upload an file using it's direct url (This functions adds the url to the Remote Upload queue of the account)
68 | * @param (Required) url - URL to remote upload
69 | * @param (Optional) new_title - Set a custom video title
70 | */
71 | public function RUpload($url, $new_title = NULL) {
72 | $req = array(
73 | 'url' => $url,
74 | 'new_title' => $new_title
75 | );
76 | return $this->api_call('upload', 'url', $req);
77 | }
78 |
79 | /**
80 | * Remote Upload URLs List & Status
81 | * @param No parameters required
82 | */
83 | public function RUploadList() {
84 | return $this->api_call('urlupload', 'list', array());
85 | }
86 |
87 | /**
88 | * Remote Upload File Status
89 | * @param (Required) file_code - File code of the file in Remote Upload Queue
90 | */
91 | public function RUploadStatus($file_code) {
92 | $req = array(
93 | 'file_code' => $file_code
94 | );
95 | return $this->api_call('urlupload', 'status', $req);
96 | }
97 |
98 | /**
99 | * Get total & used remote upload slots
100 | * @param No parameters required
101 | */
102 | public function RUploadSlots() {
103 | return $this->api_call('urlupload', 'slots', array());
104 | }
105 |
106 | /**
107 | * Restart Errors In Remote Upload List/Queue
108 | * @param No parameters required
109 | */
110 | public function RestartErrors() {
111 | $req = array(
112 | 'restart_errors' => '1'
113 | );
114 | return $this->api_call('urlupload', 'actions', $req);
115 | }
116 |
117 | /**
118 | * Clear All Errors In Remote Upload List/Queue
119 | * @param No parameters required
120 | */
121 | public function ClearErrors() {
122 | $req = array(
123 | 'clear_errors' => '1'
124 | );
125 | return $this->api_call('urlupload', 'actions', $req);
126 | }
127 |
128 | /**
129 | * Clear All Pending Files In Remote Upload List/Queue
130 | * @param No parameters required
131 | */
132 | public function ClearAll() {
133 | $req = array(
134 | 'clear_all' => '1'
135 | );
136 | return $this->api_call('urlupload', 'actions', $req);
137 | }
138 |
139 | /**
140 | * Remove a Specific File from Remote Upload List/Queue
141 | * @param (Required) file_code - File code to be removed from Remote Upload List/Queue
142 | */
143 | public function DeleteCode($file_code) {
144 | $req = array(
145 | 'delete_code' => $file_code
146 | );
147 | return $this->api_call('urlupload', 'actions', $req);
148 | }
149 |
150 | /**
151 | * Create a folder
152 | * @param (Required) name - Name of the folder to be created
153 | * @param (Optional) parent_id - Parent folder ID
154 | */
155 | public function CreateFolder($name, $parent_id = NULL) {
156 | $req = array(
157 | 'name' => $name,
158 | 'parent_id' => $parent_id
159 | );
160 | return $this->api_call('folder', 'create', $req);
161 | }
162 |
163 | /**
164 | * Rename a folder
165 | * @param (Required) fld_id - Folder ID
166 | * @param (Required) name - New name of the folder
167 | */
168 | public function RenameFolder($fld_id, $name) {
169 | $req = array(
170 | 'fld_id' => $fld_id,
171 | 'name' => $name
172 | );
173 | return $this->api_call('folder', 'rename', $req);
174 | }
175 |
176 |
177 |
178 | /**
179 | * Get List of Videos Uploaded with info-
180 | * @param (Required) page - Pagination , page number from which results have to shown (1 for the most recent uploads; Ascending Order followed)
181 | * @param (Required) per_page - Max videos per page (Cannot be more than 200)
182 | * @param (Optional) fld_id - Show videos inside a specific folder
183 | */
184 | public function List($page, $per_page, $fld_id = NULL) {
185 | $req = array(
186 | 'page' => $page,
187 | 'per_page' => $per_page,
188 | 'fld_id' => $fld_id
189 | );
190 | return $this->api_call('file', 'list', $req);
191 | }
192 |
193 | /**
194 | * Check status of an uploaded file
195 | * @param (Required) file_code - File Code
196 | */
197 | public function FileStatus($file_code) {
198 | $req = array(
199 | 'file_code' => $file_code
200 | );
201 | return $this->api_call('file', 'check', $req);
202 | }
203 |
204 | /**
205 | * Get File Info
206 | * @param (Required) file_code - File Code
207 | */
208 | public function FileInfo($file_code) {
209 | $req = array(
210 | 'file_code' => $file_code
211 | );
212 | return $this->api_call('file', 'info', $req);
213 | }
214 |
215 | /**
216 | * Get file splash, single or thumbnail image
217 | * @param (Required) file_code - File Code
218 | */
219 | public function FileImage($file_code) {
220 | $req = array(
221 | 'file_code' => $file_code
222 | );
223 | return $this->api_call('file', 'image', $req);
224 | }
225 |
226 | /**
227 | * Rename a File
228 | * @param (Required) file_code - File Code
229 | * @param (Required) name - New File Name
230 | */
231 | public function FileRename($file_code, $name) {
232 | $req = array(
233 | 'file_code' => $file_code,
234 | 'title' => $name
235 | );
236 | return $this->api_call('file', 'rename', $req);
237 | }
238 |
239 | /**
240 | * Search your files
241 | * @param (Required) search_term - Search term
242 | */
243 | public function Search($search_term) {
244 | $req = array(
245 | 'search_term' => $search_term
246 | );
247 | return $this->api_call('search', 'videos', $req);
248 | }
249 |
250 | /**
251 | * Use a custom image for an file's embed link, returns the full embed link
252 | * @param (Required) code/url - File code of the video OR insert an embed url of the video in the parameter(If using a url, make sure it includes https://, do not pass protected embed link)
253 | * @param (Required) imgurl - URL of the image you want to set as the splash/single image
254 | * @param (Optional) protected - Return protected embed url if set this parameter to 1, defaults to Null/Static URL if not set.
255 | */
256 | public function CustomEmbedImage($code, $imgurl, $protected = NULL) {
257 | $embed = $this->get_url($code, $protected);
258 | if($embed !== 0 && $embed !== 2){
259 | $param = "?c_poster=";
260 | $url = $embed . $param . $imgurl;
261 | $result = json_encode(array('msg' => 'OK', 'status' => 200, 'url' => $url), JSON_UNESCAPED_SLASHES);
262 | return $result;
263 | }
264 | elseif($embed == 2){
265 | return json_encode(array('error' => 'Not found or not your file'));
266 | }
267 | else{
268 | return json_encode(array('error' => 'Incorrect file code or url passed'));
269 | }
270 | }
271 |
272 | /**
273 | * Use remote subitles(custom subtitles) for a embed link
274 | * @param (Required) code/url - File code of the video OR insert an embed url of the video in the parameter(If using a url, make sure it includes https://, do not pass protected embed link)
275 | * @param (Required) c1_file - Subtitle URL (srt or vtt)
276 | * @param (Required) c1_label - Subtitle language or any lable
277 | */
278 | public function RemoteSubtitles($code, $c1_file, $c1_label) {
279 | $protected = NULL;
280 | $embed = $this->get_url($code, $protected);
281 | if($embed !== 0 && $embed !== 2){
282 | $param1 = "?c1_file=";
283 | $param2 = "&c1_label=";
284 | $url = $embed . $param1 . $c1_file . $param2 . $c1_label;
285 | $result = json_encode(array('msg' => 'OK', 'status' => 200, 'url' => $url), JSON_UNESCAPED_SLASHES);
286 | return $result;
287 | }
288 | elseif($embed == 2){
289 | return json_encode(array('error' => 'Not found or not your file'));
290 | }
291 | else{
292 | return json_encode(array('error' => 'Incorrect file code or url passed'));
293 | }
294 | }
295 |
296 | /**
297 | * Use remote JSON subitles(custom subtitles) for a embed link (Load multiple subtitles via URL in JSON format)
298 | * @param (Required) code/url - File code of the video OR insert an embed url of the video in the parameter(If using a url, make sure it includes https://, do not pass protected embed link)
299 | * @param (Required) subtitle_json - Multiple subtitle in JSON format (Look at https://doodstream.com/api-docs#remote-subtitle-json for example)
300 | */
301 | public function RemoteJSONSubtitles($code, $subtitle_json) {
302 | $protected = NULL;
303 | $embed = $this->get_url($code, $protected);
304 | if($embed !== 0 && $embed !== 2){
305 | $param = "?subtitle_json=";
306 | $url = $embed . $param . $subtitle_json;
307 | $result = json_encode(array('msg' => 'OK', 'status' => 200, 'url' => $url), JSON_UNESCAPED_SLASHES);
308 | return $result;
309 | }
310 | elseif($embed == 2){
311 | return json_encode(array('error' => 'Not found or not your file'));
312 | }
313 | else{
314 | return json_encode(array('error' => 'Incorrect file code or url passed'));
315 | }
316 | }
317 |
318 |
319 | private function is_setup() {
320 | return (!empty($this->api_key));
321 | }
322 |
323 |
324 | private function get_url($code, $protected = NULL) {
325 | if (!$this->is_setup()) {
326 | return array('error' => 'You have not called the Setup function with your api key!');
327 | }
328 |
329 | if(strlen($code) == 12){
330 | $baseurl = "https://dood.pm";
331 | $json = $this->api_call('file', 'info',$req = array('file_code' => $code));
332 | $result = json_decode($json, true);
333 | if($protected == 1){
334 | if($result["result"][0]["status"] !== "Not found or not your file"){
335 | $url = $baseurl . $result["result"][0]["protected_embed"];
336 | return $url;
337 | }
338 | else{
339 | $error = 2;
340 | return $error;
341 | }
342 | }
343 | else{
344 | if($result["result"][0]["status"] !== "Not found or not your file"){
345 | $url = $baseurl . "/e/" . $code;
346 | return $url;
347 | }
348 | else{
349 | $error = 2;
350 | return $error;
351 | }
352 | }
353 | }
354 | else{
355 | if(filter_var($code, FILTER_VALIDATE_URL)){
356 | $domains = array('www.doodstream.com', 'www.dood.la', 'www.dood.so', 'www.dood.ws', 'www.dood.pm', 'doodstream.com', 'dood.la', 'dood.so', 'dood.ws', 'dood.pm');
357 | $parse = parse_url($code);
358 | if(in_array($parse["host"], $domains)){
359 | if(strlen($parse["path"]) == 15){
360 | $file_code = substr($parse["path"], 3);
361 | if($protected == 1){
362 | $json = $this->api_call('file', 'info',$req = array('file_code' => $file_code));
363 | $result = json_decode($json, true);
364 | if($result["result"][0]["status"] !== "Not found or not your file"){
365 | $url = "https://" . $parse["host"] . $result["result"][0]["protected_embed"];
366 | return $url;
367 | }
368 | else {
369 | $error = 2;
370 | return $error;
371 | }
372 | }
373 | else{
374 | return $code;
375 | }
376 | }
377 | else{
378 | $error = 0;
379 | return $error;
380 | }
381 | }
382 | else{
383 | $error = 0;
384 | return $error;
385 | }
386 | }
387 | else{
388 | $error = 0;
389 | return $error;
390 | }
391 | }
392 | }
393 |
394 | //GET methods call
395 |
396 | private function api_call($path, $cmd, $req = array()) {
397 | if (!$this->is_setup()) {
398 | return array('error' => 'You have not called the Setup function with your api key!');
399 | }
400 |
401 | $req['key'] = $this->api_key;
402 |
403 | // Generate the query string
404 | $urldata = http_build_query($req, '', '&');
405 | $url = "https://doodapi.com/api/". $path ."/". $cmd ."?" . $urldata;
406 | // cURL request
407 | $ch = curl_init();
408 | curl_setopt($ch, CURLOPT_URL, $url);
409 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
410 |
411 | $data = curl_exec($ch);
412 | if ($data !== FALSE) {
413 | return $data;
414 | } else {
415 | return array('error' => 'cURL error: '.curl_error($ch));
416 | }
417 | $path = null;
418 | $cmd = null;
419 | $req = null;
420 | }
421 |
422 | //Post call for file uploading
423 |
424 | private function post_call($tempfile, $type, $name, $uploadurl) {
425 | if (!$this->is_setup()) {
426 | return array('error' => 'You have not called the Setup function with your api key!');
427 | }
428 |
429 | $key = $this->api_key;
430 |
431 | $ch = curl_init();
432 | curl_setopt($ch, CURLOPT_URL, $uploadurl . '?' . $key);
433 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
434 | curl_setopt($ch, CURLOPT_POST, 1);
435 |
436 | $post = array(
437 | 'api_key' => "$key",
438 | 'file' => curl_file_create($tempfile, $type, $name)
439 | );
440 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
441 |
442 | $data = curl_exec($ch);
443 | if ($data !== FALSE) {
444 | return $data;
445 | } else {
446 | return array('error' => 'cURL error: '.curl_error($ch));
447 | }
448 | }
449 | };
450 |
451 |
--------------------------------------------------------------------------------