]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/aenetworks.py
Imported Upstream version 2016.06.25
[youtubedl] / youtube_dl / extractor / aenetworks.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 smuggle_url,
8 update_url_query,
9 unescapeHTML,
10 )
11
12
13 class AENetworksIE(InfoExtractor):
14 IE_NAME = 'aenetworks'
15 IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
16 _VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?P<type>[^/]+)/(?:[^/]+/)+(?P<id>[^/]+?)(?:$|[?#])'
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',
20 'info_dict': {
21 'id': 'g12m5Gyt3fdR',
22 'ext': 'mp4',
23 'title': "Bet You Didn't Know: Valentine's Day",
24 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
25 'timestamp': 1375819729,
26 'upload_date': '20130806',
27 'uploader': 'AENE-NEW',
28 },
29 'params': {
30 # m3u8 download
31 'skip_download': True,
32 },
33 'add_ie': ['ThePlatform'],
34 'expected_warnings': ['JSON-LD'],
35 }, {
36 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
37 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
38 'info_dict': {
39 'id': 'eg47EERs_JsZ',
40 'ext': 'mp4',
41 'title': 'Winter Is Coming',
42 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
43 'timestamp': 1338306241,
44 'upload_date': '20120529',
45 'uploader': 'AENE-NEW',
46 },
47 'add_ie': ['ThePlatform'],
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
57 }]
58
59 def _real_extract(self, url):
60 page_type, video_id = re.match(self._VALID_URL, url).groups()
61
62 webpage = self._download_webpage(url, video_id)
63
64 video_url_re = [
65 r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
66 r"media_url\s*=\s*'([^']+)'"
67 ]
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'
74
75 info = self._search_json_ld(webpage, video_id, fatal=False)
76 info.update({
77 '_type': 'url_transparent',
78 'url': smuggle_url(
79 update_url_query(video_url, query),
80 {
81 'sig': {
82 'key': 'crazyjava',
83 'secret': 's3cr3t'},
84 'force_smil_url': True
85 }),
86 })
87 return info