]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/aenetworks.py
[arte:playlist] Fix test
[yt-dlp.git] / youtube_dl / extractor / aenetworks.py
CommitLineData
b9c7a973
S
1from __future__ import unicode_literals
2
d8873d4d 3import re
4
b9c7a973 5from .common import InfoExtractor
d8873d4d 6from ..utils import (
7 smuggle_url,
8 update_url_query,
9 unescapeHTML,
10)
b9c7a973
S
11
12
855f90fa
S
13class AENetworksIE(InfoExtractor):
14 IE_NAME = 'aenetworks'
15 IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
d8873d4d 16 _VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?P<type>[^/]+)/(?:[^/]+/)+(?P<id>[^/]+?)(?:$|[?#])'
b9c7a973
S
17
18 _TESTS = [{
19 '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',
b9c7a973 20 'info_dict': {
52767c1b 21 'id': 'g12m5Gyt3fdR',
b9c7a973
S
22 'ext': 'mp4',
23 'title': "Bet You Didn't Know: Valentine's Day",
24 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
79ba9140 25 'timestamp': 1375819729,
26 'upload_date': '20130806',
27 'uploader': 'AENE-NEW',
b9c7a973 28 },
52767c1b 29 'params': {
30 # m3u8 download
31 'skip_download': True,
32 },
33 'add_ie': ['ThePlatform'],
1358b941 34 'expected_warnings': ['JSON-LD'],
52767c1b 35 }, {
36 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
d8873d4d 37 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
52767c1b 38 'info_dict': {
39 'id': 'eg47EERs_JsZ',
40 'ext': 'mp4',
611c1dd9 41 'title': 'Winter Is Coming',
1358b941 42 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
79ba9140 43 'timestamp': 1338306241,
44 'upload_date': '20120529',
45 'uploader': 'AENE-NEW',
52767c1b 46 },
b9c7a973 47 'add_ie': ['ThePlatform'],
587dfd44 48 }, {
49 'url': 'http://www.aetv.com/shows/duck-dynasty/video/inlawful-entry',
50 'only_matching': True
51 }, {
52 'url': 'http://www.fyi.tv/shows/tiny-house-nation/videos/207-sq-ft-minnesota-prairie-cottage',
53 'only_matching': True
54 }, {
55 'url': 'http://www.mylifetime.com/shows/project-runway-junior/video/season-1/episode-6/superstar-clients',
56 'only_matching': True
b9c7a973
S
57 }]
58
59 def _real_extract(self, url):
d8873d4d 60 page_type, video_id = re.match(self._VALID_URL, url).groups()
b9c7a973
S
61
62 webpage = self._download_webpage(url, video_id)
63
52767c1b 64 video_url_re = [
fad7a336 65 r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
52767c1b 66 r"media_url\s*=\s*'([^']+)'"
67 ]
d8873d4d 68 video_url = unescapeHTML(self._search_regex(video_url_re, webpage, 'video url'))
69 query = {'mbr': 'true'}
70 if page_type == 'shows':
71 query['assetTypes'] = 'medium_video_s3'
72 if 'switch=hds' in video_url:
73 query['switch'] = 'hls'
b9c7a973 74
b4e44234
S
75 info = self._search_json_ld(webpage, video_id, fatal=False)
76 info.update({
77 '_type': 'url_transparent',
329c1eae
JMF
78 'url': smuggle_url(
79 update_url_query(video_url, query),
80 {
d8873d4d 81 'sig': {
82 'key': 'crazyjava',
83 'secret': 's3cr3t'},
84 'force_smil_url': True
85 }),
b4e44234
S
86 })
87 return info