mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-10 21:32:54 +08:00
memri: fix syntax
This commit is contained in:
parent
cef57038f8
commit
7784f328ff
@ -1,20 +1,12 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
import time
|
||||
import hmac
|
||||
import hashlib
|
||||
import itertools
|
||||
import re
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
int_or_none,
|
||||
parse_iso8601,
|
||||
unescapeHTML,
|
||||
js_to_json,
|
||||
)
|
||||
from ..compat import compat_urllib_request
|
||||
from .common import InfoExtractor
|
||||
|
||||
|
||||
@ -39,46 +31,46 @@ class MemriIE(InfoExtractor):
|
||||
mobj = re.match(self._VALID_URL, url)
|
||||
video_id = mobj.group('id') or mobj.group('eid')
|
||||
rurl = url
|
||||
if mobj.groupdict().get('eid') == None:
|
||||
rurl = 'http://www.memritv.org/embedded_player/index.php?clip_id='+video_id
|
||||
if mobj.groupdict().get('eid') is None:
|
||||
rurl = 'http://www.memritv.org/embedded_player/index.php?clip_id=' + video_id
|
||||
|
||||
webpage = self._download_webpage(rurl, video_id)
|
||||
jstr = self._search_regex( r'var config_overrides =.+?({.+?});', webpage, 'json', flags=re.DOTALL)
|
||||
jstr = re.sub(r'\n\s*//.*?\n','\n',jstr) # // comments break js_to_json
|
||||
js = self._parse_json(jstr,'json',transform_source=js_to_json)
|
||||
jstr = self._search_regex(r'var config_overrides =.+?({.+?});', webpage, 'json', flags=re.DOTALL)
|
||||
jstr = re.sub(r'\n\s*//.*?\n', '\n', jstr) # // comments break js_to_json
|
||||
js = self._parse_json(jstr, 'json', transform_source=js_to_json)
|
||||
|
||||
formats = []
|
||||
for ent in js['media']['source']:
|
||||
eurl = ent.get('src')
|
||||
if ent.get('type','') == 'application/x-mpegURL':
|
||||
formats.extend( self._extract_m3u8_formats(
|
||||
eurl, video_id, entry_protocol='m3u8', ext='mp4',
|
||||
m3u8_id='m3u8-mp4',
|
||||
preference=0)
|
||||
if ent.get('type', '') == 'application/x-mpegURL':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
eurl, video_id, entry_protocol='m3u8', ext='mp4',
|
||||
m3u8_id='m3u8-mp4',
|
||||
preference=0)
|
||||
)
|
||||
continue
|
||||
proto = re.search(r'^(.+?)://',eurl).group(1)
|
||||
proto = re.search(r'^(.+?)://', eurl).group(1)
|
||||
format = {
|
||||
'url': eurl,
|
||||
'ext': 'mp4',
|
||||
'protocol': proto,
|
||||
'format_id': proto+'-mp4',
|
||||
'url': eurl,
|
||||
'ext': 'mp4',
|
||||
'protocol': proto,
|
||||
'format_id': proto + '-mp4',
|
||||
}
|
||||
if proto == 'rtmp':
|
||||
urlre = re.search(r'^(.+?)(mp4:[^\?]+)(.+)',eurl)
|
||||
format['url'] = urlre.group(1)+urlre.group(3)
|
||||
urlre = re.search(r'^(.+?)(mp4:[^\?]+)(.+)', eurl)
|
||||
format['url'] = urlre.group(1) + urlre.group(3)
|
||||
format['play_path'] = urlre.group(2)
|
||||
formats.append(format)
|
||||
if not formats:
|
||||
if self._downloader.params.get('verbose', False):
|
||||
raise ExtractorError('No video found in '+jstr+'\n')
|
||||
raise ExtractorError('No video found in ' + jstr + '\n')
|
||||
else:
|
||||
raise ExtractorError('No video found')
|
||||
|
||||
self._sort_formats(formats)
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': unescapeHTML(js['media']['title']),
|
||||
'uploader': 'Memri',
|
||||
'formats': formats,
|
||||
'id': video_id,
|
||||
'title': unescapeHTML(js['media']['title']),
|
||||
'uploader': 'Memri',
|
||||
'formats': formats,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user