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'
19 [^/]+/video/(?P<display_id>[0-9a-z-]+)-|
26 'url': 'http://abcnews.go.com/ThisWeek/video/week-exclusive-irans-foreign-minister-zarif-20411932',
30 'display_id': 'week-exclusive-irans-foreign-minister-zarif',
31 'title': '\'This Week\' Exclusive: Iran\'s Foreign Minister Zarif',
32 'description': 'George Stephanopoulos goes one-on-one with Iranian Foreign Minister Dr. Javad Zarif.',
34 'thumbnail': r're:^https?://.*\.jpg$',
38 'skip_download': True,
41 'url': 'http://abcnews.go.com/video/embed?id=46979033',
42 'only_matching': True,
44 'url': 'http://abcnews.go.com/2020/video/2020-husband-stands-teacher-jail-student-affairs-26119478',
45 'only_matching': True,
48 def _real_extract(self, url):
49 mobj = re.match(self._VALID_URL, url)
50 display_id = mobj.group('display_id')
51 video_id = mobj.group('id')
52 info_dict = self._extract_feed_info(
53 'http://abcnews.go.com/video/itemfeed?id=%s' % video_id)
56 'display_id': display_id,
61 class AbcNewsIE(InfoExtractor):
63 _VALID_URL = r'https?://abcnews\.go\.com/(?:[^/]+/)+(?P<display_id>[0-9a-z-]+)/story\?id=(?P<id>\d+)'
66 'url': 'http://abcnews.go.com/Blotter/News/dramatic-video-rare-death-job-america/story?id=10498713#.UIhwosWHLjY',
70 'display_id': 'dramatic-video-rare-death-job-america',
71 'title': 'Occupational Hazards',
72 'description': 'Nightline investigates the dangers that lurk at various jobs.',
73 'thumbnail': r're:^https?://.*\.jpg$',
74 'upload_date': '20100428',
75 'timestamp': 1272412800,
77 'add_ie': ['AbcNewsVideo'],
79 'url': 'http://abcnews.go.com/Entertainment/justin-timberlake-performs-stop-feeling-eurovision-2016/story?id=39125818',
83 'display_id': 'justin-timberlake-performs-stop-feeling-eurovision-2016',
84 'title': 'Justin Timberlake Drops Hints For Secret Single',
85 'description': 'Lara Spencer reports the buzziest stories of the day in "GMA" Pop News.',
86 'upload_date': '20160515',
87 'timestamp': 1463329500,
91 'skip_download': True,
92 # The embedded YouTube video is blocked due to copyright issues
93 'playlist_items': '1',
95 'add_ie': ['AbcNewsVideo'],
97 'url': 'http://abcnews.go.com/Technology/exclusive-apple-ceo-tim-cook-iphone-cracking-software/story?id=37173343',
98 'only_matching': True,
101 def _real_extract(self, url):
102 mobj = re.match(self._VALID_URL, url)
103 display_id = mobj.group('display_id')
104 video_id = mobj.group('id')
106 webpage = self._download_webpage(url, video_id)
107 video_url = self._search_regex(
108 r'window\.abcnvideo\.url\s*=\s*"([^"]+)"', webpage, 'video URL')
109 full_video_url = compat_urlparse.urljoin(url, video_url)
111 youtube_url = self._html_search_regex(
112 r'<iframe[^>]+src="(https://www\.youtube\.com/embed/[^"]+)"',
113 webpage, 'YouTube URL', default=None)
116 date_str = self._html_search_regex(
117 r'<span[^>]+class="timestamp">([^<]+)</span>',
118 webpage, 'timestamp', fatal=False)
121 if date_str.endswith(' ET'): # Eastern Time
123 date_str = date_str[:-3]
124 date_formats = ['%b. %d, %Y', '%b %d, %Y, %I:%M %p']
125 for date_format in date_formats:
127 timestamp = calendar.timegm(time.strptime(date_str.strip(), date_format))
130 if timestamp is not None:
131 timestamp -= tz_offset * 3600
134 '_type': 'url_transparent',
135 'ie_key': AbcNewsVideoIE.ie_key(),
136 'url': full_video_url,
138 'display_id': display_id,
139 'timestamp': timestamp,
143 entries = [entry, self.url_result(youtube_url, 'Youtube')]
144 return self.playlist_result(entries)