[filmweb] improve extraction
This commit is contained in:
parent
a14001a5a1
commit
be069839b4
2 changed files with 86 additions and 57 deletions
|
@ -1,45 +1,42 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from .twentythreevideo import TwentyThreeVideoIE
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
|
||||
|
||||
class FilmwebIE(TwentyThreeVideoIE):
|
||||
IE_NAME = 'Filmweb'
|
||||
_VALID_URL = r'https?://(?:www\.)?filmweb\.no/trailere/article(?P<id>\d+).ece'
|
||||
class FilmwebIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece'
|
||||
_TEST = {
|
||||
'url': 'http://www.filmweb.no/trailere/article1264921.ece',
|
||||
'md5': 'e353f47df98e557d67edaceda9dece89',
|
||||
'info_dict': {
|
||||
'id': '1264921',
|
||||
'title': 'Det som en gang var',
|
||||
'id': '13033574',
|
||||
'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):
|
||||
article_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, article_id)
|
||||
|
||||
title = self._search_regex(r'var\s+jsTitle\s*=\s*escape\("([^"]+)"\);',
|
||||
webpage, 'title', fatal=True)
|
||||
|
||||
format_url = self._proto_relative_url(
|
||||
self._html_search_regex(r'"(//filmweb\.23video\.com/[^"]+)"',
|
||||
self._download_json(self._EMBED_BASE_URL % article_id,
|
||||
article_id)['embedCode'], 'format url'))
|
||||
|
||||
formats = self._extract_formats(format_url, self._CLIENT_ID)
|
||||
self._sort_formats(formats)
|
||||
article_type, article_id = re.match(self._VALID_URL, url).groups()
|
||||
if article_type == 'filmnytt':
|
||||
webpage = self._download_webpage(url, article_id)
|
||||
article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id')
|
||||
embed_code = self._download_json(
|
||||
'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp',
|
||||
article_id, query={
|
||||
'articleId': article_id,
|
||||
})['embedCode']
|
||||
iframe_url = self._proto_relative_url(self._search_regex(
|
||||
r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url'))
|
||||
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'id': article_id,
|
||||
'title': title,
|
||||
'alt_title': self._og_search_title(webpage),
|
||||
'formats': formats,
|
||||
'description': self._og_search_description(webpage),
|
||||
'url': iframe_url,
|
||||
'ie_key': 'TwentyThreeVideo',
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue