1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-13 10:47:15 +08:00

richannel Add new extractor

This commit is contained in:
Michael Evans 2016-11-21 10:16:04 -05:00
parent ebc7ab1e23
commit 2c5def659c
2 changed files with 65 additions and 1 deletions

View File

@ -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

View File

@ -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<id>[-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,
}