Пример #1
0
def cmd_depot_info(args):
    try:
        with init_clients(args) as (_, cdn, manifests):
            for i, manifest in enumerate(manifests, 1):
                print("App ID:", manifest.app_id)
                print("Depot ID:", manifest.metadata.depot_id)
                print("Depot Name:", manifest.name if manifest.name else 'Unnamed Depot')
                print("Manifest GID:", manifest.metadata.gid_manifest)
                print("Created On:", fmt_datetime(manifest.metadata.creation_time))
                print("Size:", fmt_size(manifest.metadata.cb_disk_original))
                print("Compressed Size:", fmt_size(manifest.metadata.cb_disk_compressed))
                nchunks = sum((len(file.chunks) for file in manifest.payload.mappings))
                unique_chunks = manifest.metadata.unique_chunks
                print("Unique/Total chunks:", unique_chunks, "/", nchunks, "({:.2f}%)".format(((1-(unique_chunks / nchunks))*100) if nchunks else 0))
                print("Encrypted Filenames:", repr(manifest.metadata.filenames_encrypted))
                print("Number of Files:", len(manifest.payload.mappings))

                if cdn:
                    depot_info = cdn.app_depots.get(manifest.app_id, {}).get(str(manifest.metadata.depot_id))

                    if depot_info:
                        print("Config:", depot_info.get('config', '{}'))
                        if 'dlcappid' in depot_info:
                            print("DLC AppID:", depot_info['dlcappid'])

                        print("Branch:", args.branch)
                        print("Open branches:", ', '.join(depot_info.get('manifests', {}).keys()))
                        print("Protected branches:", ', '.join(depot_info.get('encryptedmanifests', {}).keys()))

                if i != len(manifests):
                    print("-"*40)

    except SteamError as exp:
        LOG.error(str(exp))
        return 1  # error
Пример #2
0
def download_via_url(args, pubfile):
    sess = make_requests_session()
    fstream = sess.get(pubfile['file_url'], stream=True)
    total_size = int(pubfile['file_size'])

    relpath = sanitizerelpath(pubfile['filename'])

    if args.no_directories:
        relpath = os.path.basename(relpath)

    relpath = os.path.join(args.output, relpath)

    filepath = os.path.abspath(relpath)
    ensure_dir(filepath)

    with open(filepath, 'wb') as fp:
        if not args.no_progress and sys.stderr.isatty():
            pbar = tqdm(total=total_size, unit='B', unit_scale=True)
            gevent.spawn(pbar.gevent_refresh_loop)
        else:
            pbar = fake_tqdm()

        LOG.info('Downloading to {} ({})'.format(
            relpath,
            fmt_size(total_size),
        ))

        for chunk in iter(lambda: fstream.raw.read(1024**2), b''):
            fp.write(chunk)
            pbar.update(len(chunk))

        pbar.close()
Пример #3
0
    def download_to(self, target, no_make_dirs=False, pbar=None):
        relpath = sanitizerelpath(self.filename)

        if no_make_dirs:
            relpath = os.path.basename(relpath)

        relpath = os.path.join(target, relpath)

        filepath = os.path.abspath(relpath)
        ensure_dir(filepath)

        checksum = self.file_mapping.sha_content.hex()

        with open(filepath, 'wb') as fp:
            self._LOG.info('Downloading to {}  ({}, {})'.format(
                relpath, fmt_size(self.size), checksum))

            for chunk in self.chunks:
                data = self.manifest.cdn_client.get_chunk(
                    self.manifest.app_id,
                    self.manifest.depot_id,
                    chunk.sha.hex(),
                )

                fp.write(data)

                if pbar:
                    pbar.update(len(data))
Пример #4
0
def vpkfile_download_to(vpk_path, vpkfile, target, no_make_dirs, pbar):
    relpath = sanitizerelpath(vpkfile.filepath)

    if no_make_dirs:
        relpath = os.path.basename(relpath)

    relpath = os.path.join(
        target,  # output directory
        vpk_path[:-4],  # vpk path with extention (e.g. pak01_dir)
        relpath)  # vpk relative path

    filepath = os.path.abspath(relpath)
    ensure_dir(filepath)

    LOG.info("Downloading VPK file to {} ({}, crc32:{})".format(
        relpath,
        fmt_size(vpkfile.file_length),
        vpkfile.crc32,
    ))

    with open(filepath, 'wb') as fp:
        for chunk in iter(lambda: vpkfile.read(16384), b''):
            fp.write(chunk)

            if pbar:
                pbar.update(len(chunk))
Пример #5
0
    def download_to(self, target, no_make_dirs=False, pbar=None, verify=True):
        relpath = sanitizerelpath(self.filename)

        if no_make_dirs:
            relpath = os.path.basename(relpath)

        relpath = os.path.join(target, relpath)

        filepath = os.path.abspath(relpath)
        ensure_dir(filepath)

        checksum = self.file_mapping.sha_content.hex()

        # don't bother verifying if file doesn't already exist
        if not os.path.exists(filepath):
            verify = False

        with open(filepath, 'r+b' if verify else 'wb') as fp:
            fp.seek(0, 2)

            # pre-allocate space
            if fp.tell() != self.size:
                newsize = fp.truncate(self.size)

                if newsize != self.size:
                    raise SteamError("Failed allocating space for {}".format(filepath))

            self._LOG.info('{} {}  ({}, sha1:{})'.format(
                               'Verifying' if verify else 'Downloading',
                               relpath,
                               fmt_size(self.size),
                               checksum
                               ))

            fp.seek(0)
            for chunk in self.chunks:
                # verify chunk sha hash
                if verify:
                    cur_data = fp.read(chunk.cb_original)

                    if sha1_hash(cur_data) == chunk.sha:
                        if pbar:
                            pbar.update(chunk.cb_original)
                        continue

                    fp.seek(chunk.offset)  # rewind before write

                # download and write chunk
                data = self.manifest.cdn_client.get_chunk(
                                self.manifest.app_id,
                                self.manifest.depot_id,
                                chunk.sha.hex(),
                                )

                fp.write(data)

                if pbar:
                    pbar.update(chunk.cb_original)
Пример #6
0
def cmd_ugc_info(args):
    with init_client(args) as s:
        ugcdetails = s.get_ugc_details(args.ugc)
        user = s.get_user(ugcdetails.steamid_creator)

        print("File URL:", ugcdetails.url)
        print("Filename:", ugcdetails.filename)
        print("File size:", fmt_size(ugcdetails.file_size))
        print("SHA1:", ugcdetails.file_encoded_sha1)
        print("App ID:", ugcdetails.app_id)
        print("Creator:", user.name)
        print("Creator Profile:", SteamID(ugcdetails.steamid_creator).community_url)
Пример #7
0
        def make_row(item):
            size = int(item.get('file_size', 0))

            if item.get('file_url'):
                dl = 'URL'
            elif item.get('hcontent_file'):
                dl = 'SP'
            else:
                dl = ''

            return [
                item['publishedfileid'], item['title'].strip(),
                names.get(item['creator'], ''),
                str(item['consumer_appid']), item['app_name'],
                '{:,d}'.format(item['views']),
                '{:,d}'.format(item['favorited']),
                fmt_size(size) if size else '', dl,
                ', '.join(map(lambda x: x['tag'], item.get('tags', [])))
            ]