diff --git a/README.md b/README.md index ed80c8d..dc1ec3c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you want to support the project, consider [buying me some coffee](https://ko- If you are a course maintainer and want to migrate from Thinkific, ping me at hello@sumeetnaik.com -## How do +## How To Use: ### Prepare your environment @@ -69,7 +69,7 @@ ffmpeg are already included in the Docker image. ### Preparing selective download -If you'd like to make a selective download, please checkout [Thinki-Parser v0.0.1 Experimental Support](https://sumeetweb.github.io/Thinki-Parser/) and generate course data file. +If you'd like to make a selective download, checkout [Thinki-Parser v0.0.1 Experimental Support](https://sumeetweb.github.io/Thinki-Parser/) and generate course data file. Then pass --json flag and file path of course data file. There's a example for each solution below. @@ -194,18 +194,8 @@ If you like this work, consider [buying me a coffee](https://ko-fi.com/sumeet)! ### Changelog -#### ***Revision 6.3.2 ~ 16th December 2023*** - -!NEW! [Thinki-Parser v0.0.1 Experimental Support Added](https://sumeetweb.github.io/Thinki-Parser/) -!FIX! "wistia" and "videoproxy" Lesson Downloads Fixed! -!HOT! Quality Selection for Video Downloads! -!HOT! Presentation Downloads with FFMPEG support to merge audio and video files! -!NEW! FFMPEG Support in Docker Image! - -#### ***Revision 6.3.4*** - -!FIX! Fix issues with File Names and Downloads +#### ***Revision 6.4 ~ 27th November 2024*** +!FIX! "wistia" and "videoproxy" Lesson Downloads Fixed for HtmlItem and Quiz Content Types! #### ***Revision 6.3.5*** - !NEW! Added support for mp3 in courses diff --git a/include/downloader.functions.php b/include/downloader.functions.php index d2d30eb..19890c5 100644 --- a/include/downloader.functions.php +++ b/include/downloader.functions.php @@ -75,7 +75,7 @@ function chapterwise_download($datas) if (!empty($video_set_matches)) { foreach ($video_set_matches as $match) { $video_url = $match[0]; - video_downloader_videoproxy($video_url, $content["name"], $video_download_quality); + video_downloader_videoproxy($video_url, filter_filename($content["name"]), $video_download_quality); } } @@ -88,15 +88,21 @@ function chapterwise_download($datas) } } - # Query the API for the video URL + # Find a string similar to https://fast.wistia.net/embed/iframe/* + $regex = '/https:\/\/fast.wistia.net\/embed\/iframe\/[a-zA-Z0-9]+/'; + preg_match_all($regex, $temp2, $matches, PREG_SET_ORDER, 0); + $first_set_matches = array_unique($matches, SORT_REGULAR); + + if(!empty($first_set_matches)) { + foreach($first_set_matches as $match) { + $embed_video_url = $match[0]; - # Find a string similar to https://fast.wistia.com/embed/medias/*.jsonp + $wistia_id = explode("/", $embed_video_url); + $wistia_id = end($wistia_id); + video_downloader_wistia($wistia_id, $fname, $video_download_quality); + } + } - // # FInd all iframe src links which contain https://platform.thinkific.com/videoproxy/v1/play/* - // $regex = '//'; - // preg_match_all($regex, $temp2, $matches, PREG_SET_ORDER, 0); - // $matches = array_unique($matches, SORT_REGULAR); - // print_r($matches); $fname = str_replace(" ","-",$fname); $myfile = fopen($fname, "w"); fwrite($myfile, $temp2); @@ -149,27 +155,6 @@ function chapterwise_download($datas) mkdir($dc, 0777); $prev_dir = getcwd(); chdir($dc); - /* - $result = query("https://".$p['host']."/api/course_player/v2/lessons/".$content['contentable']); - echo $result; - $temp = json_decode($result,true); - if($temp["lesson"]["downloadable"]) - { - $temp2 = $temp["videos"][0]["url"]; //Store Video URL to temp - $parts = parse_url($temp2); - $fileName = basename($parts["path"]); - $fileName = filter_filename($fileName); - echo "Downloading Video : ".$fileName.PHP_EOL; - - // Download the video inside a folder $content["name"] - //$downloadedFileContents = file_get_contents($temp2); - //file_put_contents($fileName, $downloadedFileContents); - $downloadedFileContents = downloadFileChunked($temp2, $fileName); - chdir($prev_dir); - } - else - { - */ $vname = filter_filename($content['name']); echo "Downloading Video : " . $vname . PHP_EOL; $sendurl = "https://" . $p['host'] . "/api/course_player/v2/lessons/" . $content['contentable']; @@ -230,6 +215,21 @@ function chapterwise_download($datas) foreach ($result["questions"] as $qs) { $choice = 'A'; $file_contents_with_answers = $file_contents_with_answers . ++$qs["position"] . ") " . "" . unicode_decode($qs["prompt"]) . "" . "Explanation: " . unicode_decode($qs["text_explanation"]) . "

"; + + $decoded_prompt = unicode_decode($qs["prompt"]); + + $pattern = '/fast.wistia.net\/embed\/iframe\/[a-zA-Z0-9]+/'; + preg_match_all($pattern, $decoded_prompt, $matches, PREG_SET_ORDER, 0); + $first_set_matches = array_unique($matches, SORT_REGULAR); + if(!empty($first_set_matches)) { + foreach($first_set_matches as $match) { + $embed_video_url = $match[0]; + $wistia_id = explode("/", $embed_video_url); + $wistia_id = end($wistia_id); + video_downloader_wistia($wistia_id, "QA Video ".$qs["position"], $video_download_quality); + } + } + $file_contents_with_questions = $file_contents_with_questions . $qs["position"] . ") " . "" . unicode_decode($qs["prompt"]) . "" . "

"; foreach ($result["choices"] as $ch) { if ($ch["question_id"] == $qs["id"]) { diff --git a/thinkidownloader3.php b/thinkidownloader3.php index b212017..20fbb25 100644 --- a/thinkidownloader3.php +++ b/thinkidownloader3.php @@ -3,7 +3,7 @@ require("config.php"); $pwd = ''; $root_project_dir = ''; -$revision = "Revision 6.3.4 ~ 1st May 2024"; +$revision = "Revision 6.4 ~ 27th November 2024"; 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;