1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-05 00:51:29 +00:00
youtube-dl/youtube_dl/extractor/aenetworks.py

88 lines
3 KiB
Python
Raw Normal View History

2015-02-14 22:57:52 +00:00
from __future__ import unicode_literals
2016-04-01 08:56:18 +00:00
import re
2015-02-14 22:57:52 +00:00
from .common import InfoExtractor
2016-04-01 08:56:18 +00:00
from ..utils import (
smuggle_url,
update_url_query,
unescapeHTML,
)
2015-02-14 22:57:52 +00:00
class AENetworksIE(InfoExtractor):
IE_NAME = 'aenetworks'
IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
2016-04-01 08:56:18 +00:00
_VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?P<type>[^/]+)/(?:[^/]+/)+(?P<id>[^/]+?)(?:$|[?#])'
2015-02-14 22:57:52 +00:00
_TESTS = [{
'url': 'http://www.history.com/topics/valentines-day/history-of-valentines-day/videos/bet-you-didnt-know-valentines-day?m=528e394da93ae&s=undefined&f=1&free=false',
'info_dict': {
'id': 'g12m5Gyt3fdR',
2015-02-14 22:57:52 +00:00
'ext': 'mp4',
'title': "Bet You Didn't Know: Valentine's Day",
'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
'timestamp': 1375819729,
'upload_date': '20130806',
'uploader': 'AENE-NEW',
2015-02-14 22:57:52 +00:00
},
'params': {
# m3u8 download
'skip_download': True,
},
'add_ie': ['ThePlatform'],
2016-01-16 12:56:53 +00:00
'expected_warnings': ['JSON-LD'],
}, {
'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
2016-04-01 08:56:18 +00:00
'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
'info_dict': {
'id': 'eg47EERs_JsZ',
'ext': 'mp4',
2016-02-14 09:37:17 +00:00
'title': 'Winter Is Coming',
2016-01-16 12:56:53 +00:00
'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
'timestamp': 1338306241,
'upload_date': '20120529',
'uploader': 'AENE-NEW',
},
2015-02-14 22:57:52 +00:00
'add_ie': ['ThePlatform'],
}, {
'url': 'http://www.aetv.com/shows/duck-dynasty/video/inlawful-entry',
'only_matching': True
}, {
'url': 'http://www.fyi.tv/shows/tiny-house-nation/videos/207-sq-ft-minnesota-prairie-cottage',
'only_matching': True
}, {
'url': 'http://www.mylifetime.com/shows/project-runway-junior/video/season-1/episode-6/superstar-clients',
'only_matching': True
2015-02-14 22:57:52 +00:00
}]
def _real_extract(self, url):
2016-04-01 08:56:18 +00:00
page_type, video_id = re.match(self._VALID_URL, url).groups()
2015-02-14 22:57:52 +00:00
webpage = self._download_webpage(url, video_id)
video_url_re = [
r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
r"media_url\s*=\s*'([^']+)'"
]
2016-04-01 08:56:18 +00:00
video_url = unescapeHTML(self._search_regex(video_url_re, webpage, 'video url'))
query = {'mbr': 'true'}
if page_type == 'shows':
query['assetTypes'] = 'medium_video_s3'
if 'switch=hds' in video_url:
query['switch'] = 'hls'
2015-02-14 22:57:52 +00:00
info = self._search_json_ld(webpage, video_id, fatal=False)
info.update({
'_type': 'url_transparent',
2016-04-01 18:42:19 +00:00
'url': smuggle_url(
update_url_query(video_url, query),
{
2016-04-01 08:56:18 +00:00
'sig': {
'key': 'crazyjava',
'secret': 's3cr3t'},
'force_smil_url': True
}),
})
return info