def scan_archive(path):
 if (not os.path.exists(path)):
  raise ValueError('Path does not exist')
 if (not path.endswith(ARCHIVE_EXTENSIONS)):
  raise ValueError(('%r is not a valid archive extension' % os.path.splitext(path)[1]))
 (dirpath, filename) = os.path.split(path)
 logger.info('Scanning archive %r in %r', filename, dirpath)
 if filename.endswith('.rar'):
  rar = RarFile(path)
  rar_filenames = [f for f in rar.namelist() if f.endswith(VIDEO_EXTENSIONS)]
  if (not rar_filenames):
   raise ValueError('No video in archive')
  if (len(rar_filenames) > 1):
   raise ValueError('More than one video in archive')
  rar_filename = rar_filenames[0]
  rar_filepath = os.path.join(dirpath, rar_filename)
  video = Video.fromguess(rar_filepath, guessit(rar_filepath))
  video.size = rar.getinfo(rar_filename).file_size
 else:
  raise ValueError(('Unsupported extension %r' % os.path.splitext(path)[1]))
 return video

def scan_archive ( path ) : if ( not os . path . exists ( path ) ) : raise ValueError ( 'Path does not exist' ) if ( not path . endswith ( ARCHIVE_EXTENSIONS ) ) : raise ValueError ( ( '%r is not a valid archive extension' % os . path . splitext ( path ) [ 1 ] ) ) ( dirpath , filename ) = os . path . split ( path ) logger . info ( 'Scanning archive %r in %r' , filename , dirpath ) if filename . endswith ( '.rar' ) : rar = RarFile ( path ) rar_filenames = [ f for f in rar . namelist ( ) if f . endswith ( VIDEO_EXTENSIONS ) ] if ( not rar_filenames ) : raise ValueError ( 'No video in archive' ) if ( len ( rar_filenames ) > 1 ) : raise ValueError ( 'More than one video in archive' ) rar_filename = rar_filenames [ 0 ] rar_filepath = os . path . join ( dirpath , rar_filename ) video = Video . fromguess ( rar_filepath , guessit ( rar_filepath ) ) video . size = rar . getinfo ( rar_filename ) . file_size else : raise ValueError ( ( 'Unsupported extension %r' % os . path . splitext ( path ) [ 1 ] ) ) return video
scan an archive from a path .