Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix and New Features #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EdX powered courses video downloader

This script is intended to download course videos from http://education.10gen.com
This script is intended to download course videos from http://university.mongodb.com
or any other site 'Powered by EdX' (including, of course, http://edx.org itself).

This script relies on [youtube-dl](https://github.com/rg3/youtube-dl/) project
Expand All @@ -17,7 +17,7 @@ Accepts destination path as optional parameter.

### Installation

git clone https://github.com/nonsleepr/edu_10gen_dl.git
git clone https://github.com/svnindia/edu_10gen_dl.git
cd edu_10gen_dl
sudo pip install -r requirements.txt

Expand All @@ -28,5 +28,11 @@ Optionally set another options in `config.py` like `writesubtitles` to enable su
### Usage:

+ `python edx_dl.py`

+ `python edx_dl.py c:\Users\MyUser\Lectures\`
+ `python edx_dl.py --interactive c:\Users\MyUser\Lectures\`

+ `python edx_dl.py --interactive c:\Users\MyUser\Lectures\` To Download all the videos from the Course chapter

+ `python edx_dl.py --interactive --pause /home/svnindia/Downloads/tut_edx/` To Download the specipfic videos from the Course chapter, for each video Download Permission asked

+ `python edx_dl.py --interactive --resume /home/svnindia/Downloads/tut_edx/` To Download all the videos from the Course chapter from the broken download.Because of some reasons we may not able to downloaded all the videos in that case we can make use of the below
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
EMAIL = '[email protected]'
PASSWORD='password'
DOMAIN='courses.edx.org'
#DOMAIN='education.10gen.com'
#DOMAIN='courses.edx.org'
DOMAIN='university.mongodb.com'


YDL_PARAMS = \
Expand Down
41 changes: 37 additions & 4 deletions edx_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def list_courses(self):
if self._logged_in:
dashboard = self._br.open(base_url + dashboard_url)
dashboard_soup = BeautifulSoup(dashboard.read())
my_courses = dashboard_soup.findAll('article', 'my-course')
my_courses = dashboard_soup.findAll('div', 'media')
i = 0
for my_course in my_courses:
course_url = my_course.a['href']
Expand All @@ -96,7 +96,8 @@ def list_courses(self):
continue

i += 1
courseware_url = re.sub(r'\/info$','/courseware',course_url)
#from git short_path=04c6e90 courseware_url = re.sub(r'\/info$','/courseware',course_url)
courseware_url = re.sub(r'\/(info|syllabus)$','/courseware',course_url)
self.courses.append({'name':course_name, 'url':courseware_url})
print '[%02i] %s' % (i, course_name)

Expand All @@ -108,10 +109,11 @@ def list_chapters(self, course_i):
course_name = course['name']
courseware = self._br.open(base_url+course['url'])
courseware_soup = BeautifulSoup(courseware.read())
chapters = courseware_soup.findAll('div','chapter')
chapters = courseware_soup.findAll('li', 'accordion-caret')

i = 0
for chapter in chapters:
chapter_name = chapter.find('h3').find('a').text
chapter_name = chapter.find('strong').find('a').text

if self._config.interactive_mode:
launch_download_msg = 'Download the chapter [%s - %s]? (y/n) ' % (course_name, chapter_name)
Expand Down Expand Up @@ -171,6 +173,24 @@ def download(self):
sanitize_filename(chapter_name, replace_space_with_underscore),
'%02i.%02i.%02i ' % (i,j,k) + \
sanitize_filename('%s (%s)' % (par_name, video_type), replace_space_with_underscore) + '.%(ext)s')
#
#print "Debug me pause- %s" % self._config.pause_mode
#print "Debug me resume- %s" % self._config.resume_mode
if self._config.pause_mode:
launch_download_msg = 'Download this video [%s - %s]? (y/n) ' % (chapter_name, outtmpl)
launch_download = raw_input(launch_download_msg)
if (launch_download.lower() == "n"):
continue

if self._config.resume_mode:
launch_download_msg = 'Download video from this [%s - %s]? (y/n) ' % (chapter_name, outtmpl)
launch_download = raw_input(launch_download_msg)
if (launch_download.lower() == "n"):
continue
else:
self._config.resume_mode = False
#
#
self._fd.params['outtmpl'] = outtmpl
self._fd.download([video_url])
except Exception as e:
Expand All @@ -183,6 +203,19 @@ def download(self):
if config.interactive_mode:
sys.argv.remove('--interactive')

#
config.pause_mode = ('--pause' in sys.argv)

if config.pause_mode:
sys.argv.remove('--pause')

config.resume_mode = ('--resume' in sys.argv)

if config.resume_mode:
sys.argv.remove('--resume')

#

if len(sys.argv) >= 2:
DIRECTORY = sys.argv[-1].strip('"')
else:
Expand Down