- is_economy = video_real_url.endswith('low')
-
- if is_economy:
- self.report_warning('Site is currently in economy mode! You will only have access to lower quality streams')
-
- # Invoking ffprobe to determine resolution
- pp = FFmpegPostProcessor(self._downloader)
- cookies = self._get_cookies('https://nicovideo.jp').output(header='', sep='; path=/; domain=nicovideo.jp;\n')
-
- self.to_screen('%s: %s' % (video_id, 'Checking smile format with ffprobe'))
-
- try:
- metadata = pp.get_metadata_object(video_real_url, ['-cookies', cookies])
- except PostProcessingError as err:
- raise ExtractorError(err.msg, expected=True)
-
- v_stream = a_stream = {}
-
- # Some complex swf files doesn't have video stream (e.g. nm4809023)
- for stream in metadata['streams']:
- if stream['codec_type'] == 'video':
- v_stream = stream
- elif stream['codec_type'] == 'audio':
- a_stream = stream
-
- # Community restricted videos seem to have issues with the thumb API not returning anything at all
- filesize = int(
- (get_video_info_xml('size_high') if not is_economy else get_video_info_xml('size_low'))
- or metadata['format']['size']
- )
- extension = (
- get_video_info_xml('movie_type')
- or 'mp4' if 'mp4' in metadata['format']['format_name'] else metadata['format']['format_name']
- )
-
- # 'creation_time' tag on video stream of re-encoded SMILEVIDEO mp4 files are '1970-01-01T00:00:00.000000Z'.
- timestamp = (
- parse_iso8601(get_video_info_web('first_retrieve'))
- or unified_timestamp(get_video_info_web('postedDateTime'))
- )
- metadata_timestamp = (
- parse_iso8601(try_get(v_stream, lambda x: x['tags']['creation_time']))
- or timestamp if extension != 'mp4' else 0
- )
-
- # According to compconf, smile videos from pre-2017 are always better quality than their DMC counterparts
- smile_threshold_timestamp = parse_iso8601('2016-12-08T00:00:00+09:00')
-
- is_source = timestamp < smile_threshold_timestamp or metadata_timestamp > 0
-
- # If movie file size is unstable, old server movie is not source movie.
- if filesize > 1:
- formats.append({
- 'url': video_real_url,
- 'format_id': 'smile' if not is_economy else 'smile_low',
- 'format_note': 'SMILEVIDEO source' if not is_economy else 'SMILEVIDEO low quality',
- 'ext': extension,
- 'container': extension,
- 'vcodec': v_stream.get('codec_name'),
- 'acodec': a_stream.get('codec_name'),
- # Some complex swf files doesn't have total bit rate metadata (e.g. nm6049209)
- 'tbr': int_or_none(metadata['format'].get('bit_rate'), scale=1000),
- 'vbr': int_or_none(v_stream.get('bit_rate'), scale=1000),
- 'abr': int_or_none(a_stream.get('bit_rate'), scale=1000),
- 'height': int_or_none(v_stream.get('height')),
- 'width': int_or_none(v_stream.get('width')),
- 'source_preference': 5 if not is_economy else -2,
- 'quality': 5 if is_source and not is_economy else None,
- 'filesize': filesize
- })
+ if not video_real_url:
+ self.report_warning('Unable to obtain smile video information')
+ else:
+ is_economy = video_real_url.endswith('low')
+
+ if is_economy:
+ self.report_warning('Site is currently in economy mode! You will only have access to lower quality streams')
+
+ # Invoking ffprobe to determine resolution
+ pp = FFmpegPostProcessor(self._downloader)
+ cookies = self._get_cookies('https://nicovideo.jp').output(header='', sep='; path=/; domain=nicovideo.jp;\n')
+
+ self.to_screen('%s: %s' % (video_id, 'Checking smile format with ffprobe'))
+
+ try:
+ metadata = pp.get_metadata_object(video_real_url, ['-cookies', cookies])
+ except PostProcessingError as err:
+ raise ExtractorError(err.msg, expected=True)
+
+ v_stream = a_stream = {}
+
+ # Some complex swf files doesn't have video stream (e.g. nm4809023)
+ for stream in metadata['streams']:
+ if stream['codec_type'] == 'video':
+ v_stream = stream
+ elif stream['codec_type'] == 'audio':
+ a_stream = stream
+
+ # Community restricted videos seem to have issues with the thumb API not returning anything at all
+ filesize = int(
+ (get_video_info_xml('size_high') if not is_economy else get_video_info_xml('size_low'))
+ or metadata['format']['size']
+ )
+ extension = (
+ get_video_info_xml('movie_type')
+ or 'mp4' if 'mp4' in metadata['format']['format_name'] else metadata['format']['format_name']
+ )
+
+ # 'creation_time' tag on video stream of re-encoded SMILEVIDEO mp4 files are '1970-01-01T00:00:00.000000Z'.
+ timestamp = (
+ parse_iso8601(get_video_info_web('first_retrieve'))
+ or unified_timestamp(get_video_info_web('postedDateTime'))
+ )
+ metadata_timestamp = (
+ parse_iso8601(try_get(v_stream, lambda x: x['tags']['creation_time']))
+ or timestamp if extension != 'mp4' else 0
+ )
+
+ # According to compconf, smile videos from pre-2017 are always better quality than their DMC counterparts
+ smile_threshold_timestamp = parse_iso8601('2016-12-08T00:00:00+09:00')
+
+ is_source = timestamp < smile_threshold_timestamp or metadata_timestamp > 0
+
+ # If movie file size is unstable, old server movie is not source movie.
+ if filesize > 1:
+ formats.append({
+ 'url': video_real_url,
+ 'format_id': 'smile' if not is_economy else 'smile_low',
+ 'format_note': 'SMILEVIDEO source' if not is_economy else 'SMILEVIDEO low quality',
+ 'ext': extension,
+ 'container': extension,
+ 'vcodec': v_stream.get('codec_name'),
+ 'acodec': a_stream.get('codec_name'),
+ # Some complex swf files doesn't have total bit rate metadata (e.g. nm6049209)
+ 'tbr': int_or_none(metadata['format'].get('bit_rate'), scale=1000),
+ 'vbr': int_or_none(v_stream.get('bit_rate'), scale=1000),
+ 'abr': int_or_none(a_stream.get('bit_rate'), scale=1000),
+ 'height': int_or_none(v_stream.get('height')),
+ 'width': int_or_none(v_stream.get('width')),
+ 'source_preference': 5 if not is_economy else -2,
+ 'quality': 5 if is_source and not is_economy else None,
+ 'filesize': filesize
+ })