2 from __future__ import unicode_literals
9 from .common import InfoExtractor
10 from .youtube import YoutubeIE
11 from ..compat import compat_urlparse
14 class AbcNewsVideoIE(AMPIE):
15 IE_NAME = 'abcnews:video'
21 [^/]+/video/(?P<display_id>[0-9a-z-]+)-|
24 fivethirtyeight\.abcnews\.go\.com/video/embed/\d+/
30 'url': 'http://abcnews.go.com/ThisWeek/video/week-exclusive-irans-foreign-minister-zarif-20411932',
34 'display_id': 'week-exclusive-irans-foreign-minister-zarif',
35 'title': '\'This Week\' Exclusive: Iran\'s Foreign Minister Zarif',
36 'description': 'George Stephanopoulos goes one-on-one with Iranian Foreign Minister Dr. Javad Zarif.',
38 'thumbnail': r're:^https?://.*\.jpg$',
42 'skip_download': True,
45 'url': 'http://abcnews.go.com/video/embed?id=46979033',
46 'only_matching': True,
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 = YoutubeIE._extract_url(webpage)
118 date_str = self._html_search_regex(
119 r'<span[^>]+class="timestamp">([^<]+)</span>',
120 webpage, 'timestamp', fatal=False)
123 if date_str.endswith(' ET'): # Eastern Time
125 date_str = date_str[:-3]
126 date_formats = ['%b. %d, %Y', '%b %d, %Y, %I:%M %p']
127 for date_format in date_formats:
129 timestamp = calendar.timegm(time.strptime(date_str.strip(), date_format))
132 if timestamp is not None:
133 timestamp -= tz_offset * 3600
136 '_type': 'url_transparent',
137 'ie_key': AbcNewsVideoIE.ie_key(),
138 'url': full_video_url,
140 'display_id': display_id,
141 'timestamp': timestamp,
145 entries = [entry, self.url_result(youtube_url, ie=YoutubeIE.ie_key())]
146 return self.playlist_result(entries)