2014-01-07 22:18:10 +07:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
2015-12-06 02:25:46 +01:00
|
|
|
HEADRequest,
|
2014-01-07 22:18:10 +07:00
|
|
|
)
|
|
|
|
|
2014-01-08 01:18:47 +01:00
|
|
|
|
2014-02-24 23:30:09 +07:00
|
|
|
class NovaMovIE(InfoExtractor):
|
|
|
|
IE_NAME = 'novamov'
|
|
|
|
IE_DESC = 'NovaMov'
|
|
|
|
|
2014-04-05 19:36:22 +07:00
|
|
|
_VALID_URL_TEMPLATE = r'http://(?:(?:www\.)?%(host)s/(?:file|video)/|(?:(?:embed|www)\.)%(host)s/embed\.php\?(?:.*?&)?v=)(?P<id>[a-z\d]{13})'
|
2014-04-05 15:34:54 +07:00
|
|
|
_VALID_URL = _VALID_URL_TEMPLATE % {'host': 'novamov\.com'}
|
2014-02-24 23:30:09 +07:00
|
|
|
|
|
|
|
_HOST = 'www.novamov.com'
|
|
|
|
|
2014-01-07 22:18:10 +07:00
|
|
|
_TEST = {
|
|
|
|
'url': 'http://www.novamov.com/video/4rurhn9x446jj',
|
|
|
|
'md5': '7205f346a52bbeba427603ba10d4b935',
|
|
|
|
'info_dict': {
|
2014-02-24 23:30:09 +07:00
|
|
|
'id': '4rurhn9x446jj',
|
|
|
|
'ext': 'flv',
|
2014-01-07 22:18:10 +07:00
|
|
|
'title': 'search engine optimization',
|
|
|
|
'description': 'search engine optimization is used to rank the web page in the google search engine'
|
2014-01-22 03:04:10 +01:00
|
|
|
},
|
|
|
|
'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)'
|
2014-01-07 22:18:10 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-11-11 22:34:49 +06:00
|
|
|
video_id = self._match_id(url)
|
2014-01-07 22:18:10 +07:00
|
|
|
|
2015-12-06 02:25:46 +01:00
|
|
|
video_data = self._download_json(
|
|
|
|
'http://%s/mobile/ajax.php?videoId=%s' % (self._HOST, video_id),
|
|
|
|
video_id, 'Downloading video page')
|
2014-01-07 22:18:10 +07:00
|
|
|
|
2015-12-06 02:25:46 +01:00
|
|
|
if video_data.get('error'):
|
|
|
|
raise ExtractorError(
|
|
|
|
'%s said: The video does not exist or has been deleted.' % self.IE_NAME,
|
|
|
|
expected=True)
|
2014-01-07 22:18:10 +07:00
|
|
|
|
2015-12-06 02:25:46 +01:00
|
|
|
video_data = video_data['items'][0]
|
2014-01-07 22:18:10 +07:00
|
|
|
|
2015-12-06 02:25:46 +01:00
|
|
|
request = HEADRequest('http://%s/mobile/%s' % (self._HOST, video_data['download']))
|
|
|
|
# resolve the url so that we can detect the correct extension
|
|
|
|
head = self._request_webpage(request, video_id)
|
|
|
|
video_url = head.geturl()
|
2014-01-07 22:18:10 +07:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'url': video_url,
|
2015-12-06 02:25:46 +01:00
|
|
|
'title': video_data['title'],
|
|
|
|
'description': video_data.get('desc'),
|
2014-11-23 20:41:03 +01:00
|
|
|
}
|