From 2c5def659cd3b0cbbfd033ced7d44c6f748330c4 Mon Sep 17 00:00:00 2001 From: Michael Evans Date: Mon, 21 Nov 2016 10:16:04 -0500 Subject: [PATCH 1/2] richannel Add new extractor --- youtube_dl/extractor/extractors.py | 6 ++- youtube_dl/extractor/richannel.py | 60 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 youtube_dl/extractor/richannel.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index d7ad5b8fc..373217e79 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -267,7 +267,10 @@ from .engadget import EngadgetIE from .eporner import EpornerIE from .eroprofile import EroProfileIE from .escapist import EscapistIE -from .espn import ESPNIE +from .espn import ( + ESPNIE, + ESPNArticleIE, +) from .esri import EsriVideoIE from .europa import EuropaIE from .everyonesmixtape import EveryonesMixtapeIE @@ -760,6 +763,7 @@ from .revision3 import ( Revision3IE, ) from .rice import RICEIE +from .richannel import RIChannelIE from .ringtv import RingTVIE from .rmcdecouverte import RMCDecouverteIE from .ro220 import Ro220IE diff --git a/youtube_dl/extractor/richannel.py b/youtube_dl/extractor/richannel.py new file mode 100644 index 000000000..b88a4ddbc --- /dev/null +++ b/youtube_dl/extractor/richannel.py @@ -0,0 +1,60 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + +import re +import urllib + + +class RIChannelIE(InfoExtractor): + _VALID_URL = r'http?://(?:www\.)?richannel\.org/(?P[-a-z0-9]+)' + _TEST = { + 'url': 'http://www.richannel.org/christmas-lectures-1991-richard-dawkins--waking-up-in-the-universe', + 'md5': 'd41d8cd98f00b204e9800998ecf8427e', + 'info_dict': { + 'id': 'christmas-lectures-1991-richard-dawkins--waking-up-in-the-universe', + 'ext': 'mp4', + 'title': str(172) # 'CHRISTMAS LECTURES 1991: Richard Dawkins - Waking Up in the Universe', is too long to fit + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + pattern = re.compile("video id=\"player-\d+") + reduced = pattern.search(webpage) + patt = re.compile("[\d]+") + r = str(reduced.group()) + m = patt.search(r) + RiP = str(m.group()) + resolutions = ['480', '640', '960', '1280'] + valid_urls = [] + i = 0 + src = "http://theri.bc.cdn.bitgravity.com/" \ + "vid_" + RiP + "/" + RiP + "_" + resolutions[i] + ".mp4" + redirected_url = src + while(i < 4): + src = "http://theri.bc.cdn.bitgravity.com/" \ + "vid_" + RiP + "/" + RiP + "_" + resolutions[i] + ".mp4" + try: + request = urllib.Request(src) + opener = urllib.build_opener() + f = opener.open(request) + if (f.getcode() == 200): + redirected_url = f.url + valid_urls.append(redirected_url) + except: + pass + formats = [{ + 'quality': resolutions[i], + 'url': redirected_url, + }] + i += 1 + self._sort_formats(formats) + + return { + 'id': video_id, + 'title': str(RiP), + 'formats': formats, + } From 655a74585b8790ffa10bb4cab1fdaac21c8379d1 Mon Sep 17 00:00:00 2001 From: mcjevans Date: Wed, 30 Nov 2016 21:08:41 -0500 Subject: [PATCH 2/2] Fixed test case for richannel.py --- youtube_dl/extractor/richannel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/richannel.py b/youtube_dl/extractor/richannel.py index b88a4ddbc..ea54e8f47 100644 --- a/youtube_dl/extractor/richannel.py +++ b/youtube_dl/extractor/richannel.py @@ -11,7 +11,7 @@ class RIChannelIE(InfoExtractor): _VALID_URL = r'http?://(?:www\.)?richannel\.org/(?P[-a-z0-9]+)' _TEST = { 'url': 'http://www.richannel.org/christmas-lectures-1991-richard-dawkins--waking-up-in-the-universe', - 'md5': 'd41d8cd98f00b204e9800998ecf8427e', + 'md5': '76170b1fe4eb12f5631d204a241b0bfe', 'info_dict': { 'id': 'christmas-lectures-1991-richard-dawkins--waking-up-in-the-universe', 'ext': 'mp4',