dinosaurfiles-zz / cybrary-video-downloader

Downloads Course Videos From Cybrary.it
43 stars 24 forks source link

can't download #7

Closed RuthlessRuler closed 7 years ago

RuthlessRuler commented 7 years ago

I am using Windows 10 and python 3. i have no knowledge in coding but thought to tweak it as i was getting this error "C:\Users\Username\Downloads\cybrary-video-downloader-master>cybrary-video-downloader.py 720 "https://www.cybrary.it/course/ethical-hacking/" File "C:\Users\Username\Downloads\cybrary-video-downloader-master\cybrary-video-downloader.py", line 40 print "Downloading "+link ^ SyntaxError: Missing parentheses in call to 'print'"

so i googled and tweaked the python file :

!/usr/bin/python

import os import re import sys import getpass import requests from more_itertools import unique_everseen

Set sys encoding to UTF-8

reload(sys) sys.setdefaultencoding('utf-8')

Global Variables

session = requests.session()

Initialize Login

def login(username, password): values = { 'log': username, 'pwd': password, 'testcookie': 1, 'wp-submit': 'Log+In', 'redirect_to': '' } global session session.post('https://www.cybrary.it/wp-login.php', data=values)

Get Lessons

def getLessonList(courselink, quality): global session coursehtml = (session.get(courselink)).text

lessonLinkRegex = re.compile('https?://www.cybrary.it/video/\w+(?:-[\w]+)*/')
matchedLessonLink = list(unique_everseen(lessonLinkRegex.findall(coursehtml)))

for link in matchedLessonLink:
    print ("Downloading "+link)
    downloadVideos(getVideoLink(link), quality)

Get Video URL

def getVideoLink(lessonlink): global session lessonhtml = (session.get(lessonlink)).text

videoLinkRegex = re.compile('https?://player.vimeo.com/video/[\d]+')
return (list(unique_everseen(videoLinkRegex.findall(lessonhtml))))[0]

Download Videos using youtube-dl

def downloadVideos(videoLink, quality): command = "youtube-dl -cif http-%sp %s" % (quality, videoLink) os.system(command)

def main(): if len(sys.argv) < 3: print ("Usage: ./cybrary-video-downloader.py <270/360/720> \"\"") print ("Example: ./cybrary-video-downloader.py 360 \"https://www.cybrary.it/course/ethical-hacking/\"") else: username = raw_input("Username: ") passwd = getpass.getpass() login(username, passwd) getLessonList(sys.argv[2], sys.argv[1])

if name == 'main': main()

then i got the error: C:\Users\Username\Downloads\cybrary-video-downloader-master>cybrary-video-downloader.py 720 "https://www.cybrary.it/course/ethical-hacking/" Traceback (most recent call last): File "C:\Users\Username\Downloads\cybrary-video-downloader-master\cybrary-video-downloader.py", line 7, in import requests ImportError: No module named 'requests'.

please help me

zzenonn commented 7 years ago

The lack of a request module is probably a compatibility issue with Python 3. Use Python 2 instead of Python 3 because that's what the code was originally written in, or find out how to import the requests module to python 3. For the downloading via youtube-dl, I just changed line 63 of the original code to:

command = "youtube-dl " + videoLink

This is because the permissions issue with Vimeo and embedded urls does not allow direct viewing. This will allow you to download the video, but you won't get the video quality you specify. I think it defaults to 360.

dinosaurfiles-zz commented 7 years ago

Hi @RuthlessRuler thank you. @miguelsaavedra you're right, I've only tested the code in Python 3 on a Linux distro.

I'll try to revive the project and put up a good regex solution. Also the video res will be determined by the command-line parameter or settled to 360 if no parameters specified.

dinosaurfiles-zz commented 7 years ago

Hi @RuthlessRuler & @miguelsaavedra , I've tested the current update only in a Linux distro, feel free to re-open another issue if it doesn't work on Windows.