2 from __future__ import unicode_literals
9 from .common import InfoExtractor
10 from ..compat import compat_urlparse
13 class AbcNewsVideoIE(AMPIE):
14 IE_NAME = 'abcnews:video'
16 https?://abcnews\.go\.com/
17 (?:[^/]+/video/(?P<display_id>[0-9a-z-]+)-|
22 'url': 'http://abcnews.go.com/ThisWeek/video/week-exclusive-irans-foreign-minister-zarif-20411932',
26 'display_id': 'week-exclusive-irans-foreign-minister-zarif',
27 'title': '\'This Week\' Exclusive: Iran\'s Foreign Minister Zarif',
28 'description': 'George Stephanopoulos goes one-on-one with Iranian Foreign Minister Dr. Javad Zarif.',
30 'thumbnail': r're:^https?://.*\.jpg$',
34 'skip_download': True,
37 'url': 'http://abcnews.go.com/video/embed?id=46979033',
38 'md5': 'd19d160cfa8372fc197f406d4821dd9f',
42 'title': 'Nikki Haley reacts to French election results',
43 'description': 'md5:df1b5ad1b8ad76c4d4e01d3c67d6b38e',
45 'thumbnail': r're:^https?://.*\.jpg$',
48 'url': 'http://abcnews.go.com/2020/video/2020-husband-stands-teacher-jail-student-affairs-26119478',
49 'only_matching': True,
52 def _real_extract(self, url):
53 mobj = re.match(self._VALID_URL, url)
54 display_id = mobj.group('display_id')
55 video_id = mobj.group('id')
56 info_dict = self._extract_feed_info(
57 'http://abcnews.go.com/video/itemfeed?id=%s' % video_id)
60 'display_id': display_id,
65 class AbcNewsIE(InfoExtractor):
67 _VALID_URL = r'https?://abcnews\.go\.com/(?:[^/]+/)+(?P<display_id>[0-9a-z-]+)/story\?id=(?P<id>\d+)'
70 'url': 'http://abcnews.go.com/Blotter/News/dramatic-video-rare-death-job-america/story?id=10498713#.UIhwosWHLjY',
74 'display_id': 'dramatic-video-rare-death-job-america',
75 'title': 'Occupational Hazards',
76 'description': 'Nightline investigates the dangers that lurk at various jobs.',
77 'thumbnail': r're:^https?://.*\.jpg$',
78 'upload_date': '20100428',
79 'timestamp': 1272412800,
81 'add_ie': ['AbcNewsVideo'],
83 'url': 'http://abcnews.go.com/Entertainment/justin-timberlake-performs-stop-feeling-eurovision-2016/story?id=39125818',
87 'display_id': 'justin-timberlake-performs-stop-feeling-eurovision-2016',
88 'title': 'Justin Timberlake Drops Hints For Secret Single',
89 'description': 'Lara Spencer reports the buzziest stories of the day in "GMA" Pop News.',
90 'upload_date': '20160515',
91 'timestamp': 1463329500,
95 'skip_download': True,
96 # The embedded YouTube video is blocked due to copyright issues
97 'playlist_items': '1',
99 'add_ie': ['AbcNewsVideo'],
101 'url': 'http://abcnews.go.com/Technology/exclusive-apple-ceo-tim-cook-iphone-cracking-software/story?id=37173343',
102 'only_matching': True,
105 def _real_extract(self, url):
106 mobj = re.match(self._VALID_URL, url)
107 display_id = mobj.group('display_id')
108 video_id = mobj.group('id')
110 webpage = self._download_webpage(url, video_id)
111 video_url = self._search_regex(
112 r'window\.abcnvideo\.url\s*=\s*"([^"]+)"', webpage, 'video URL')
113 full_video_url = compat_urlparse.urljoin(url, video_url)
115 youtube_url = self._html_search_regex(
116 r'<iframe[^>]+src="(https://www\.youtube\.com/embed/[^"]+)"',
117 webpage, 'YouTube URL', default=None)
120 date_str = self._html_search_regex(
121 r'<span[^>]+class="timestamp">([^<]+)</span>',
122 webpage, 'timestamp', fatal=False)
125 if date_str.endswith(' ET'): # Eastern Time
127 date_str = date_str[:-3]
128 date_formats = ['%b. %d, %Y', '%b %d, %Y, %I:%M %p']
129 for date_format in date_formats:
131 timestamp = calendar.timegm(time.strptime(date_str.strip(), date_format))
134 if timestamp is not None:
135 timestamp -= tz_offset * 3600
138 '_type': 'url_transparent',
139 'ie_key': AbcNewsVideoIE.ie_key(),
140 'url': full_video_url,
142 'display_id': display_id,
143 'timestamp': timestamp,
147 entries = [entry, self.url_result(youtube_url, 'Youtube')]
148 return self.playlist_result(entries)