[filmweb] improve extraction
This commit is contained in:
parent
a14001a5a1
commit
be069839b4
@ -1,45 +1,42 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .twentythreevideo import TwentyThreeVideoIE
|
import re
|
||||||
|
|
||||||
|
from .common import InfoExtractor
|
||||||
|
|
||||||
|
|
||||||
class FilmwebIE(TwentyThreeVideoIE):
|
class FilmwebIE(InfoExtractor):
|
||||||
IE_NAME = 'Filmweb'
|
_VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece'
|
||||||
_VALID_URL = r'https?://(?:www\.)?filmweb\.no/trailere/article(?P<id>\d+).ece'
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://www.filmweb.no/trailere/article1264921.ece',
|
'url': 'http://www.filmweb.no/trailere/article1264921.ece',
|
||||||
'md5': 'e353f47df98e557d67edaceda9dece89',
|
'md5': 'e353f47df98e557d67edaceda9dece89',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '1264921',
|
'id': '13033574',
|
||||||
'title': 'Det som en gang var',
|
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'description': 'Trailer: Scener fra et vennskap',
|
'title': 'Det som en gang var',
|
||||||
|
'upload_date': '20160316',
|
||||||
|
'timestamp': 1458140101,
|
||||||
|
'uploader_id': '12639966',
|
||||||
|
'uploader': 'Live Roaldset',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_CLIENT_NAME = 'filmweb'
|
|
||||||
_CLIENT_ID = '12732917'
|
|
||||||
_EMBED_BASE_URL = 'http://www.filmweb.no/template/ajax/json_trailerEmbed.jsp?articleId=%s&autoplay=true'
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
article_id = self._match_id(url)
|
article_type, article_id = re.match(self._VALID_URL, url).groups()
|
||||||
webpage = self._download_webpage(url, article_id)
|
if article_type == 'filmnytt':
|
||||||
|
webpage = self._download_webpage(url, article_id)
|
||||||
title = self._search_regex(r'var\s+jsTitle\s*=\s*escape\("([^"]+)"\);',
|
article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id')
|
||||||
webpage, 'title', fatal=True)
|
embed_code = self._download_json(
|
||||||
|
'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp',
|
||||||
format_url = self._proto_relative_url(
|
article_id, query={
|
||||||
self._html_search_regex(r'"(//filmweb\.23video\.com/[^"]+)"',
|
'articleId': article_id,
|
||||||
self._download_json(self._EMBED_BASE_URL % article_id,
|
})['embedCode']
|
||||||
article_id)['embedCode'], 'format url'))
|
iframe_url = self._proto_relative_url(self._search_regex(
|
||||||
|
r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url'))
|
||||||
formats = self._extract_formats(format_url, self._CLIENT_ID)
|
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'_type': 'url_transparent',
|
||||||
'id': article_id,
|
'id': article_id,
|
||||||
'title': title,
|
'url': iframe_url,
|
||||||
'alt_title': self._og_search_title(webpage),
|
'ie_key': 'TwentyThreeVideo',
|
||||||
'formats': formats,
|
|
||||||
'description': self._og_search_description(webpage),
|
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,77 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import int_or_none
|
||||||
|
|
||||||
|
|
||||||
class TwentyThreeVideoIE(InfoExtractor):
|
class TwentyThreeVideoIE(InfoExtractor):
|
||||||
IE_NAME = '23video'
|
IE_NAME = '23video'
|
||||||
_VALID_URL = r'https?://(?:www\.)?(?P<client>[\w-]+)\.23video\.com/v.ihtml/player.html.*photo_id=(?P<id>\d+)'
|
_VALID_URL = r'https?://video\.(?P<domain>twentythree\.net|23video\.com|filmweb\.no)/v\.ihtml/player\.html\?(?P<query>.*?\bphoto(?:_|%5f)id=(?P<id>\d+).*)'
|
||||||
_TEST = {}
|
_TEST = {
|
||||||
|
'url': 'https://video.twentythree.net/v.ihtml/player.html?showDescriptions=0&source=site&photo%5fid=20448876&autoPlay=1',
|
||||||
_URL_TEMPLATE = 'https://%s.23video.com/%s/%s/%s/%s/download-video.mp4'
|
'md5': '75fcf216303eb1dae9920d651f85ced4',
|
||||||
_FORMATS = {
|
'info_dict': {
|
||||||
'video_hd': {
|
'id': '20448876',
|
||||||
'width': 1280,
|
'ext': 'mp4',
|
||||||
'height': 720,
|
'title': 'Video Marketing Minute: Personalized Video',
|
||||||
},
|
'timestamp': 1513855354,
|
||||||
'video_medium': {
|
'upload_date': '20171221',
|
||||||
'width': 640,
|
'uploader_id': '12258964',
|
||||||
'height': 360,
|
'uploader': 'Rasmus Bysted',
|
||||||
},
|
|
||||||
'video_mobile_high': {
|
|
||||||
'width': 320,
|
|
||||||
'height': 180,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _extract_formats(self, url, client_id):
|
def _real_extract(self, url):
|
||||||
client_name = self._search_regex(r'([a-z]+)\.23video\.com', url, 'client name')
|
domain, query, photo_id = re.match(self._VALID_URL, url).groups()
|
||||||
video_id = self._search_regex(r'photo%5fid=([^?&]+)', url, 'video id')
|
base_url = 'https://video.%s' % domain
|
||||||
token = self._search_regex(r'token=([^?&]+)', url, 'token')
|
photo_data = self._download_json(
|
||||||
|
base_url + '/api/photo/list?' + query, photo_id, query={
|
||||||
|
'format': 'json',
|
||||||
|
}, transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photo data'))['photo']
|
||||||
|
title = photo_data['title']
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for format_key in self._FORMATS.keys():
|
|
||||||
|
audio_path = photo_data.get('audio_download')
|
||||||
|
if audio_path:
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': self._URL_TEMPLATE % (client_name, client_id, video_id,
|
'format_id': 'audio',
|
||||||
token, format_key),
|
'url': base_url + audio_path,
|
||||||
'width': self._FORMATS.get(format_key, {}).get('width'),
|
'filesize': int_or_none(photo_data.get('audio_size')),
|
||||||
'height': self._FORMATS.get(format_key, {}).get('height'),
|
'vcodec': 'none',
|
||||||
})
|
})
|
||||||
|
|
||||||
return formats
|
def add_common_info_to_list(l, template, id_field, id_value):
|
||||||
|
f_base = template % id_value
|
||||||
|
f_path = photo_data.get(f_base + 'download')
|
||||||
|
if not f_path:
|
||||||
|
return
|
||||||
|
l.append({
|
||||||
|
id_field: id_value,
|
||||||
|
'url': base_url + f_path,
|
||||||
|
'width': int_or_none(photo_data.get(f_base + 'width')),
|
||||||
|
'height': int_or_none(photo_data.get(f_base + 'height')),
|
||||||
|
'filesize': int_or_none(photo_data.get(f_base + 'size')),
|
||||||
|
})
|
||||||
|
|
||||||
def _real_extract(self, url):
|
for f in ('mobile_high', 'medium', 'hd', '1080p', '4k'):
|
||||||
# TODO: Find out how to extract client_id
|
add_common_info_to_list(formats, 'video_%s_', 'format_id', f)
|
||||||
raise NotImplementedError('Not able to extract the `client_id`')
|
|
||||||
|
thumbnails = []
|
||||||
|
for t in ('quad16', 'quad50', 'quad75', 'quad100', 'small', 'portrait', 'standard', 'medium', 'large', 'original'):
|
||||||
|
add_common_info_to_list(thumbnails, '%s_', 'id', t)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': photo_id,
|
||||||
|
'title': title,
|
||||||
|
'timestamp': int_or_none(photo_data.get('creation_date_epoch')),
|
||||||
|
'duration': int_or_none(photo_data.get('video_length')),
|
||||||
|
'view_count': int_or_none(photo_data.get('view_count')),
|
||||||
|
'comment_count': int_or_none(photo_data.get('number_of_comments')),
|
||||||
|
'uploader_id': photo_data.get('user_id'),
|
||||||
|
'uploader': photo_data.get('display_name'),
|
||||||
|
'thumbnails': thumbnails,
|
||||||
|
'formats': formats,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user