2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from .kaltura import KalturaIE
14 class AsianCrushIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?asiancrush\.com/video/(?:[^/]+/)?0+(?P<id>\d+)v\b'
17 'url': 'https://www.asiancrush.com/video/012869v/women-who-flirt/',
18 'md5': 'c3b740e48d0ba002a42c0b72857beae6',
22 'title': 'Women Who Flirt',
23 'description': 'md5:3db14e9186197857e7063522cb89a805',
24 'timestamp': 1496936429,
25 'upload_date': '20170608',
26 'uploader_id': 'craig@crifkin.com',
29 'url': 'https://www.asiancrush.com/video/she-was-pretty/011886v-pretty-episode-3/',
30 'only_matching': True,
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
36 webpage = self._download_webpage(url, video_id)
38 entry_id, partner_id, title = [None] * 3
40 vars = self._parse_json(
42 r'iEmbedVars\s*=\s*({.+?})', webpage, 'embed vars',
43 default='{}'), video_id, fatal=False)
45 entry_id = vars.get('entry_id')
46 partner_id = vars.get('partner_id')
47 title = vars.get('vid_label')
50 entry_id = self._search_regex(
51 r'\bentry_id["\']\s*:\s*["\'](\d+)', webpage, 'entry id')
53 player = self._download_webpage(
54 'https://api.asiancrush.com/embeddedVideoPlayer', video_id,
55 query={'id': entry_id})
57 kaltura_id = self._search_regex(
58 r'entry_id["\']\s*:\s*(["\'])(?P<id>(?:(?!\1).)+)\1', player,
59 'kaltura id', group='id')
62 partner_id = self._search_regex(
63 r'/p(?:artner_id)?/(\d+)', player, 'partner id',
66 return self.url_result(
67 'kaltura:%s:%s' % (partner_id, kaltura_id),
68 ie=KalturaIE.ie_key(), video_id=kaltura_id,
72 class AsianCrushPlaylistIE(InfoExtractor):
73 _VALID_URL = r'https?://(?:www\.)?asiancrush\.com/series/0+(?P<id>\d+)s\b'
75 'url': 'https://www.asiancrush.com/series/012481s/scholar-walks-night/',
78 'title': 'Scholar Who Walks the Night',
79 'description': 'md5:7addd7c5132a09fd4741152d96cce886',
84 def _real_extract(self, url):
85 playlist_id = self._match_id(url)
87 webpage = self._download_webpage(url, playlist_id)
91 for mobj in re.finditer(
92 r'<a[^>]+href=(["\'])(?P<url>%s.*?)\1[^>]*>' % AsianCrushIE._VALID_URL,
94 attrs = extract_attributes(mobj.group(0))
95 if attrs.get('class') == 'clearfix':
96 entries.append(self.url_result(
97 mobj.group('url'), ie=AsianCrushIE.ie_key()))
100 self._html_search_regex(
101 r'(?s)<h1\b[^>]\bid=["\']movieTitle[^>]+>(.+?)</h1>', webpage,
102 'title', default=None) or self._og_search_title(
103 webpage, default=None) or self._html_search_meta(
104 'twitter:title', webpage, 'title',
105 default=None) or self._search_regex(
106 r'<title>([^<]+)</title>', webpage, 'title', fatal=False),
109 description = self._og_search_description(
110 webpage, default=None) or self._html_search_meta(
111 'twitter:description', webpage, 'description', fatal=False)
113 return self.playlist_result(entries, playlist_id, title, description)