mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 08:26:50 +00:00
[imdb] Fix extraction (fixes #7220)
This commit is contained in:
parent
4a7b790384
commit
dd67702a3e
@ -4,8 +4,8 @@ import re
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..utils import (
|
||||||
compat_urlparse,
|
qualities,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -30,24 +30,33 @@ class ImdbIE(InfoExtractor):
|
|||||||
descr = self._html_search_regex(
|
descr = self._html_search_regex(
|
||||||
r'(?s)<span itemprop="description">(.*?)</span>',
|
r'(?s)<span itemprop="description">(.*?)</span>',
|
||||||
webpage, 'description', fatal=False)
|
webpage, 'description', fatal=False)
|
||||||
available_formats = re.findall(
|
player_url = 'http://www.imdb.com/video/imdb/vi%s/imdb/single' % video_id
|
||||||
r'case \'(?P<f_id>.*?)\' :$\s+url = \'(?P<path>.*?)\'', webpage,
|
player_page = self._download_webpage(
|
||||||
flags=re.MULTILINE)
|
player_url, video_id, 'Downloading player page')
|
||||||
|
# the player page contains the info for the default format, we have to
|
||||||
|
# fetch other pages for the rest of the formats
|
||||||
|
extra_formats = re.findall(r'href="(?P<url>%s.*?)".*?>(?P<name>.*?)<' % re.escape(player_url), player_page)
|
||||||
|
format_pages = [
|
||||||
|
self._download_webpage(
|
||||||
|
f_url, video_id, 'Downloading info for %s format' % f_name)
|
||||||
|
for f_url, f_name in extra_formats]
|
||||||
|
format_pages.append(player_page)
|
||||||
|
|
||||||
|
quality = qualities(['SD', '480p', '720p'])
|
||||||
formats = []
|
formats = []
|
||||||
for f_id, f_path in available_formats:
|
for format_page in format_pages:
|
||||||
f_path = f_path.strip()
|
|
||||||
format_page = self._download_webpage(
|
|
||||||
compat_urlparse.urljoin(url, f_path),
|
|
||||||
'Downloading info for %s format' % f_id)
|
|
||||||
json_data = self._search_regex(
|
json_data = self._search_regex(
|
||||||
r'<script[^>]+class="imdb-player-data"[^>]*?>(.*?)</script>',
|
r'<script[^>]+class="imdb-player-data"[^>]*?>(.*?)</script>',
|
||||||
format_page, 'json data', flags=re.DOTALL)
|
format_page, 'json data', flags=re.DOTALL)
|
||||||
info = json.loads(json_data)
|
info = json.loads(json_data)
|
||||||
format_info = info['videoPlayerObject']['video']
|
format_info = info['videoPlayerObject']['video']
|
||||||
|
f_id = format_info['ffname']
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': f_id,
|
'format_id': f_id,
|
||||||
'url': format_info['videoInfoList'][0]['videoUrl'],
|
'url': format_info['videoInfoList'][0]['videoUrl'],
|
||||||
|
'quality': quality(f_id),
|
||||||
})
|
})
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user