Last active
March 18, 2025 08:58
-
-
Save usrnk1/5c1b9f15dbb1a5d6e2deb31c99c56352 to your computer and use it in GitHub Desktop.
Get HDPI images from Dribbble data export .json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
# Load the JSON data | |
with open("export.json", "r") as f: | |
data = json.load(f) | |
# The structure might be different from what we expected | |
# Let's inspect the structure first | |
if "attachments" in data: | |
# Original expected structure | |
shots = data["attachments"][0]["content"]["shots"] | |
elif "shots" in data: | |
# Direct shots array | |
shots = data["shots"] | |
else: | |
# Try to find the shots in the JSON structure | |
if isinstance(data, dict) and "content" in data: | |
shots = data["content"].get("shots", []) | |
else: | |
# Look for shots in any structure | |
for key, value in data.items(): | |
if isinstance(value, dict) and "shots" in value: | |
shots = value["shots"] | |
break | |
else: | |
# If we still can't find it, print the structure and exit | |
print("Could not find shots in the JSON structure.") | |
print("JSON structure:", json.dumps(data, indent=2)[:500] + "...") | |
exit(1) | |
# Create a text file with all HDPI image URLs | |
with open("hdpi_images_urls.txt", "w") as f: | |
for shot in shots: | |
if "images" in shot and "hidpi" in shot["images"]: | |
f.write(f"{shot['images']['hidpi']}\n") | |
print(f"Found HDPI URL for shot {shot.get('id', 'unknown')}") | |
else: | |
print(f"No HDPI image for shot {shot.get('id', 'unknown')}") | |
print(f"Extracted URLs for {len(shots)} shots to hdpi_urls.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment