- video_id = self._extract_id(url)
-
- # Get video webpage
- self.report_video_webpage_download(video_id)
- url = 'http://www.nicovideo.jp/watch/' + video_id
- request = compat_urllib_request.Request(url)
- try:
- video_webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- raise ExtractorError(u'Unable to download video webpage: %s' % compat_str(err))
-
- # Get video info
- self.report_video_info_webpage_download(video_id)
- url = 'http://ext.nicovideo.jp/api/getthumbinfo/' + video_id
- request = compat_urllib_request.Request(url)
- try:
- video_info_webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- raise ExtractorError(u'Unable to download video info webpage: %s' % compat_str(err))
-
- # Get flv info
- self.report_flv_info_webpage_download(video_id)
- url = 'http://flapi.nicovideo.jp/api/getflv?v=' + video_id
- request = compat_urllib_request.Request(url)
- try:
- flv_info_webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- raise ExtractorError(u'Unable to download flv info webpage: %s' % compat_str(err))
-
- # Start extracting information
- self.report_information_extraction(video_id)
- video_info = xml.etree.ElementTree.fromstring(video_info_webpage)
-
- # url
- video_real_url = compat_urlparse.parse_qs(flv_info_webpage.decode('utf-8'))['url'][0]
-
- # title
- video_title = video_info.find('.//title').text
-
- # ext
- video_extension = video_info.find('.//movie_type').text
-
- # format
- video_format = video_extension.upper()
-
- # thumbnail
- video_thumbnail = video_info.find('.//thumbnail_url').text
-
- # description
- video_description = video_info.find('.//description').text
-
- # uploader_id
- video_uploader_id = video_info.find('.//user_id').text
-
- # uploader
- url = 'http://seiga.nicovideo.jp/api/user/info?id=' + video_uploader_id
- request = compat_urllib_request.Request(url)
- try:
- user_info_webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- self._downloader.report_warning(u'Unable to download user info webpage: %s' % compat_str(err))
-
- user_info = xml.etree.ElementTree.fromstring(user_info_webpage)
- video_uploader = user_info.find('.//nickname').text
-
- # uploder_date
- video_upload_date = unified_strdate(video_info.find('.//first_retrieve').text.split('+')[0])