-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy paththinkidownloader3.php
More file actions
67 lines (61 loc) · 2.48 KB
/
thinkidownloader3.php
File metadata and controls
67 lines (61 loc) · 2.48 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
<?php
set_time_limit(0);
require("config.php");
$pwd = '';
$root_project_dir = '';
$revision = "Revision 6.5 ~ 24/11/2025";
error_reporting(0); //Disabled for keeping console clean. Set to 1 if you got an error or problem while downloading :)
echo "THINKIFIC DOWNLOADER".PHP_EOL.$revision.PHP_EOL."Author : SumeetWeb ~ https://github.com/sumeetweb".PHP_EOL."Consider buying me a coffee at : https://www.ko-fi.com/sumeet".PHP_EOL."Want to download only selected videos? Thinki-Parser is available! : https://sumeetweb.github.io/Thinki-Parser/".PHP_EOL;
echo "----------------------------------------------------------".PHP_EOL;
require("include/file.functions.php");
require("include/downloader.functions.php");
require("include/wistia.downloader.php");
// Run.
// If --json or COURSE_DATA_FILE in env, then read from json file.
// Else, download from url or use COURSE_URL from env.
if( (in_array("--json", $argv) && isset($argv[2])) || !in_array(getenv("COURSE_DATA_FILE"), ["", null, false]) ) {
// --json is higher priority than env.
if (in_array("--json", $argv)) {
echo "Using Custom Metadata File for course data.".PHP_EOL;
if (!file_exists($argv[2])) {
die("File not found: ".$argv[2].PHP_EOL);
}
$json = file_get_contents($argv[2]);
} else {
echo "Loading Custom Metadata File from .env for course data.".PHP_EOL;
$courseDataFile = getenv("COURSE_DATA_FILE");
if (!file_exists($courseDataFile)) {
die("File not found: ".$courseDataFile.PHP_EOL);
}
$json = file_get_contents($courseDataFile);
}
$data = json_decode($json, true);
$contentsdata = $data["contents"];
init_course($data);
} else if(isset($argv[1])) {
// Use course url from command line. It is higher priority than env.
$courseUrl = $argv[1];
handler($courseUrl);
} else if(!in_array(getenv("COURSE_LINK"), ["", null, false])) {
$courseUrl = getenv("COURSE_LINK");
handler($courseUrl);
} else {
echo "Usage for using course url: php thinkidownloader3.php <course_url>".PHP_EOL;
echo "Usage for selective download: php thinkidownloader3.php --json <course.json>".PHP_EOL;
}
function handler($courseUrl) {
global $contentsdata, $p;
$url = query($courseUrl);
$p = parse_url($courseUrl);
$path = $p;
$path = explode("/", $path["path"]);
file_put_contents(end($path).".json",$url); //save coursename.json
$data = json_decode($url,true);
$contentsdata = $data["contents"];
if(isset($data["error"]))
die($data["error"].PHP_EOL);
else
echo "Fetching Course Contents... Please Wait...".PHP_EOL;
init_course($data);
}
?>