From 18ffdcfd88c92004ab7a9b025f3c219670e585d5 Mon Sep 17 00:00:00 2001 From: sumeetweb <25149022+sumeetweb@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:17:07 +0530 Subject: [PATCH] Refactor .env file usage in script --- README.md | 38 ++++++++++++++++++++++++++++---------- config.php | 36 +++++++++++++++++++++++++++++++++++- thinkidownloader3.php | 40 +++++++++++++++++++++++++++++++--------- 3 files changed, 94 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index dc1ec3c..0d424bc 100644 --- a/README.md +++ b/README.md @@ -99,20 +99,37 @@ docker-compose -f compose.selective.yaml up #### Using the PHP script direcly on host machine -For Direct Method, remember to edit the config.php file and modify : +For Direct Method, remember to edit the .env file and modify : -```php -$clientdate = "PASTE CLIENT DATE HERE"; -$cookiedata = "PASTE COOKIE DATA HERE"; -// Set the video download quality. Default is 720p. -// Available Options: "Original File", "1080p", "720p", "540p", "360p", "224p" -$video_download_quality = "720p"; +```bash +COURSE_LINK="" -// Set the following flag to true if you want to merge audio and video files of presentations -$FFMPEG_PRESENTATION_MERGE_FLAG = true; +# If using selective download, add the following line and add the path of course data file downloaded from Thinki-Parser +COURSE_DATA_FILE="" + +# Watch YouTube video to know how to get the client date and cookie data +CLIENT_DATE="" +COOKIE_DATA="" + +# Set the video download quality. Default is 720p. +# Available Options: "Original File", "1080p", "720p", "540p", "360p", "224p" +VIDEO_DOWNLOAD_QUALITY="720p" ``` -Now simply run: + +NOTE: Priority of COURSE_DATA_FILE is higher than COURSE_LINK. If COURSE_DATA_FILE is set, COURSE_LINK will be ignored. +Arguments passed to script in terminal override the values in .env file. + +The priority order is (Highest to Lowest): +1. COURSE_DATA_FILE (if set) Terminal > .env +2. COURSE_LINK (if set) Terminal > .env + +Now simply run: +```bash +php thinkidownloader3.php +``` + +You can override the course link or course data file by providing it as an argument: ```bash php thinkidownloader3.php LINK_HERE @@ -125,6 +142,7 @@ php thinkidownloader3.php --json COURSE_DATA_FILE_PATH ``` + > [!CAUTION] > This script only downloads enrolled courses from thinkific based website. Owner of this repository is not responsible for any misuse if you share your credentials with strangers. diff --git a/config.php b/config.php index 2d261d3..ac8420b 100644 --- a/config.php +++ b/config.php @@ -1,9 +1,12 @@ ".PHP_EOL; + echo "Usage for selective download: php thinkidownloader3.php --json ".PHP_EOL; +} + +function handler($courseUrl) { + $url = query($courseUrl); + $p = parse_url($courseUrl); $path = $p; $path = explode("/", $path["path"]); file_put_contents(end($path).".json",$url); //save coursename.json @@ -33,8 +58,5 @@ else echo "Fetching Course Contents... Please Wait...".PHP_EOL; init_course($data); -} else { - echo "Usage for using course url: php thinkidownloader3.php ".PHP_EOL; - echo "Usage for selective download: php thinkidownloader3.php --json ".PHP_EOL; } ?>