Skip to content

Commit

Permalink
Merge pull request #66 from sumeetweb/fix-wistia-27-nov
Browse files Browse the repository at this point in the history
Fixed wistia downloads for HtmlItem and Quiz
  • Loading branch information
sumeetweb authored Nov 27, 2024
2 parents b4c1554 + 88f7748 commit 1c1a3bc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 44 deletions.
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]

## How do
## How To Use:

### Prepare your environment

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
58 changes: 29 additions & 29 deletions include/downloader.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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 = '/<iframe.*?src="(https:\/\/platform.thinkific.com\/videoproxy\/v1\/play\/[a-zA-Z0-9]+)".*?<\/iframe>/';
// 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);
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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"] . ") " . "<strong>" . unicode_decode($qs["prompt"]) . "</strong>" . "Explanation: " . unicode_decode($qs["text_explanation"]) . "<br><br>";

$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"] . ") " . "<strong>" . unicode_decode($qs["prompt"]) . "</strong>" . "<br><br>";
foreach ($result["choices"] as $ch) {
if ($ch["question_id"] == $qs["id"]) {
Expand Down
2 changes: 1 addition & 1 deletion thinkidownloader3.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1c1a3bc

Please sign in to comment.