Little Python program to download your images from your Steam gallery.

For each file it just downloads the images by its id and attempts to include some meta data about the image in a separate json file. For example:

{"Id": 1474149818, "Game": "Crypt of the NecroDancer", "Desc": "Bat out of hell", "Url": ""}

Code uses requests and has been tested with Python 3.7 on Windows.

import requests
import re
from pathlib import Path
import json
from typing import List

# Because I'm lazy and probably the only person to ever run this
STEAM_ID = 'Ardren'
DOWNLOAD_DIRECTORY = r'c:\Users\Matthewd\Dropbox\Screenshots-Steam'

def scan_gallery(username):
    file_ids = []
    page = 1

    while True:
        url = f"{username}/screenshots/?p={page}&sort=newestfirst&browsefilter=myfiles&view=grid&privacy=14"
        r = requests.get(url)

        matches = list(re.finditer(r'<a href="https://steamcommunity\.com/sharedfiles/filedetails/\?id=(\d+)"', r.text))

        if len(matches) == 0:
            print(f"No more files found on page {page}")

        print(f"Found {len(matches)} images on page {page}")

        for match in matches:

        page += 1

    return file_ids

def download_file_ids(base_directory: Path, file_ids: List[int]):
    for file_id in file_ids:

        download_filename = base_directory / f"{file_id}.jpeg"
        metadata_filename = base_directory / f"{file_id}.json"

        if download_filename.exists():
            print(f"Already downloaded {download_filename}")

        url = f"{file_id}"
        r = requests.get(url)

        match ='<a href="([^/]+/[^/]+/)" target=', r.text)
        if match is None:
            print(f"Unable to find image_src for file_id {file_id}")

        create_metadata(metadata_filename, file_id, r.text)

        with'wb+') as f:
            r = requests.get(
            bytes_written = f.write(r.content)
            print(f"Downloaded {bytes_written} bytes to {download_filename}")

def create_metadata(metadata_filename: Path, file_id: int, html_detail_contents: str):
    game_name_match ='<h3 class="ellipsis apphub_responsive_menu_title">([^<]+)</h3>', html_detail_contents)
    game_desc_match ='<textarea class="descField" name="description" id="description" class="dynInput" maxlength="140">([^<]*)</textarea>', html_detail_contents)
    image_url_match ='<a href="([^/]+/[^/]+/)" target="_blank">', html_detail_contents)

    data = {
        'Id': file_id,

    with'w+') as f:
        json.dump(data, f)

if __name__ == '__main__':
    download_file_ids(Path(DOWNLOAD_DIRECTORY), scan_gallery(STEAM_ID))