Compute a hash using NapiProjekt's algorithm.

    :param str video_path: path of the video.
    :return: the hash.
    :rtype: str
5798
def hash_napiprojekt(video_path):
    
    readsize = 1024 * 1024 * 10
    with open(video_path, 'rb') as f:
        data = f.read(readsize)
    return hashlib.md5(data).hexdigest()
62420
def download_video(self):
        
        rvideo_path = self.presentation.metadata['video_path']

        if self.presentation.client.cache:
            video_path = self.presentation.client.cache.get_path(rvideo_path)
            if not video_path:
                video_path = self.download_video_no_cache()
                self.presentation.client.cache.put_path(rvideo_path, video_path)
        else:
            video_path = self.download_video_no_cache()

        return video_path
550222
def video(self):
        
        if self._video is None:
            from twilio.rest.video import Video
            self._video = Video(self)
        return self._video
107027
def get_cache_key(path):
    
    # Python 2/3 support for path hashing
    try:
        path_hash = hashlib.md5(path).hexdigest()
    except TypeError:
        path_hash = hashlib.md5(path.encode('utf-8')).hexdigest()
    return settings.cache_key_prefix + path_hash
822327
def _hash_file(self, path):
        

        m = hashlib.md5()
        with open(path, "rb") as f:
            while True:
                buf = f.read(128)
                if not buf:
                    break
                m.update(buf)
        return m.hexdigest()
900937
def _get_hashed_path(self, path):
        """"""
        return self._get_path('%s.pkl' % hashlib.md5(path.encode("utf-8")).hexdigest())
1305388
def _get_video_ts_file_paths(dvd_path):
    

    video_ts_folder_path = join(dvd_path, "VIDEO_TS")

    video_ts_file_paths = []

    for video_ts_folder_content_name in listdir(video_ts_folder_path):
        video_ts_folder_content_path = join(video_ts_folder_path, video_ts_folder_content_name)

        if isfile(video_ts_folder_content_path):
            video_ts_file_paths.append(video_ts_folder_content_path)

    return sorted(video_ts_file_paths)
1012346
def get_video(self, node):
        
        video = Video()
        video.embed_code = self.get_embed_code(node)
        video.embed_type = self.get_embed_type(node)
        video.width = self.get_width(node)
        video.height = self.get_height(node)
        video.src = self.get_src(node)
        video.provider = self.get_provider(video.src)
        return video
137887
def mv_videos(path):
    
    count = 0
    for f in os.listdir(path):
        f = os.path.join(path, f)
        if os.path.isdir(f):
            for sf in os.listdir(f):
                sf = os.path.join(f, sf)
                if os.path.isfile(sf):
                    new_name = os.path.join(path, os.path.basename(sf))
                    try:
                        os.rename(sf, new_name)
                    except (WindowsError, OSError) as e:
                        print('mv {} happens error: {}'.format(sf, e))
                    else:
                        count += 1
                        print('mv {} to {}'.format(sf, new_name))
    return count
37977
def get_image_hashes(image_path, version=None, levels=None):
    '''
    '''
    if levels is None:
        levels = get_levels(version=version)
    hashes = dict()
    for level_name,level_filter in levels.items():
        hashes[level_name] = get_image_hash(image_path,
                                            level_filter=level_filter)
    return hashes
199797
def _get_video_info(self):
        
        if not hasattr(self, '_info_cache'):
            encoding_backend = get_backend()
            try:
                path = os.path.abspath(self.path)
            except AttributeError:
                path = os.path.abspath(self.name)
            self._info_cache = encoding_backend.get_media_info(path)
        return self._info_cache
721321
def hash(cls, path, digest=None, hasher=sha1):
    """"""
    if digest is None:
      digest = hasher()
    with open(path, 'rb') as fh:
      cls.update_hash(fh, digest)
    return digest.hexdigest()
302827
def generate_hash_comment(file_path):
    
    with open(file_path, 'rb') as fp:
        hexdigest = hashlib.sha1(fp.read().strip()).hexdigest()
    return "# SHA1:{0}\n".format(hexdigest)
122991
function getPathHash(path) {
            var hash = 0;
            var seed = 131;

            path.forEach(function (p) {
                hash = 0x7FFFFFFF & (hash * seed + getPointHash(p) + (p.onCurve ? 1 : 0));
            });

            return hash;
        }
304094
def video(video_type, video_mime, doc=None):
    """"""
    @on_valid(video_mime)
    def video_handler(data, **kwargs):
        if hasattr(data, 'read'):
            return data
        elif hasattr(data, 'save'):
            output = stream()
            data.save(output, format=video_type.upper())
            output.seek(0)
            return output
        elif hasattr(data, 'render'):
            return data.render()
        elif os.path.isfile(data):
            return open(data, 'rb')

    video_handler.__doc__ = doc or "{0} formatted video".format(video_type)
    return video_handler
1090473
def hash_file(filepath: str) -> str:
    """"""
    md5 = hashlib.md5()
    acc_hash(filepath, md5)
    return md5.hexdigest()
162053
def get_thumbnail(self, video_path, at_time=0.5):
        
        filename = os.path.basename(video_path)
        filename, __ = os.path.splitext(filename)
        _, image_path = tempfile.mkstemp(suffix='_{}.jpg'.format(filename))

        video_duration = self.get_media_info(video_path)['duration']
        if at_time > video_duration:
            raise exceptions.InvalidTimeError()
        thumbnail_time = at_time

        cmds = [self.ffmpeg_path, '-i', video_path, '-vframes', '1']
        cmds.extend(['-ss', str(thumbnail_time), '-y', image_path])

        process = self._spawn(cmds)
        self._check_returncode(process)

        if not os.path.getsize(image_path):
            # we somehow failed to generate thumbnail
            os.unlink(image_path)
            raise exceptions.InvalidTimeError()

        return image_path