]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/abc7news.py
Prepare for release.
[youtubedl] / youtube_dl / extractor / abc7news.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import parse_iso8601
7
8
9 class Abc7NewsIE(InfoExtractor):
10 _VALID_URL = r'https?://abc7news\.com(?:/[^/]+/(?P<display_id>[^/]+))?/(?P<id>\d+)'
11 _TESTS = [
12 {
13 'url': 'http://abc7news.com/entertainment/east-bay-museum-celebrates-vintage-synthesizers/472581/',
14 'info_dict': {
15 'id': '472581',
16 'display_id': 'east-bay-museum-celebrates-vintage-synthesizers',
17 'ext': 'mp4',
18 'title': 'East Bay museum celebrates history of synthesized music',
19 'description': 'md5:a4f10fb2f2a02565c1749d4adbab4b10',
20 'thumbnail': 're:^https?://.*\.jpg$',
21 'timestamp': 1421123075,
22 'upload_date': '20150113',
23 'uploader': 'Jonathan Bloom',
24 },
25 'params': {
26 # m3u8 download
27 'skip_download': True,
28 },
29 },
30 {
31 'url': 'http://abc7news.com/472581',
32 'only_matching': True,
33 },
34 ]
35
36 def _real_extract(self, url):
37 mobj = re.match(self._VALID_URL, url)
38 video_id = mobj.group('id')
39 display_id = mobj.group('display_id') or video_id
40
41 webpage = self._download_webpage(url, display_id)
42
43 m3u8 = self._html_search_meta(
44 'contentURL', webpage, 'm3u8 url', fatal=True)
45
46 formats = self._extract_m3u8_formats(m3u8, display_id, 'mp4')
47 self._sort_formats(formats)
48
49 title = self._og_search_title(webpage).strip()
50 description = self._og_search_description(webpage).strip()
51 thumbnail = self._og_search_thumbnail(webpage)
52 timestamp = parse_iso8601(self._search_regex(
53 r'<div class="meta">\s*<time class="timeago" datetime="([^"]+)">',
54 webpage, 'upload date', fatal=False))
55 uploader = self._search_regex(
56 r'rel="author">([^<]+)</a>',
57 webpage, 'uploader', default=None)
58
59 return {
60 'id': video_id,
61 'display_id': display_id,
62 'title': title,
63 'description': description,
64 'thumbnail': thumbnail,
65 'timestamp': timestamp,
66 'uploader': uploader,
67 'formats': formats,
68 }