Example #1
0
    def _get_collection_type(self, path):
        cookie_len = len(CollectionInfo.SIGNATURE)

        with open(path, 'rb') as f:
            data = f.read(cookie_len)

            if CollectionInfo.is_valid_signature(data):
                return CollectionInfoTypes.BYTESTAG

            if path.endswith('.torrent'):
                f.seek(0)

                if BitTorrentInfoFile.is_valid_signature(f.read(1024)):
                    return CollectionInfoTypes.BITTORRENT