sumeetweb / Thinki-Downloader

A php based utility to download courses from Thinkific based sites like PacktPub for personal offline use.
MIT License
67 stars 26 forks source link

Script is silently failing #5

Closed Stuart88 closed 2 years ago

Stuart88 commented 3 years ago

Hi, I'm running this but but it doesn't seem to work. It gets to "Starting Download..." then terminates without an error message. I have also set error_reporting(1) in the code.

This is my first time running a PHP script so the issue is probably due to me not setting up PHP correctly. I followed these instructions to get it set up: https://www.sitepoint.com/how-to-install-php-on-windows#installphp

Can you think of any reason why your script would fail for me?

Thanks.

sumeetweb commented 3 years ago

php-mbstring and curl extension may not be enabled in php. First download and install curl. https://curl.se/dlwiz/?type=bin

Then, in the PHP.INI file, do this thing. Find the line: ;extension=php_mbstring.dll. Remove the ; at the beginning of the line.

Also Increase the memory limit to 2GB or 3GB. memory_limit = 2G

Stuart88 commented 3 years ago

Still not working.

Is there no way I can set the code to show an actual error message to let me know where and how it's failing?

sumeetweb commented 3 years ago

Did you configured the cookie data correctly in the code?

Silamt commented 3 years ago

Hello guys, same issue here, I tried to fix the php.ini, but nothing works. The cookie data I copy/paste is quite different from what I can see on youtube... Thanks a lot !

Stuart88 commented 3 years ago

Did you configured the cookie data correctly in the code?

I don't know what I can configure in the cookie, I just copied and pasted it.

However, I noticed a couple of potential issues.

  1. Your video shows how to do it for a courses.packthub domain, whereas I am trying it on a strozzi.thinkific domain. For the domain I'm looking at, there is no "php" result when filtering network traffic via the "api" keyword.

Instead I picked the XHR entry for _https://strozzi.thinkific.com/api/course_player/v2/courses/embodied-leadership-core_, which is most similar to the one presented in your instructional video.

  1. The cookie in the request header looks like this:

_ga=GA1.2.647690451.1619522603; __thinkific_store_subdomain__=%5B%22strozzi%22%5D; __thinkific_store_email__=XXXXXXXXXXXXX; visitor_id=XXXXXXXXXXXX; _gid=XXXXXXXXXXXXX;

The cookie appears to have the same information as your video tutorial, but the data is not in the same order.

I've tried putting all of your code in a try/catch block but still it gives the same empty result. Sorry I can't try anything more to help, my PHP knowledge is very limited.

Silamt commented 3 years ago

I think "php" is the name of the course he is trying to download in the video, it's confusing because of the php script he's using but the name of your course is probably going to be different... I'm i right ?

sumeetweb commented 3 years ago

I think "php" is the name of the course he is trying to download in the video, it's confusing because of the php script he's using but the name of your course is probably going to be different... I'm i right ?

Yes. You're correct. I was downloading PHP Course's files and it's course slug was php.

Stuart88 commented 3 years ago

Ok, so I think I've copied everything as instructed, from the correct XHR entry with the relevant course slug.

Still failing though! :(

I'm honestly surprised there's no way of outputting a useful message to say how/why it has failed?

sumeetweb commented 3 years ago

Did you configured the cookie data correctly in the code?

I don't know what I can configure in the cookie, I just copied and pasted it.

However, I noticed a couple of potential issues.

  1. Your video shows how to do it for a courses.packthub domain, whereas I am trying it on a strozzi.thinkific domain. For the domain I'm looking at, there is no "php" result when filtering network traffic via the "api" keyword.

Instead I picked the XHR entry for _https://strozzi.thinkific.com/api/course_player/v2/courses/embodied-leadership-core_, which is most similar to the one presented in your instructional video.

  1. The cookie in the request header looks like this:

_ga=GA1.2.647690451.1619522603; __thinkific_store_subdomain__=%5B%22strozzi%22%5D; __thinkific_store_email__=XXXXXXXXXXXXX; visitor_id=XXXXXXXXXXXX; _gid=XXXXXXXXXXXXX;

The cookie appears to have the same information as your video tutorial, but the data is not in the same order.

I've tried putting all of your code in a try/catch block but still it gives the same empty result. Sorry I can't try anything more to help, my PHP knowledge is very limited.

Contact me on hi@sumeet.xyz with the api url, cookie data and thinkific client date header details. I need to debug this if there's something wrong. Also, do not logout from course's site after sending data.

sumeetweb commented 3 years ago

Ok, so I think I've copied everything as instructed, from the correct XHR entry with the relevant course slug.

Still failing though! :(

I'm honestly surprised there's no way of outputting a useful message to say how/why it has failed?

Does the script generates some folder after you execute or directly ends?

Stuart88 commented 3 years ago

Ok, so I think I've copied everything as instructed, from the correct XHR entry with the relevant course slug. Still failing though! :( I'm honestly surprised there's no way of outputting a useful message to say how/why it has failed?

Does the script generates some folder after you execute or directly ends?

No folder is generated.

I've emailed the script to you now.

Stuart88 commented 3 years ago

Also I've tried running as admin and it still fails silently

Silamt commented 3 years ago

Ok, so I think I've copied everything as instructed, from the correct XHR entry with the relevant course slug. Still failing though! :( I'm honestly surprised there's no way of outputting a useful message to say how/why it has failed?

Does the script generates some folder after you execute or directly ends?

No folder is generated.

I've emailed the script to you now.

In my case the folders are generated (I finally found them), but they stay empty OC.

Stuart88 commented 3 years ago

In my case the folders are generated (I finally found them), but they stay empty OC.

Where are the folders?

I expect them to be generated in the same folder as the script file.

Silamt commented 3 years ago

In my case the folders are generated (I finally found them), but they stay empty OC.

Where are the folders?

I expect them to be generated in the same folder as the script file.

You can see them at the end of the video (on windows) with the path. In my case (macOS) its MacintoshHD/user/me

Stuart88 commented 3 years ago

In my case the folders are generated (I finally found them), but they stay empty OC.

Where are the folders? I expect them to be generated in the same folder as the script file.

You can them at the end of the video (on windows) with the path. In my case (macOS) its MacintoshHD/user/me

Thanks, didn't see that.

But still, no folders are generated

sumeetweb commented 3 years ago

In my case the folders are generated (I finally found them), but they stay empty OC.

Where are the folders? I expect them to be generated in the same folder as the script file.

You can them at the end of the video (on windows) with the path. In my case (macOS) its MacintoshHD/user/me

Thanks, didn't see that.

But still, no folders are generated

Then this means curl error basically. It requires the json api data for making folders and then download the content.

sumeetweb commented 3 years ago

Ok, so I think I've copied everything as instructed, from the correct XHR entry with the relevant course slug. Still failing though! :( I'm honestly surprised there's no way of outputting a useful message to say how/why it has failed?

Does the script generates some folder after you execute or directly ends?

No folder is generated. I've emailed the script to you now.

In my case the folders are generated (I finally found them), but they stay empty OC.

Does your course contains pdfs or any file as a downloadable content?

Silamt commented 3 years ago

Ok, so I think I've copied everything as instructed, from the correct XHR entry with the relevant course slug. Still failing though! :( I'm honestly surprised there's no way of outputting a useful message to say how/why it has failed?

Does the script generates some folder after you execute or directly ends?

No folder is generated. I've emailed the script to you now.

In my case the folders are generated (I finally found them), but they stay empty OC.

Does your course contains pdfs or any file as a downloadable content?

The courses I try to download are labeled as "text" but it may be pdfs no content are listed as downloadable on the website, I'm not sure i correctly answer your question, sorry ... (english is not my primary language)

haroldolivieri commented 3 years ago

I'm facing the same issue. The script is able to generate some folders, not for all the existing chapters but all empty.

My URL seems fine as it returns me a JSON with the whole course's information.

UPDATE

Ok, after some debugging I found the problem, looks like their server logic does some translation for the display_name field.

To fix it manually you can paste your URL into your browser to have access to the JSON response. Then you search by display_name and check the translated name for Video and Text(for me it was Vídeo and Texto).

Then you go to the script file and change it on lines 252 and 274

if($content["contentable_type"] == "HtmlItem" && $content["display_name"] == "Texto") 
if($content["contentable_type"] == "Lesson" && $content["display_name"] == "Vídeo")

Hope it works for you as well :)

Silamt commented 3 years ago

I'm facing the same issue. The script is able to generate some folders, not for all the existing chapters but all empty.

My URL seems fine as it returns me a JSON with the whole course's information.

UPDATE

Ok, after some debugging I found the problem, looks like their server logic does some translation for the display_name field.

To fix it manually you can paste your URL into your browser to have access to the JSON response. Then you search by display_name and check the translated name for Video and Text(for me it was Vídeo and Texto).

Then you go to the script file and change it on lines 252 and 274

if($content["contentable_type"] == "HtmlItem" && $content["display_name"] == "Texto") 
if($content["contentable_type"] == "Lesson" && $content["display_name"] == "Vídeo")

Hope it works for you as well :)

THE MAN WHO SAVES THE DAY !! It worked ! You just need to translate text and video to match your language. The lines in the script were different, but with the research tool .... VICTORY !

Thanks guys, you rock !

sumeetweb commented 3 years ago

I'm facing the same issue. The script is able to generate some folders, not for all the existing chapters but all empty.

My URL seems fine as it returns me a JSON with the whole course's information.

UPDATE

Ok, after some debugging I found the problem, looks like their server logic does some translation for the display_name field.

To fix it manually you can paste your URL into your browser to have access to the JSON response. Then you search by display_name and check the translated name for Video and Text(for me it was Vídeo and Texto).

Then you go to the script file and change it on lines 252 and 274

if($content["contentable_type"] == "HtmlItem" && $content["display_name"] == "Texto") 
if($content["contentable_type"] == "Lesson" && $content["display_name"] == "Vídeo")

Hope it works for you as well :)

Looks like I need to add a check for api data translations too. Thanks for helping out. 👍

momceras commented 3 years ago

tryied with this free course link https://www.dunbaracademy.com/courses/take/guide-to-getting-a-dog/texts/2503398-introduction Same problem: curl returns false

sumeetweb commented 2 years ago

It seems to be a php issue specifically if you're in windows. Don't know how but, I'm stuck in this situation too while testing codes for quiz downloads. It was working some days back. Meanwhile, Script worked smoothly in Ubuntu (Tested in Github Codespaces).

I'm done with Bindows lol.

ahaseeb728 commented 2 years ago

I just came across your script , and it is super helpful. The windows Issue you all guys addressing requires a small fix , i had the same problem too. I fixed it by editing a code a bit, go to /include folder and edit the downloader.functions.php file , You need to put this Piece of code after Line 215 and Line 240 :

curl_setopt($process, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, 0);

Save it and then run again

sumeetweb commented 2 years ago

Thanks @ahaseeb728

scqrr commented 10 months ago

I just came across your script , and it is super helpful. The windows Issue you all guys addressing requires a small fix , i had the same problem too. I fixed it by editing a code a bit, go to /include folder and edit the downloader.functions.php file , You need to put this Piece of code after Line 215 and Line 240 :

curl_setopt($process, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, 0);

Save it and then run again

Can you help with the proper way of adding the lines? Am I to add both lines or each per line? Also for line 240, is it line 240 before adding to line 215 or line 240 after adding to line 215?

Thanks for your support.