From eb0ab45ac8cd06b640faf57e7159a0feecdf5c7f Mon Sep 17 00:00:00 2001 From: David Parunakian Date: Wed, 7 Aug 2013 15:40:59 +0400 Subject: [PATCH] Added TED.com video downloader --- src/you_get/downloader/__init__.py | 1 + src/you_get/downloader/__main__.py | 3 ++- src/you_get/downloader/baidu.py | 0 src/you_get/downloader/ted.py | 24 ++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/you_get/downloader/baidu.py create mode 100644 src/you_get/downloader/ted.py diff --git a/src/you_get/downloader/__init__.py b/src/you_get/downloader/__init__.py index 7a4e315d..9be7e3d6 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 .ted import * from .__main__ import * diff --git a/src/you_get/downloader/__main__.py b/src/you_get/downloader/__main__.py index 4ce9cbe5..64d7c73b 100644 --- a/src/you_get/downloader/__main__.py +++ b/src/you_get/downloader/__main__.py @@ -14,7 +14,7 @@ def url_to_module(url): if not domain: domain = site assert domain, 'unsupported url: ' + url - + k = r1(r'([^.]+)', domain) downloads = { '163': netease, @@ -59,6 +59,7 @@ def url_to_module(url): 'youku': youku, 'youtu': youtube, 'youtube': youtube, + 'ted': ted, #TODO } if k in downloads: diff --git a/src/you_get/downloader/baidu.py b/src/you_get/downloader/baidu.py old mode 100755 new mode 100644 diff --git a/src/you_get/downloader/ted.py b/src/you_get/downloader/ted.py new file mode 100644 index 00000000..167da2a8 --- /dev/null +++ b/src/you_get/downloader/ted.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +__all__ = ['ted_download'] + +from ..common import * + +def ted_download(url, output_dir = '.', merge = True, info_only = False): + page = get_html(url).split("\n") + for line in page: + if line.find("") > -1: + title = line.replace("<title>", "").replace("", "").replace("\t", "") + title = title[:title.find(' | ')] + if line.find("no-flash-video-download") > -1: + url = line.replace('