2024-06-12 01:09:58 +02:00
|
|
|
|
import urllib.parse
|
|
|
|
|
|
2016-03-11 22:44:18 +01:00
|
|
|
|
from .common import InfoExtractor
|
2016-05-26 16:48:47 +02:00
|
|
|
|
from ..utils import (
|
|
|
|
|
int_or_none,
|
|
|
|
|
unified_strdate,
|
2021-09-05 03:33:27 +02:00
|
|
|
|
url_or_none,
|
2016-05-26 16:48:47 +02:00
|
|
|
|
)
|
2016-03-11 22:44:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DWIE(InfoExtractor):
|
2024-03-09 01:02:45 +01:00
|
|
|
|
_WORKING = False
|
|
|
|
|
_ENABLED = None # XXX: pass through to GenericIE
|
2016-03-12 08:33:22 +01:00
|
|
|
|
IE_NAME = 'dw'
|
2016-05-26 16:48:47 +02:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?dw\.com/(?:[^/]+/)+(?:av|e)-(?P<id>\d+)'
|
2016-03-11 23:55:26 +01:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
# video
|
2016-03-11 22:44:18 +01:00
|
|
|
|
'url': 'http://www.dw.com/en/intelligent-light/av-19112290',
|
2021-09-05 03:33:27 +02:00
|
|
|
|
'md5': 'fb9dfd9520811d3ece80f04befd73428',
|
2016-03-11 22:44:18 +01:00
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '19112290',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Intelligent light',
|
|
|
|
|
'description': 'md5:90e00d5881719f2a6a5827cb74985af1',
|
2021-09-05 03:33:27 +02:00
|
|
|
|
'upload_date': '20160605',
|
2024-06-12 01:09:58 +02:00
|
|
|
|
},
|
2016-03-11 23:55:26 +01:00
|
|
|
|
}, {
|
|
|
|
|
# audio
|
|
|
|
|
'url': 'http://www.dw.com/en/worldlink-my-business/av-19111941',
|
|
|
|
|
'md5': '2814c9a1321c3a51f8a7aeb067a360dd',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '19111941',
|
|
|
|
|
'ext': 'mp3',
|
|
|
|
|
'title': 'WorldLink: My business',
|
|
|
|
|
'description': 'md5:bc9ca6e4e063361e21c920c53af12405',
|
|
|
|
|
'upload_date': '20160311',
|
2024-06-12 01:09:58 +02:00
|
|
|
|
},
|
2016-05-26 16:48:47 +02:00
|
|
|
|
}, {
|
2016-06-10 10:53:40 +02:00
|
|
|
|
# DW documentaries, only last for one or two weeks
|
2016-05-26 16:48:47 +02:00
|
|
|
|
'url': 'http://www.dw.com/en/documentaries-welcome-to-the-90s-2016-05-21/e-19220158-9798',
|
|
|
|
|
'md5': '56b6214ef463bfb9a3b71aeb886f3cf1',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '19274438',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Welcome to the 90s – Hip Hop',
|
|
|
|
|
'description': 'Welcome to the 90s - The Golden Decade of Hip Hop',
|
|
|
|
|
'upload_date': '20160521',
|
|
|
|
|
},
|
2016-06-10 10:53:40 +02:00
|
|
|
|
'skip': 'Video removed',
|
2016-03-11 23:55:26 +01:00
|
|
|
|
}]
|
2016-03-11 22:44:18 +01:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2016-03-12 08:33:22 +01:00
|
|
|
|
media_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage(url, media_id)
|
2016-03-11 22:44:18 +01:00
|
|
|
|
hidden_inputs = self._hidden_inputs(webpage)
|
|
|
|
|
title = hidden_inputs['media_title']
|
2016-05-26 16:48:47 +02:00
|
|
|
|
media_id = hidden_inputs.get('media_id') or media_id
|
2016-03-11 22:44:18 +01:00
|
|
|
|
|
2021-09-05 03:33:27 +02:00
|
|
|
|
direct_url = url_or_none(hidden_inputs.get('file_name'))
|
|
|
|
|
if direct_url:
|
|
|
|
|
formats = [{'url': hidden_inputs['file_name']}]
|
|
|
|
|
else:
|
2016-03-11 23:55:26 +01:00
|
|
|
|
formats = self._extract_smil_formats(
|
2024-06-12 01:09:58 +02:00
|
|
|
|
f'http://www.dw.com/smil/v-{media_id}', media_id,
|
2016-03-11 23:55:26 +01:00
|
|
|
|
transform_source=lambda s: s.replace(
|
|
|
|
|
'rtmp://tv-od.dw.de/flash/',
|
|
|
|
|
'http://tv-download.dw.de/dwtv_video/flv/'))
|
|
|
|
|
|
2016-05-26 16:48:47 +02:00
|
|
|
|
upload_date = hidden_inputs.get('display_date')
|
|
|
|
|
if not upload_date:
|
|
|
|
|
upload_date = self._html_search_regex(
|
|
|
|
|
r'<span[^>]+class="date">([0-9.]+)\s*\|', webpage,
|
|
|
|
|
'upload date', default=None)
|
|
|
|
|
upload_date = unified_strdate(upload_date)
|
|
|
|
|
|
2016-03-11 22:44:18 +01:00
|
|
|
|
return {
|
2016-03-12 08:33:22 +01:00
|
|
|
|
'id': media_id,
|
2016-03-11 22:44:18 +01:00
|
|
|
|
'title': title,
|
|
|
|
|
'description': self._og_search_description(webpage),
|
|
|
|
|
'thumbnail': hidden_inputs.get('preview_image'),
|
|
|
|
|
'duration': int_or_none(hidden_inputs.get('file_duration')),
|
2016-05-26 16:48:47 +02:00
|
|
|
|
'upload_date': upload_date,
|
2016-03-11 22:44:18 +01:00
|
|
|
|
'formats': formats,
|
|
|
|
|
}
|
2016-03-12 08:33:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DWArticleIE(InfoExtractor):
|
2024-03-09 01:02:45 +01:00
|
|
|
|
_WORKING = False
|
|
|
|
|
_ENABLED = None # XXX: pass through to GenericIE
|
2016-03-12 08:33:22 +01:00
|
|
|
|
IE_NAME = 'dw:article'
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?dw\.com/(?:[^/]+/)+a-(?P<id>\d+)'
|
|
|
|
|
_TEST = {
|
|
|
|
|
'url': 'http://www.dw.com/en/no-hope-limited-options-for-refugees-in-idomeni/a-19111009',
|
|
|
|
|
'md5': '8ca657f9d068bbef74d6fc38b97fc869',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '19105868',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'The harsh life of refugees in Idomeni',
|
|
|
|
|
'description': 'md5:196015cc7e48ebf474db9399420043c7',
|
|
|
|
|
'upload_date': '20160310',
|
2024-06-12 01:09:58 +02:00
|
|
|
|
},
|
2016-03-12 08:33:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
article_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage(url, article_id)
|
|
|
|
|
hidden_inputs = self._hidden_inputs(webpage)
|
|
|
|
|
media_id = hidden_inputs['media_id']
|
2024-06-12 01:09:58 +02:00
|
|
|
|
media_path = self._search_regex(rf'href="([^"]+av-{media_id})"\s+class="overlayLink"', webpage, 'media url')
|
|
|
|
|
media_url = urllib.parse.urljoin(url, media_path)
|
2016-03-12 08:33:22 +01:00
|
|
|
|
return self.url_result(media_url, 'DW', media_id)
|