From e3e416c52640476b6e7d1646781fd48dffcaddee Mon Sep 17 00:00:00 2001 From: David Parunakian Date: Thu, 8 Aug 2013 20:18:54 +0400 Subject: [PATCH 1/2] Added Khan Academy support (videos downloaded from YouTube) --- src/you_get/downloader/__init__.py | 1 + src/you_get/downloader/__main__.py | 1 + src/you_get/downloader/khan.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100755 src/you_get/downloader/khan.py diff --git a/src/you_get/downloader/__init__.py b/src/you_get/downloader/__init__.py index 7a4e315d..adaafdf0 100644 --- a/src/you_get/downloader/__init__.py +++ b/src/you_get/downloader/__init__.py @@ -38,5 +38,6 @@ from .xiami import * from .yinyuetai import * from .youku import * from .youtube import * +from .khan import * from .__main__ import * diff --git a/src/you_get/downloader/__main__.py b/src/you_get/downloader/__main__.py index 4ce9cbe5..1fc96e79 100644 --- a/src/you_get/downloader/__main__.py +++ b/src/you_get/downloader/__main__.py @@ -59,6 +59,7 @@ def url_to_module(url): 'youku': youku, 'youtu': youtube, 'youtube': youtube, + 'khanacademy': khan, #TODO } if k in downloads: diff --git a/src/you_get/downloader/khan.py b/src/you_get/downloader/khan.py new file mode 100755 index 00000000..9c4bb40d --- /dev/null +++ b/src/you_get/downloader/khan.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +__all__ = ['khan_download'] + +from ..common import * +from .youtube import youtube_download_by_id + +def khan_download(url, output_dir = '.', merge = True, info_only = False): + page = get_html(url) + id = page[page.find('src="https://www.youtube.com/embed/') + len('src="https://www.youtube.com/embed/') :page.find('?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=0')] + youtube_download_by_id(id) + +site_info = "khanacademy.org" +download = khan_download +download_playlist = playlist_not_supported('khan') From 89caa854f4d976ba5af6875ab0bc1f74db6555e8 Mon Sep 17 00:00:00 2001 From: David Parunakian Date: Thu, 8 Aug 2013 21:51:52 +0400 Subject: [PATCH 2/2] Fixed a bug: no parameters were getting passed to the youtube_download_by_id() function --- src/you_get/downloader/khan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/downloader/khan.py b/src/you_get/downloader/khan.py index 9c4bb40d..617eec47 100755 --- a/src/you_get/downloader/khan.py +++ b/src/you_get/downloader/khan.py @@ -8,7 +8,7 @@ from .youtube import youtube_download_by_id def khan_download(url, output_dir = '.', merge = True, info_only = False): page = get_html(url) id = page[page.find('src="https://www.youtube.com/embed/') + len('src="https://www.youtube.com/embed/') :page.find('?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=0')] - youtube_download_by_id(id) + youtube_download_by_id(id, output_dir=output_dir, merge=merge, info_only=info_only) site_info = "khanacademy.org" download = khan_download