]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | parse_duration, | |
5 | unified_timestamp, | |
6 | ) | |
7 | ||
8 | ||
9 | class MeipaiIE(InfoExtractor): | |
10 | IE_DESC = '美拍' | |
11 | _VALID_URL = r'https?://(?:www\.)?meipai\.com/media/(?P<id>[0-9]+)' | |
12 | _TESTS = [{ | |
13 | # regular uploaded video | |
14 | 'url': 'http://www.meipai.com/media/531697625', | |
15 | 'md5': 'e3e9600f9e55a302daecc90825854b4f', | |
16 | 'info_dict': { | |
17 | 'id': '531697625', | |
18 | 'ext': 'mp4', | |
19 | 'title': '#葉子##阿桑##余姿昀##超級女聲#', | |
20 | 'description': '#葉子##阿桑##余姿昀##超級女聲#', | |
21 | 'thumbnail': r're:^https?://.*\.jpg$', | |
22 | 'duration': 152, | |
23 | 'timestamp': 1465492420, | |
24 | 'upload_date': '20160609', | |
25 | 'view_count': 35511, | |
26 | 'creator': '她她-TATA', | |
27 | 'tags': ['葉子', '阿桑', '余姿昀', '超級女聲'], | |
28 | } | |
29 | }, { | |
30 | # record of live streaming | |
31 | 'url': 'http://www.meipai.com/media/585526361', | |
32 | 'md5': 'ff7d6afdbc6143342408223d4f5fb99a', | |
33 | 'info_dict': { | |
34 | 'id': '585526361', | |
35 | 'ext': 'mp4', | |
36 | 'title': '姿昀和善願 練歌練琴啦😁😁😁', | |
37 | 'description': '姿昀和善願 練歌練琴啦😁😁😁', | |
38 | 'thumbnail': r're:^https?://.*\.jpg$', | |
39 | 'duration': 5975, | |
40 | 'timestamp': 1474311799, | |
41 | 'upload_date': '20160919', | |
42 | 'view_count': 1215, | |
43 | 'creator': '她她-TATA', | |
44 | } | |
45 | }] | |
46 | ||
47 | def _real_extract(self, url): | |
48 | video_id = self._match_id(url) | |
49 | webpage = self._download_webpage(url, video_id) | |
50 | ||
51 | title = self._og_search_title( | |
52 | webpage, default=None) or self._html_search_regex( | |
53 | r'<title[^>]*>([^<]+)</title>', webpage, 'title') | |
54 | ||
55 | formats = [] | |
56 | ||
57 | # recorded playback of live streaming | |
58 | m3u8_url = self._html_search_regex( | |
59 | r'file:\s*encodeURIComponent\((["\'])(?P<url>(?:(?!\1).)+)\1\)', | |
60 | webpage, 'm3u8 url', group='url', default=None) | |
61 | if m3u8_url: | |
62 | formats.extend(self._extract_m3u8_formats( | |
63 | m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', | |
64 | m3u8_id='hls', fatal=False)) | |
65 | ||
66 | if not formats: | |
67 | # regular uploaded video | |
68 | video_url = self._search_regex( | |
69 | r'data-video=(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'video url', | |
70 | group='url', default=None) | |
71 | if video_url: | |
72 | formats.append({ | |
73 | 'url': video_url, | |
74 | 'format_id': 'http', | |
75 | }) | |
76 | ||
77 | timestamp = unified_timestamp(self._og_search_property( | |
78 | 'video:release_date', webpage, 'release date', fatal=False)) | |
79 | ||
80 | tags = self._og_search_property( | |
81 | 'video:tag', webpage, 'tags', default='').split(',') | |
82 | ||
83 | view_count = int_or_none(self._html_search_meta( | |
84 | 'interactionCount', webpage, 'view count')) | |
85 | duration = parse_duration(self._html_search_meta( | |
86 | 'duration', webpage, 'duration')) | |
87 | creator = self._og_search_property( | |
88 | 'video:director', webpage, 'creator', fatal=False) | |
89 | ||
90 | return { | |
91 | 'id': video_id, | |
92 | 'title': title, | |
93 | 'description': self._og_search_description(webpage), | |
94 | 'thumbnail': self._og_search_thumbnail(webpage), | |
95 | 'duration': duration, | |
96 | 'timestamp': timestamp, | |
97 | 'view_count': view_count, | |
98 | 'creator': creator, | |
99 | 'tags': tags, | |
100 | 'formats': formats, | |
101 | } |