Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AsianCrush] fix extractor, add support for yuyutv and Midnight Pulp #21290

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 81 additions & 27 deletions youtube_dl/extractor/asiancrush.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,64 @@

from .common import InfoExtractor
from .kaltura import KalturaIE
from ..utils import (
extract_attributes,
remove_end,
)
from ..utils import extract_attributes


class AsianCrushIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?asiancrush\.com/video/(?:[^/]+/)?0+(?P<id>\d+)v\b'
IE_NAME = 'asiancrush'
_DOMAINS = r'(?:asiancrush\.com|yuyutv\.com|midnightpulp\.com)'
ealgase marked this conversation as resolved.
Show resolved Hide resolved
_VALID_URL = r'https?://(?:www\.)?(?P<host>%s)/video/(?:[^/]+/)?0+(?P<id>\d+)v\b' % _DOMAINS
_TESTS = [{
'url': 'https://www.asiancrush.com/video/012869v/women-who-flirt/',
'md5': 'c3b740e48d0ba002a42c0b72857beae6',
'info_dict': {
'id': '1_y4tmjm5r',
'ext': 'mp4',
'title': 'Women Who Flirt',
'description': 'md5:3db14e9186197857e7063522cb89a805',
'description': 'md5:7e986615808bcfb11756eb503a751487',
'timestamp': 1496936429,
'upload_date': '20170608',
'uploader_id': '[email protected]',
},
}, {
'url': 'https://www.asiancrush.com/video/she-was-pretty/011886v-pretty-episode-3/',
'only_matching': True,
}, {
'url': 'https://www.yuyutv.com/video/013886v/the-act-of-killing/',
'md5': '90dc82dfcd52e1f44c0b065bc1dd3827',
'info_dict': {
'id': '1_66x4rg7o',
'ext': 'mp4',
'title': 'The Act of Killing',
'description': 'md5:76d745019ef586b3dc59c2a344758741',
'timestamp': 1557419432,
'upload_date': '20190509',
'uploader_id': '[email protected]',
},
}, {
'url': 'https://www.yuyutv.com/video/peep-show/013922v-warring-factions/',
'only_matching': True,
}, {
'url': 'https://www.midnightpulp.com/video/010400v/drifters/',
'md5': '44c7993934434afd7f1ee928ef0f734b',
'info_dict': {
'id': '1_sh88xpyz',
'ext': 'mp4',
'title': 'Drifters',
'description': 'md5:beccb5d5d2955d6defbf88ea256607db',
'timestamp': 1497470628,
'upload_date': '20170614',
'uploader_id': '[email protected]',
},
}, {
'url': 'https://www.midnightpulp.com/video/mononoke/016378v-zashikiwarashi-part-1/',
'only_matching': True,
}]

def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
host = mobj.group('host')
video_id = self._match_id(url)

webpage = self._download_webpage(url, video_id)

entry_id, partner_id, title = [None] * 3
Expand All @@ -51,7 +81,7 @@ def _real_extract(self, url):
r'\bentry_id["\']\s*:\s*["\'](\d+)', webpage, 'entry id')

player = self._download_webpage(
'https://api.asiancrush.com/embeddedVideoPlayer', video_id,
'https://api.%s/embeddedVideoPlayer' % host, video_id,
query={'id': entry_id})

kaltura_id = self._search_regex(
Expand All @@ -63,23 +93,47 @@ def _real_extract(self, url):
r'/p(?:artner_id)?/(\d+)', player, 'partner id',
default='513551')

return self.url_result(
'kaltura:%s:%s' % (partner_id, kaltura_id),
ie=KalturaIE.ie_key(), video_id=kaltura_id,
video_title=title)
description = self._html_search_regex(r'<div class="description">(.+?)</div>', webpage, 'description', fatal=False, flags=re.DOTALL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move flags into regex. Carry long lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about "Move flags into regex", I can't find a difference between the way this is implemented in other extractors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What difference are you even talking about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You said "Move flags into regex", I don't understand what you're asking me to do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you aware what flags are at all?


return {
'_type': 'url_transparent',
'url': 'kaltura:%s:%s' % (partner_id, kaltura_id),
'ie_key': KalturaIE.ie_key(),
'id': video_id,
'title': title,
'description': description,
}


class AsianCrushPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?asiancrush\.com/series/0+(?P<id>\d+)s\b'
_TEST = {
_VIDEO_IE = AsianCrushIE
ealgase marked this conversation as resolved.
Show resolved Hide resolved
_DOMAINS = r'(?:asiancrush\.com|yuyutv\.com|midnightpulp\.com)'
_VALID_URL = r'https?://(?:www\.)?(?P<host>%s)/series/0+(?P<id>\d+)s\b' % _DOMAINS
_TESTS = [{
'url': 'https://www.asiancrush.com/series/012481s/scholar-walks-night/',
'info_dict': {
'id': '12481',
'title': 'Scholar Who Walks the Night',
'description': 'md5:7addd7c5132a09fd4741152d96cce886',
},
'playlist_count': 20,
}
}, {
'url': 'https://www.yuyutv.com/series/013920s/peep-show/',
'info_dict': {
'id': '13920',
'title': 'Peep Show',
'description': 'md5:15b59e05eb41fd2082671577eaf1b02d',
},
'playlist_count': 54,
}, {
'url': 'https://www.midnightpulp.com/series/016375s/mononoke/',
'info_dict': {
'id': '16375',
'title': 'Mononoke',
'description': 'md5:4a6d4f36eb1165f1854dbc9ac3b83c07',
},
'playlist_count': 12,
}]

def _real_extract(self, url):
playlist_id = self._match_id(url)
Expand All @@ -89,22 +143,22 @@ def _real_extract(self, url):
entries = []

for mobj in re.finditer(
r'<a[^>]+href=(["\'])(?P<url>%s.*?)\1[^>]*>' % AsianCrushIE._VALID_URL,
r'<a[^>]+href=(["\'])(?P<url>%s.*?)\1[^>]*>' % self._VIDEO_IE._VALID_URL,
ealgase marked this conversation as resolved.
Show resolved Hide resolved
webpage):
attrs = extract_attributes(mobj.group(0))
if attrs.get('class') == 'clearfix':
entries.append(self.url_result(
mobj.group('url'), ie=AsianCrushIE.ie_key()))

title = remove_end(
self._html_search_regex(
r'(?s)<h1\b[^>]\bid=["\']movieTitle[^>]+>(.+?)</h1>', webpage,
'title', default=None) or self._og_search_title(
webpage, default=None) or self._html_search_meta(
'twitter:title', webpage, 'title',
default=None) or self._search_regex(
r'<title>([^<]+)</title>', webpage, 'title', fatal=False),
' | AsianCrush')
mobj.group('url'), ie=self._VIDEO_IE.ie_key()))

title = re.sub(r'\s*\|\s*.+?$', '',
self._html_search_regex(
r'(?s)<h1\b[^>]\bid=["\']movieTitle[^>]+>(.+?)</h1>', webpage,
'title', default=None) or self._og_search_title(
webpage, default=None) or self._html_search_meta(
'twitter:title', webpage, 'title',
default=None) or self._search_regex(
r'<title>([^<]+)</title>', webpage, 'title', fatal=False)
)
ealgase marked this conversation as resolved.
Show resolved Hide resolved

description = self._og_search_description(
webpage, default=None) or self._html_search_meta(
Expand Down