[camwithher] Improve extraction (Closes #8989)
This commit is contained in:
parent
04819db58e
commit
9aaaf8e8e8
1 changed files with 64 additions and 31 deletions
|
@ -1,55 +1,88 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import (
|
||||||
|
int_or_none,
|
||||||
|
parse_duration,
|
||||||
|
unified_strdate,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CamWithHerIE(InfoExtractor):
|
class CamWithHerIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?camwithher\.tv/view_video\.php\?.*viewkey=(?P<id>\w+)'
|
_VALID_URL = r'https?://(?:www\.)?camwithher\.tv/view_video\.php\?.*\bviewkey=(?P<id>\w+)'
|
||||||
|
|
||||||
_TESTS = [
|
_TESTS = [{
|
||||||
{
|
|
||||||
'url': 'http://camwithher.tv/view_video.php?viewkey=6e9a24e2c0e842e1f177&page=&viewtype=&category=',
|
'url': 'http://camwithher.tv/view_video.php?viewkey=6e9a24e2c0e842e1f177&page=&viewtype=&category=',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '5644',
|
'id': '5644',
|
||||||
'ext': 'flv',
|
'ext': 'flv',
|
||||||
'title': 'Periscope Tease',
|
'title': 'Periscope Tease',
|
||||||
|
'description': 'In the clouds teasing on periscope to my favorite song',
|
||||||
|
'duration': 240,
|
||||||
|
'view_count': int,
|
||||||
|
'comment_count': int,
|
||||||
|
'uploader': 'MileenaK',
|
||||||
|
'upload_date': '20160322',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
'url': 'http://camwithher.tv/view_video.php?viewkey=6dfd8b7c97531a459937',
|
'url': 'http://camwithher.tv/view_video.php?viewkey=6dfd8b7c97531a459937',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
'url': 'http://camwithher.tv/view_video.php?page=&viewkey=6e9a24e2c0e842e1f177&viewtype=&category=',
|
'url': 'http://camwithher.tv/view_video.php?page=&viewkey=6e9a24e2c0e842e1f177&viewtype=&category=',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
'url': 'http://camwithher.tv/view_video.php?viewkey=b6c3b5bea9515d1a1fc4&page=&viewtype=&category=mv',
|
'url': 'http://camwithher.tv/view_video.php?viewkey=b6c3b5bea9515d1a1fc4&page=&viewtype=&category=mv',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
flv_id = self._html_search_regex(r'<a href="/download/\?v=(\d+)', webpage, 'id')
|
flv_id = self._html_search_regex(
|
||||||
|
r'<a[^>]+href=["\']/download/\?v=(\d+)', webpage, 'video id')
|
||||||
|
|
||||||
# The number "2010" was reverse-engineered from cwhplayer.swf.
|
# Video URL construction algorithm is reverse-engineered from cwhplayer.swf
|
||||||
# It appears that they changed their video codec, and hence the RTMP URL
|
rtmp_url = 'rtmp://camwithher.tv/clipshare/%s' % (
|
||||||
# scheme at that video's ID.
|
('mp4:%s.mp4' % flv_id) if int(flv_id) > 2010 else flv_id)
|
||||||
rtmp_url = 'rtmp://camwithher.tv/clipshare/%s' % (('mp4:%s.mp4' % flv_id) if int(flv_id) > 2010 else flv_id)
|
|
||||||
|
title = self._html_search_regex(
|
||||||
|
r'<div[^>]+style="float:left"[^>]*>\s*<h2>(.+?)</h2>', webpage, 'title')
|
||||||
|
description = self._html_search_regex(
|
||||||
|
r'>Description:</span>(.+?)</div>', webpage, 'description', default=None)
|
||||||
|
|
||||||
|
runtime = self._search_regex(
|
||||||
|
r'Runtime\s*:\s*(.+?) \|', webpage, 'duration', default=None)
|
||||||
|
if runtime:
|
||||||
|
runtime = re.sub(r'[\s-]', '', runtime)
|
||||||
|
duration = parse_duration(runtime)
|
||||||
|
view_count = int_or_none(self._search_regex(
|
||||||
|
r'Views\s*:\s*(\d+)', webpage, 'view count', default=None))
|
||||||
|
comment_count = int_or_none(self._search_regex(
|
||||||
|
r'Comments\s*:\s*(\d+)', webpage, 'comment count', default=None))
|
||||||
|
|
||||||
|
uploader = self._search_regex(
|
||||||
|
r'Added by\s*:\s*<a[^>]+>([^<]+)</a>', webpage, 'uploader', default=None)
|
||||||
|
upload_date = unified_strdate(self._search_regex(
|
||||||
|
r'Added on\s*:\s*([\d-]+)', webpage, 'upload date', default=None))
|
||||||
|
|
||||||
title = self._html_search_regex(r'<div style="float:left">\s+<h2>(.+?)</h2>', webpage, 'title')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': flv_id,
|
'id': flv_id,
|
||||||
'url': rtmp_url,
|
'url': rtmp_url,
|
||||||
'no_resume': True,
|
|
||||||
'ext': 'flv',
|
'ext': 'flv',
|
||||||
|
'no_resume': True,
|
||||||
'title': title,
|
'title': title,
|
||||||
|
'description': description,
|
||||||
|
'duration': duration,
|
||||||
|
'view_count': view_count,
|
||||||
|
'comment_count': comment_count,
|
||||||
|
'uploader': uploader,
|
||||||
|
'upload_date': upload_date,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue