yoonwaiyan / stackskills-dl

Simple Ruby script to download all StackSkills tutorials.
https://yoonwaiyan.github.io/stackskills-dl/
MIT License
59 stars 19 forks source link

Support PDF courses #39

Closed BernierCR closed 5 years ago

BernierCR commented 5 years ago

Hey, good job on this.

However, the reason I wanted this is to download PDF based courses, not the mp4 ones. Some of these courses are really just a PDF of an E-book. I'd like that as a pdf file instead of embedded in the website.

Any way you could add this?

Thanks

yoonwaiyan commented 5 years ago

This script supports PDF files too.

If it doesn't work on your course, is there a free course that I can subscribe to it or are they all paid courses? I would like to get some output from your side. If you don't mind, please let me know the output of adding this line p lecture_page in line 135 of lib/course_finder.rb for my reference.

Thanks.

BernierCR commented 5 years ago

The free courses probably don't hide the PDF from you. I think that's what is happening. They are tricking you. The correct file doesn't end in .pdf. I replaced the secret parts of this output with [num] and [code]. That filepicker link has no extension but will point to the actual PDF file. Would you be able to make it get that file?

Finding https://stackskills.com/courses/enrolled/330327 from your list of courses Number of courses found: 1

<Mechanize::Page

{url #<URI::HTTPS https://stackskills.com/courses/330327/lectures/5062991>} {meta_refresh} {title "Implementing Azure Solutions | StackSkills"} {iframes} {frames} {links

<Mechanize::Page::Link "\n" + " \n" + " " "/courses/330327">

<Mechanize::Page::Link "\n" + " \n" + " " "#">

<Mechanize::Page::Link "" nil>

<Mechanize::Page::Link "\n" + " \n" + " " "#courseSidebar">

<Mechanize::Page::Link

"\n" + " \n" + "  \n" + " Previous Lecture\n" + " " "">

<Mechanize::Page::Link

"\n" + " Complete and continue\n" + "  \n" + " \n" + " " "">

<Mechanize::Page::Link

"\n" + " \n" + " \n" + "  \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " Implementing Azure Solutions\n" + " \n" + " \n" + " \n" + " " "/courses/implementing-azure-solutions/lectures/5062991">

<Mechanize::Page::Link

"\n" + " \n" + " [num].pdf\n" + " " "https://www.filepicker.io/api/file/[code]">} {forms}>

Downloading Course: Enrolled Downloading Implementing_Azure_Solutions Sorry, this lecture is not available to download

BernierCR commented 5 years ago

Actually, if you add something like this, it works.

pdf2 = lecture_page.link_with(href: /filepicker/) lecture.add_pdf(pdf2) if pdf2

You can make that nicer of course.

The name also comes out to a random number. So if you could rename the pdf after the lecture name instead of the random number, that would be helpful.

yoonwaiyan commented 5 years ago

Glad it worked for you :)

Regarding the file name, do you mean all pdf files in general or the pdf files from filepicker?

linux95 commented 5 years ago

yoonwaiyan, It appears that the program does not download PDF files. In some courses, you can manually download the PDF files. However, in other parts of the course, there is no download function on the PDF viewer. Would it be possible to add this functionality to the program? Thanks.

yoonwaiyan commented 5 years ago

@linux95 Do you mean that there are such cases that you seen which is similar to what's being reported by @BernierCR ? If it's not, can I have an example of your case?

linux95 commented 5 years ago

yoonwaiyan, Yes. It appears to be the same issue that @BernierCR is having. I get the same error and have to go into each course and download the PDF's individually or do a screenshot. Hope this helps.

BernierCR commented 5 years ago

Just patch your local copy the way i did.

On Wed, Nov 7, 2018, 7:49 AM linux95 <notifications@github.com wrote:

yoonwaiyan, Yes. It appears to be the same issue that @BernierCR https://github.com/BernierCR is having. I get the same error and have to go into each course and download the PDF's individually or do a screenshot. Hope this helps.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yoonwaiyan/stackskills-dl/issues/39#issuecomment-436612346, or mute the thread https://github.com/notifications/unsubscribe-auth/ADfj_Iv-lrR3sLzX2fY_VUzZM1aFJw_Cks5ustbpgaJpZM4W7PV4 .

yoonwaiyan commented 5 years ago

I tried several of my courses but failed to get any course with PDF files other than cloudfront hosted PDF files. For now if there's any edge case you can definitely make the source code work by adding custom PDF finder like what @BernierCR did. I will work on the documentation on this but will keep in view in case it's a common pattern that I could help on it.