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