2014-02-04 08:40:27 -05:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2015-11-21 11:18:17 -05:00
|
|
|
from ..compat import compat_urllib_parse
|
2014-12-13 06:24:42 -05:00
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
2015-11-21 11:18:17 -05:00
|
|
|
sanitized_Request,
|
2014-12-13 06:24:42 -05:00
|
|
|
)
|
2014-02-04 08:40:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
class MooshareIE(InfoExtractor):
|
|
|
|
IE_NAME = 'mooshare'
|
|
|
|
IE_DESC = 'Mooshare.biz'
|
2014-03-27 08:08:02 -04:00
|
|
|
_VALID_URL = r'http://(?:www\.)?mooshare\.biz/(?P<id>[\da-z]{12})'
|
2014-02-04 08:40:27 -05:00
|
|
|
|
|
|
|
_TESTS = [
|
|
|
|
{
|
|
|
|
'url': 'http://mooshare.biz/8dqtk4bjbp8g',
|
|
|
|
'md5': '4e14f9562928aecd2e42c6f341c8feba',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '8dqtk4bjbp8g',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Comedy Football 2011 - (part 1-2)',
|
|
|
|
'duration': 893,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'url': 'http://mooshare.biz/aipjtoc4g95j',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'aipjtoc4g95j',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Orange Caramel Dashing Through the Snow',
|
|
|
|
'duration': 212,
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# rtmp download
|
|
|
|
'skip_download': True,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-12-13 06:24:42 -05:00
|
|
|
video_id = self._match_id(url)
|
2014-02-04 08:40:27 -05:00
|
|
|
page = self._download_webpage(url, video_id, 'Downloading page')
|
|
|
|
|
|
|
|
if re.search(r'>Video Not Found or Deleted<', page) is not None:
|
2014-11-26 07:06:02 -05:00
|
|
|
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
2014-02-04 08:40:27 -05:00
|
|
|
|
|
|
|
hash_key = self._html_search_regex(r'<input type="hidden" name="hash" value="([^"]+)">', page, 'hash')
|
|
|
|
title = self._html_search_regex(r'(?m)<div class="blockTitle">\s*<h2>Watch ([^<]+)</h2>', page, 'title')
|
|
|
|
|
|
|
|
download_form = {
|
|
|
|
'op': 'download1',
|
|
|
|
'id': video_id,
|
|
|
|
'hash': hash_key,
|
|
|
|
}
|
|
|
|
|
2015-11-21 11:18:17 -05:00
|
|
|
request = sanitized_Request(
|
2014-02-06 09:26:12 -05:00
|
|
|
'http://mooshare.biz/%s' % video_id, compat_urllib_parse.urlencode(download_form))
|
2014-02-04 08:40:27 -05:00
|
|
|
request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
|
|
|
|
2014-12-14 20:31:54 -05:00
|
|
|
self._sleep(5, video_id)
|
2014-02-04 08:40:27 -05:00
|
|
|
|
|
|
|
video_page = self._download_webpage(request, video_id, 'Downloading video page')
|
|
|
|
|
|
|
|
thumbnail = self._html_search_regex(r'image:\s*"([^"]+)",', video_page, 'thumbnail', fatal=False)
|
|
|
|
duration_str = self._html_search_regex(r'duration:\s*"(\d+)",', video_page, 'duration', fatal=False)
|
|
|
|
duration = int(duration_str) if duration_str is not None else None
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
|
|
|
|
# SD video
|
|
|
|
mobj = re.search(r'(?m)file:\s*"(?P<url>[^"]+)",\s*provider:', video_page)
|
|
|
|
if mobj is not None:
|
|
|
|
formats.append({
|
|
|
|
'url': mobj.group('url'),
|
|
|
|
'format_id': 'sd',
|
|
|
|
'format': 'SD',
|
|
|
|
})
|
|
|
|
|
|
|
|
# HD video
|
|
|
|
mobj = re.search(r'\'hd-2\': { file: \'(?P<url>[^\']+)\' },', video_page)
|
|
|
|
if mobj is not None:
|
|
|
|
formats.append({
|
|
|
|
'url': mobj.group('url'),
|
|
|
|
'format_id': 'hd',
|
|
|
|
'format': 'HD',
|
|
|
|
})
|
|
|
|
|
|
|
|
# rtmp video
|
|
|
|
mobj = re.search(r'(?m)file: "(?P<playpath>[^"]+)",\s*streamer: "(?P<rtmpurl>rtmp://[^"]+)",', video_page)
|
|
|
|
if mobj is not None:
|
|
|
|
formats.append({
|
|
|
|
'url': mobj.group('rtmpurl'),
|
|
|
|
'play_path': mobj.group('playpath'),
|
|
|
|
'rtmp_live': False,
|
|
|
|
'ext': 'mp4',
|
|
|
|
'format_id': 'rtmp',
|
|
|
|
'format': 'HD',
|
|
|
|
})
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'duration': duration,
|
|
|
|
'formats': formats,
|
2014-11-23 14:41:03 -05:00
|
|
|
}
|