From 80e7827ab5c31ee9378213d90da8fce5eb1c499d Mon Sep 17 00:00:00 2001 From: r0oth3x49 Date: Sat, 30 Dec 2017 12:41:16 +0500 Subject: [PATCH] Added shields.io, added proper error message for #63, updated readme file --- README.md | 33 +++++++++++++++++++-------------- udemy/_extractor.py | 10 ++++++---- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7334bfd..60bdbbf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +[![GitHub release](https://img.shields.io/badge/release-v0.3-brightgreen.svg?style=flat-square)](https://github.com/r0oth3x49/udemy-dl/tree/e85feca476755944758149a8fc81ae8a02f15c2c) +[![GitHub stars](https://img.shields.io/github/stars/r0oth3x49/udemy-dl.svg?style=flat-square)](https://github.com/r0oth3x49/udemy-dl/stargazers) +[![GitHub forks](https://img.shields.io/github/forks/r0oth3x49/udemy-dl.svg?style=flat-square)](https://github.com/r0oth3x49/udemy-dl/network) +[![GitHub issues](https://img.shields.io/github/issues/r0oth3x49/udemy-dl.svg?style=flat-square)](https://github.com/r0oth3x49/udemy-dl/issues) + # udemy-dl **A cross-platform python based utility to download courses from udemy for personal offline use.** @@ -65,55 +70,55 @@ You can download the latest version of udemy-dl by cloning the GitHub repository ***Downloading course*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL ***Downloading Course with specific resolution*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -r 720 + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -r 720 ***Downloading course to a specific location*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -o "/path/to/directory/" + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -o "/path/to/directory/" ***Downloading course with specific resolution to a specific location*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -r 720 -o "/path/to/directory/" + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -r 720 -o "/path/to/directory/" ***Saving download links*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -s + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -s ***Saving specific resolution download links*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -s -r 720 + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -s -r 720 ***Saving download links to specific location*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -s -o "/path/to/directory/" + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -s -o "/path/to/directory/" ***Saving specific resolution download links to specific location*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -s -r 720 -o "/path/to/directory/" + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -s -r 720 -o "/path/to/directory/" ***Downloading course and caching credentials*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME --configs + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL --configs ***Downloading with specific resolution and allow default resolution as well*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -r 1080 -d + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -r 1080 -d ***Downloading course but skip captions/subtitles*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME --skip-sub + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL --skip-sub ***Downloading captions/subtitles only*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME --sub-only + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL --sub-only ***Listing course's video informtion*** - python udemy-dl.py -u user@domain.com -p p4ssw0rd https://www.udemy.com/COURSE_NAME -l + python udemy-dl.py -u user@domain.com -p p4ssw0rd COURSE_URL -l the above command will list down the size of video and attached files and available resolutions for a video in a course. ### Advanced Usage @@ -149,7 +154,7 @@ Options: --skip-sub Download course but skip captions/subtitle. Example: - python udemy-dl.py https://www.udemy.com/course_name/ + python udemy-dl.py COURSE_URL diff --git a/udemy/_extractor.py b/udemy/_extractor.py index 7bc0648..3abf7ff 100644 --- a/udemy/_extractor.py +++ b/udemy/_extractor.py @@ -162,9 +162,10 @@ def login(self, username, password): sys.exit(0) - def logout(self): + def logout(self, flag=True): sys.stdout.write('\n') - sys.stdout.write(fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fg + sd + "Downloaded course information webpages successfully..\n") + if flag: + sys.stdout.write(fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fg + sd + "Downloaded course information webpages successfully..\n") sys.stdout.write(fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fg + sb + "Trying to logout now...\n") try: session.get(logout_url) @@ -223,8 +224,9 @@ def real_extract(self, url, course_name, course_path): response = session.get(_course_url).json() _isenrolled = response.get('detail') if _isenrolled: - sys.stdout.write(fc + sd + "[" + fr + sb + "-" + fc + sd + "] : " + fr + sb + "You are not enrolled in this course Udemy Says : {}.".format(_isenrolled)) - self.logout() + sys.stdout.write(fc + sd + "[" + fr + sb + "-" + fc + sd + "] : " + fr + sb + "Udemy Says : {} either you are not enrolled in course or server didn't respond with course information webpages.\n".format(_isenrolled)) + sys.stdout.write(fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fw + sb + "Re-run udemy-dl against full course url (e.g :- https://www.udemy.com/course/learn/v4/overview)") + self.logout(flag=False) exit(0) num_lect = int(self._lecture_count(response)) sys.stdout.write(fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fg + sd + "Found (%s) lectures ...\n" % (num_lect))