2016-09-20 18:14:24 -06:00
|
|
|
from .common import InfoExtractor
|
2016-12-17 05:42:34 -07:00
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
parse_duration,
|
|
|
|
unified_timestamp,
|
|
|
|
)
|
2016-09-20 18:14:24 -06:00
|
|
|
|
|
|
|
|
|
|
|
class MeipaiIE(InfoExtractor):
|
|
|
|
IE_DESC = '美拍'
|
2017-10-09 10:50:53 -06:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?meipai\.com/media/(?P<id>[0-9]+)'
|
2016-12-17 05:42:34 -07:00
|
|
|
_TESTS = [{
|
|
|
|
# regular uploaded video
|
|
|
|
'url': 'http://www.meipai.com/media/531697625',
|
|
|
|
'md5': 'e3e9600f9e55a302daecc90825854b4f',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '531697625',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': '#葉子##阿桑##余姿昀##超級女聲#',
|
|
|
|
'description': '#葉子##阿桑##余姿昀##超級女聲#',
|
2017-01-02 05:08:07 -07:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2016-12-17 05:42:34 -07:00
|
|
|
'duration': 152,
|
|
|
|
'timestamp': 1465492420,
|
|
|
|
'upload_date': '20160609',
|
|
|
|
'view_count': 35511,
|
|
|
|
'creator': '她她-TATA',
|
|
|
|
'tags': ['葉子', '阿桑', '余姿昀', '超級女聲'],
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2016-12-17 05:42:34 -07:00
|
|
|
}, {
|
2016-09-20 18:14:24 -06:00
|
|
|
# record of live streaming
|
2016-12-17 05:42:34 -07:00
|
|
|
'url': 'http://www.meipai.com/media/585526361',
|
|
|
|
'md5': 'ff7d6afdbc6143342408223d4f5fb99a',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '585526361',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': '姿昀和善願 練歌練琴啦😁😁😁',
|
|
|
|
'description': '姿昀和善願 練歌練琴啦😁😁😁',
|
2017-01-02 05:08:07 -07:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2016-12-17 05:42:34 -07:00
|
|
|
'duration': 5975,
|
|
|
|
'timestamp': 1474311799,
|
|
|
|
'upload_date': '20160919',
|
|
|
|
'view_count': 1215,
|
|
|
|
'creator': '她她-TATA',
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2016-12-17 05:42:34 -07:00
|
|
|
}]
|
2016-09-20 18:14:24 -06:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2022-10-31 06:05:20 -06:00
|
|
|
title = self._generic_title('', webpage)
|
2016-09-20 18:14:24 -06:00
|
|
|
|
2016-12-17 05:42:34 -07:00
|
|
|
formats = []
|
|
|
|
|
|
|
|
# recorded playback of live streaming
|
|
|
|
m3u8_url = self._html_search_regex(
|
|
|
|
r'file:\s*encodeURIComponent\((["\'])(?P<url>(?:(?!\1).)+)\1\)',
|
|
|
|
webpage, 'm3u8 url', group='url', default=None)
|
|
|
|
if m3u8_url:
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
|
|
|
m3u8_id='hls', fatal=False))
|
|
|
|
|
|
|
|
if not formats:
|
|
|
|
# regular uploaded video
|
|
|
|
video_url = self._search_regex(
|
|
|
|
r'data-video=(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'video url',
|
|
|
|
group='url', default=None)
|
|
|
|
if video_url:
|
|
|
|
formats.append({
|
|
|
|
'url': video_url,
|
|
|
|
'format_id': 'http',
|
|
|
|
})
|
|
|
|
|
|
|
|
timestamp = unified_timestamp(self._og_search_property(
|
|
|
|
'video:release_date', webpage, 'release date', fatal=False))
|
2016-09-20 18:14:24 -06:00
|
|
|
|
|
|
|
tags = self._og_search_property(
|
|
|
|
'video:tag', webpage, 'tags', default='').split(',')
|
|
|
|
|
2016-12-17 05:42:34 -07:00
|
|
|
view_count = int_or_none(self._html_search_meta(
|
|
|
|
'interactionCount', webpage, 'view count'))
|
|
|
|
duration = parse_duration(self._html_search_meta(
|
|
|
|
'duration', webpage, 'duration'))
|
|
|
|
creator = self._og_search_property(
|
|
|
|
'video:director', webpage, 'creator', fatal=False)
|
|
|
|
|
|
|
|
return {
|
2016-09-20 18:14:24 -06:00
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'description': self._og_search_description(webpage),
|
2016-12-17 05:42:34 -07:00
|
|
|
'thumbnail': self._og_search_thumbnail(webpage),
|
|
|
|
'duration': duration,
|
|
|
|
'timestamp': timestamp,
|
|
|
|
'view_count': view_count,
|
|
|
|
'creator': creator,
|
2016-09-20 18:14:24 -06:00
|
|
|
'tags': tags,
|
2016-12-17 05:42:34 -07:00
|
|
|
'formats': formats,
|
2016-09-20 18:14:24 -06:00
|
|
|
}
|