cara commited on
Commit
b95c3a4
·
0 Parent(s):

Anonymize artist identifiers and remove copyrighted text and comply with Huggingface's request.

Browse files

- Replace author_slug, author_id and author_name with salted_hash
(SHA256 with slug+constant salt) for stable cross-post
grouping without revealing identity (~300k distinct artists)
- Replace title, content and bio with title_len, content_len and
bio_len character counts
- Remove usernames.txt (790k plaintext identifiers)
- Add catalog.db with cdn_url, like_count, comment_count, softwares, tags, raw_tags, status_code, is_deleted, follower_counter, following_counter and created_at preserved
- Add images (post_id, ord, cdn_url, is_cover, is_ai_auto_flagged, width, height) raw, no hash, 8.5M slides
- Keep master_fullres_8.5m_links.txt

Files changed (3) hide show
  1. .gitattributes +63 -0
  2. README.md +74 -0
  3. tool.py +470 -0
.gitattributes ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.avro filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
13
+ *.mds filter=lfs diff=lfs merge=lfs -text
14
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
+ *.model filter=lfs diff=lfs merge=lfs -text
16
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
17
+ *.npy filter=lfs diff=lfs merge=lfs -text
18
+ *.npz filter=lfs diff=lfs merge=lfs -text
19
+ *.onnx filter=lfs diff=lfs merge=lfs -text
20
+ *.ot filter=lfs diff=lfs merge=lfs -text
21
+ *.parquet filter=lfs diff=lfs merge=lfs -text
22
+ *.pb filter=lfs diff=lfs merge=lfs -text
23
+ *.pickle filter=lfs diff=lfs merge=lfs -text
24
+ *.pkl filter=lfs diff=lfs merge=lfs -text
25
+ *.pt filter=lfs diff=lfs merge=lfs -text
26
+ *.pth filter=lfs diff=lfs merge=lfs -text
27
+ *.rar filter=lfs diff=lfs merge=lfs -text
28
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
29
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
31
+ *.tar filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
39
+ # Audio files - uncompressed
40
+ *.pcm filter=lfs diff=lfs merge=lfs -text
41
+ *.sam filter=lfs diff=lfs merge=lfs -text
42
+ *.raw filter=lfs diff=lfs merge=lfs -text
43
+ # Audio files - compressed
44
+ *.aac filter=lfs diff=lfs merge=lfs -text
45
+ *.flac filter=lfs diff=lfs merge=lfs -text
46
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ *.ogg filter=lfs diff=lfs merge=lfs -text
48
+ *.wav filter=lfs diff=lfs merge=lfs -text
49
+ # Image files - uncompressed
50
+ *.bmp filter=lfs diff=lfs merge=lfs -text
51
+ *.gif filter=lfs diff=lfs merge=lfs -text
52
+ *.png filter=lfs diff=lfs merge=lfs -text
53
+ *.tiff filter=lfs diff=lfs merge=lfs -text
54
+ # Image files - compressed
55
+ *.jpg filter=lfs diff=lfs merge=lfs -text
56
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ *.webp filter=lfs diff=lfs merge=lfs -text
58
+ # Video files - compressed
59
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
60
+ *.webm filter=lfs diff=lfs merge=lfs -text
61
+ master_fullres_8.5m_links.txt filter=lfs diff=lfs merge=lfs -text
62
+ catalog.db filter=lfs diff=lfs merge=lfs -text
63
+ catalog_salted_hash.db filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CaraArchive Index Dataset
2
+
3
+ phamrhgids
4
+ igmutexyzb
5
+
6
+ ### 1) This is an Index Dataset, not an Image dataset
7
+ - This dataset contains **0 image data**.
8
+ - It only contains links to Cara App's CDN and metadata.
9
+ - HuggingFace may load some images in the preview because it detects the CDN links, however those images do not exist as data in this dataset, HF literally just loads them using your own connection as a preview.
10
+
11
+ ### 2) This dataset is *100% Complete*
12
+ - It includes **3.43 million posts** (and their thumbnails) from **790k users** to which belong **8.52 million artworks**, making a total of **~12 million image links**.
13
+ - Every user and every post on the platform (from 14/6/26 and before) is included here.
14
+ - Some people got the impression that not all of their posts are there because they searched their names in the CDN URLs, however *not all URLs include the name in them* (many use server timestamps and random hashes).
15
+
16
+ ---
17
+
18
+ ### How to Query the Database `tool.py` (make sure catalog.db is in the directory)
19
+
20
+ To see a clean summary overview of an account
21
+ ```bash
22
+ python tool.py --user <username>
23
+ ```
24
+
25
+ To see all artworks, software, metadata and creator for a specific post:
26
+ ```bash
27
+ python tool.py --post <Post URL or ID>
28
+ ```
29
+
30
+ To find the post and creator that an artwork belongs to:
31
+ ```bash
32
+ python tool.py --art <CDN URL or filename>
33
+ ```
34
+
35
+ ---
36
+
37
+ ### Database Structure (`catalog.db`)
38
+
39
+ The SQLite database contains 3 main tables:
40
+
41
+ #### `master_artworks_12m` (8,522,366 rows)
42
+ Contains all full-resolution master artwork uploads.
43
+ - `id`: Unique image ID (`<post_id>_slide_<number>`)
44
+ - `post_id`: Post ID this artwork belongs to
45
+ - `author_slug`: Username of the creator
46
+ - `slide_number`: Order in the multi-image gallery (1, 2, 3...)
47
+ - `title`: Post title
48
+ - `cdn_url`: Direct high-res CDN link
49
+ - `width`: Image width in pixels
50
+ - `height`: Image height in pixels
51
+ - `created_at`: Upload timestamp
52
+
53
+ #### `artworks` (3,431,475 rows)
54
+ Contains all posts and cover thumbnails.
55
+ - `post_id`: Unique post ID
56
+ - `author_slug`: Username of the creator
57
+ - `author_id`: User UUID
58
+ - `cdn_url`: Cover image / thumbnail link
59
+ - `created_at`: Creation timestamp
60
+
61
+ #### `post_metadata` (3,431,475 rows)
62
+ Contains all tags, software, descriptions, and audit statuses.
63
+ - `post_id`: Post ID
64
+ - `author_slug`: Username
65
+ - `author_name`: Display name
66
+ - `title`: Post title
67
+ - `content`: Description / lore text
68
+ - `softwares`: Software used (e.g. `["Blender", "Photoshop"]`)
69
+ - `tags`: Categories and tags (e.g. `["Illustration", "ConceptArt"]`)
70
+ - `status_code`: HTTP status (`200` = active, `404` = deleted post, `403` = private)
71
+ - `is_deleted`: `1` if post was removed, `0` if active
72
+ - `created_at`: Creation timestamp
73
+
74
+ ---
tool.py ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Cara Master Index Dataset Explorer CLI Tool
4
+ Zero External Dependencies (Runs on standard Python 3.7+ across Windows, macOS, Linux).
5
+ """
6
+
7
+ import sys
8
+ import os
9
+ import re
10
+ import json
11
+ import sqlite3
12
+ import argparse
13
+ from urllib.parse import urlparse
14
+ from collections import Counter
15
+
16
+ # Dynamic discovery of catalog.db (100% portable & anonymous)
17
+ DB_CANDIDATE_PATHS = [
18
+ "catalog.db",
19
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), "catalog.db"),
20
+ "../catalog.db",
21
+ ]
22
+
23
+ COMMON_PLACEHOLDERS = [
24
+ "username",
25
+ "<username>",
26
+ "your_username",
27
+ "yourname",
28
+ "your_name",
29
+ "handle",
30
+ "<handle>",
31
+ "artist",
32
+ "<artist>"
33
+ ]
34
+
35
+
36
+ def find_database() -> str:
37
+ """Auto-detects catalog.db location dynamically."""
38
+ for path in DB_CANDIDATE_PATHS:
39
+ if os.path.exists(path) and os.path.getsize(path) > 1000000:
40
+ return path
41
+ return None
42
+
43
+
44
+ def get_db_connection():
45
+ """Connects to catalog.db with clean error guidance if missing."""
46
+ db_path = find_database()
47
+ if not db_path:
48
+ print("\n" + "=" * 80)
49
+ print("❌ DATABASE NOT FOUND: 'catalog.db'")
50
+ print("=" * 80)
51
+ print("Please make sure 'catalog.db' is located in the same folder as this script!")
52
+ print(f"Current working directory: {os.getcwd()}")
53
+ print("=" * 80 + "\n")
54
+ sys.exit(1)
55
+
56
+ try:
57
+ conn = sqlite3.connect(db_path)
58
+ conn.row_factory = sqlite3.Row
59
+ return conn
60
+ except Exception as e:
61
+ print(f"\n❌ Error opening database: {e}\n")
62
+ sys.exit(1)
63
+
64
+
65
+ def sanitize_username(input_str: str) -> str:
66
+ """Cleans artist handle input."""
67
+ if not input_str:
68
+ return ""
69
+ cleaned = input_str.strip().lstrip("<").rstrip(">").strip()
70
+
71
+ if "cara.app" in cleaned or "http" in cleaned:
72
+ path = urlparse(cleaned).path.strip("/")
73
+ parts = path.split("/")
74
+ if len(parts) > 0 and parts[0] not in ["post", "search", "explore"]:
75
+ cleaned = parts[0]
76
+ elif len(parts) > 1 and parts[0] == "user":
77
+ cleaned = parts[1]
78
+
79
+ return cleaned.lstrip("@").strip()
80
+
81
+
82
+ def sanitize_post_id(input_str: str) -> str:
83
+ """Cleans post input and extracts UUID."""
84
+ if not input_str:
85
+ return ""
86
+ cleaned = input_str.strip().lstrip("<").rstrip(">").strip()
87
+
88
+ uuid_match = re.search(r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}', cleaned)
89
+ if uuid_match:
90
+ return uuid_match.group(0).lower()
91
+
92
+ if "/" in cleaned:
93
+ cleaned = cleaned.split("/")[-1].split("?")[0]
94
+ return cleaned.strip()
95
+
96
+
97
+ def sanitize_art_query(input_str: str) -> str:
98
+ """Extracts clean image hash / filename from CDN URL."""
99
+ if not input_str:
100
+ return ""
101
+ cleaned = input_str.strip().lstrip("<").rstrip(">").strip()
102
+ if "/" in cleaned:
103
+ cleaned = cleaned.split("/")[-1].split("?")[0]
104
+ return cleaned.strip()
105
+
106
+
107
+ def explore_user(username_raw: str, is_overview: bool = False):
108
+ """
109
+ Explores all posts and artworks by an artist handle.
110
+ - is_overview=True: Shows stats and clean list of posts without image URLs.
111
+ - is_overview=False: Shows full breakdown with every master slide and thumbnail URL.
112
+ """
113
+ username = sanitize_username(username_raw)
114
+
115
+ if username.lower() in [p.lower() for p in COMMON_PLACEHOLDERS]:
116
+ print("\n" + "=" * 80)
117
+ print(f"😅 I doubt your account is named '{username}' — did you forget to type your own name?")
118
+ print("Example: python tool.py --user mayonnaisejar1446 --overview")
119
+ print("=" * 80 + "\n")
120
+ return
121
+
122
+ if not username:
123
+ print("\n⚠️ Please specify an artist handle (e.g. 'python tool.py --user mayonnaisejar1446')\n")
124
+ return
125
+
126
+ conn = get_db_connection()
127
+ cur = conn.cursor()
128
+
129
+ # 1. Fetch Posts from artworks table
130
+ cur.execute("""
131
+ SELECT post_id, cdn_url as cover_url, created_at
132
+ FROM artworks
133
+ WHERE author_slug = ? COLLATE NOCASE
134
+ ORDER BY created_at DESC;
135
+ """, (username,))
136
+ posts = cur.fetchall()
137
+
138
+ if not posts:
139
+ cur.execute("SELECT DISTINCT author_slug FROM master_artworks_12m WHERE author_slug = ? COLLATE NOCASE;", (username,))
140
+ found_slug = cur.fetchone()
141
+ if not found_slug:
142
+ print("\n" + "=" * 80)
143
+ print(f"❌ Artist '@{username}' was not found in the database.")
144
+ print("Tip: Double-check the exact handle as it appears in the artist's Cara profile URL.")
145
+ print("=" * 80 + "\n")
146
+ conn.close()
147
+ return
148
+
149
+ # 2. Fetch Master Artworks
150
+ cur.execute("""
151
+ SELECT post_id, slide_number, title, cdn_url, width, height, created_at
152
+ FROM master_artworks_12m
153
+ WHERE author_slug = ? COLLATE NOCASE
154
+ ORDER BY post_id, slide_number;
155
+ """, (username,))
156
+ artworks = cur.fetchall()
157
+
158
+ # 3. Fetch Post Metadata
159
+ cur.execute("""
160
+ SELECT post_id, author_name, title, content, softwares, tags, created_at
161
+ FROM post_metadata
162
+ WHERE author_slug = ? COLLATE NOCASE;
163
+ """, (username,))
164
+ meta_rows = {r["post_id"]: r for r in cur.fetchall()}
165
+
166
+ post_artworks = {}
167
+ for art in artworks:
168
+ post_artworks.setdefault(art["post_id"], []).append(art)
169
+
170
+ # Aggregate stats
171
+ display_name = None
172
+ all_softwares = []
173
+ all_tags = []
174
+ all_dates = []
175
+
176
+ for pid, meta in meta_rows.items():
177
+ if meta["author_name"] and not display_name:
178
+ display_name = meta["author_name"]
179
+ if meta["created_at"]:
180
+ all_dates.append(meta["created_at"][:10])
181
+ try:
182
+ sw = json.loads(meta["softwares"])
183
+ if isinstance(sw, list):
184
+ all_softwares.extend(sw)
185
+ except Exception:
186
+ pass
187
+ try:
188
+ tg = json.loads(meta["tags"])
189
+ if isinstance(tg, list):
190
+ all_tags.extend(tg)
191
+ except Exception:
192
+ pass
193
+
194
+ top_software = [s for s, _ in Counter(all_softwares).most_common(5)]
195
+ top_tags = [t for t, _ in Counter(all_tags).most_common(8)]
196
+ date_range = f"{min(all_dates)} to {max(all_dates)}" if all_dates else "N/A"
197
+
198
+ name_header = f"@{username}" + (f" ({display_name})" if display_name else "")
199
+
200
+ print("\n" + "=" * 80)
201
+ print(f"👤 ARTIST SUMMARY: {name_header}")
202
+ print("=" * 80)
203
+ print(f"📊 Total Posts (Cover Thumbnails): {len(posts):,}")
204
+ print(f"🖼️ Total Master Artworks (Full-Res): {len(artworks):,}")
205
+ if top_software:
206
+ print(f"💻 Primary Software: {', '.join(top_software)}")
207
+ if top_tags:
208
+ print(f"🏷️ Top Tags: {', '.join(top_tags)}")
209
+ if all_dates:
210
+ print(f"📅 Activity Span: {date_range}")
211
+ print(f"🔗 Profile Link: https://cara.app/{username}")
212
+ print("=" * 80)
213
+
214
+ if is_overview:
215
+ print(f"📋 POSTS OVERVIEW ({len(posts)} posts): [Tip: Omit --overview to view all image links]")
216
+ print("-" * 80)
217
+ for idx, p in enumerate(posts, 1):
218
+ pid = p["post_id"]
219
+ arts = post_artworks.get(pid, [])
220
+ meta = meta_rows.get(pid)
221
+
222
+ title = "Untitled"
223
+ if meta and meta["title"] and meta["title"].strip():
224
+ title = meta["title"].strip()
225
+ elif arts and arts[0]["title"] and arts[0]["title"].strip():
226
+ title = arts[0]["title"].strip()
227
+
228
+ date_str = p["created_at"][:10] if p["created_at"] else "Unknown"
229
+ slides_info = f"{len(arts)} master slide(s)" if arts else "1 cover image"
230
+
231
+ print(f"[{idx}] 📌 {title} ({date_str}) | {slides_info}")
232
+ print(f" 🔗 https://cara.app/post/{pid}")
233
+
234
+ else:
235
+ print("📋 DETAILED POSTS & ARTWORK LINKS:")
236
+ print("-" * 80)
237
+ for idx, p in enumerate(posts, 1):
238
+ pid = p["post_id"]
239
+ arts = post_artworks.get(pid, [])
240
+ meta = meta_rows.get(pid)
241
+
242
+ title = "Untitled"
243
+ if meta and meta["title"] and meta["title"].strip():
244
+ title = meta["title"].strip()
245
+ elif arts and arts[0]["title"] and arts[0]["title"].strip():
246
+ title = arts[0]["title"].strip()
247
+
248
+ date_str = p["created_at"][:10] if p["created_at"] else "Unknown"
249
+
250
+ print(f"\n[{idx}] 📌 {title} ({date_str})")
251
+ print(f" 🔗 Post: https://cara.app/post/{pid}")
252
+ if p["cover_url"]:
253
+ print(f" 🖼️ Thumbnail: {p['cover_url']}")
254
+
255
+ if arts:
256
+ for a in arts:
257
+ res = f"[{a['width']}x{a['height']}]" if a['width'] and a['height'] else "[Full-Res]"
258
+ print(f" • Slide {a['slide_number']} {res}: {a['cdn_url']}")
259
+
260
+ print("\n" + "=" * 80 + "\n")
261
+ conn.close()
262
+
263
+
264
+ def explore_post(post_raw: str):
265
+ """Explores a post by URL or UUID."""
266
+ post_id = sanitize_post_id(post_raw)
267
+ if not post_id or post_id.lower() in ["post url", "<post url>", "post_id", "<post_id>"]:
268
+ print("\n" + "=" * 80)
269
+ print("😅 Did you copy '<Post url>' literally from the README?")
270
+ print("Example: python tool.py --post https://cara.app/post/5aac58cb-c33f-4622-9199-d6531e8f47f8")
271
+ print("=" * 80 + "\n")
272
+ return
273
+
274
+ conn = get_db_connection()
275
+ cur = conn.cursor()
276
+
277
+ cur.execute("""
278
+ SELECT id, post_id, author_slug, slide_number, title, cdn_url, width, height, created_at
279
+ FROM master_artworks_12m
280
+ WHERE post_id = ?
281
+ ORDER BY slide_number;
282
+ """, (post_id,))
283
+ slides = cur.fetchall()
284
+
285
+ cur.execute("SELECT cdn_url FROM artworks WHERE post_id = ?;", (post_id,))
286
+ cover_row = cur.fetchone()
287
+ cover_url = cover_row["cdn_url"] if cover_row else None
288
+
289
+ if not slides and not cover_url:
290
+ print("\n" + "=" * 80)
291
+ print(f"❌ Post ID '{post_id}' was not found in the master catalog.")
292
+ print("=" * 80 + "\n")
293
+ conn.close()
294
+ return
295
+
296
+ cur.execute("SELECT * FROM post_metadata WHERE post_id = ?;", (post_id,))
297
+ meta = cur.fetchone()
298
+
299
+ author = slides[0]["author_slug"] if slides else (meta["author_slug"] if meta else "unknown")
300
+ title = (slides[0]["title"] if slides and slides[0]["title"] else None) or (meta["title"] if meta and meta["title"] else "Untitled")
301
+
302
+ print("\n" + "=" * 80)
303
+ print(f"📌 POST ID: {post_id}")
304
+ print(f"👤 ARTIST: @{author} (https://cara.app/{author})")
305
+ print(f"🎨 TITLE: {title}")
306
+ print(f"🔗 WEB LINK: https://cara.app/post/{post_id}")
307
+
308
+ if cover_url:
309
+ print(f"🖼️ THUMBNAIL: {cover_url}")
310
+
311
+ if meta:
312
+ try:
313
+ tags = json.loads(meta["tags"])
314
+ softwares = json.loads(meta["softwares"])
315
+ if softwares:
316
+ print(f"💻 SOFTWARE: {softwares}")
317
+ if tags:
318
+ print(f"🏷️ TAGS: {tags}")
319
+ if meta["content"]:
320
+ print(f"\n📝 POST BODY:\n{meta['content'].strip()}")
321
+ except Exception:
322
+ pass
323
+
324
+ if slides:
325
+ print("\n🖼️ MASTER ARTWORKS (" + str(len(slides)) + " slide(s)):")
326
+ print("-" * 80)
327
+ for s in slides:
328
+ res = f"{s['width']}x{s['height']}" if s['width'] and s['height'] else "Full-Res"
329
+ print(f" • Slide {s['slide_number']} [{res}]: {s['cdn_url']}")
330
+ print("=" * 80 + "\n")
331
+ conn.close()
332
+
333
+
334
+ def explore_artwork(art_raw: str):
335
+ """Reverse traces an artwork CDN link or image filename back to its post and creator."""
336
+ raw_clean = art_raw.strip().lstrip("<").rstrip(">").strip()
337
+ art_hash = sanitize_art_query(raw_clean)
338
+
339
+ if not art_hash or art_hash.lower() in ["cdn url", "<cdn url>", "cdn_url", "<cdn_url>"]:
340
+ print("\n" + "=" * 80)
341
+ print("😅 Did you copy '<CDN url>' literally from the README?")
342
+ print("Example: python tool.py --art otawrou-8L8tjCPtnNl1TStnB3Psu-0000-00091.gif")
343
+ print("=" * 80 + "\n")
344
+ return
345
+
346
+ conn = get_db_connection()
347
+ cur = conn.cursor()
348
+
349
+ # Fast Path 1: Exact URL match
350
+ cur.execute("SELECT post_id, author_slug, slide_number, title, cdn_url, width, height, created_at FROM master_artworks_12m WHERE cdn_url = ?;", (raw_clean,))
351
+ match = cur.fetchone()
352
+
353
+ # Fast Path 2: Exact Filename match
354
+ if not match:
355
+ cur.execute("SELECT post_id, author_slug, slide_number, title, cdn_url, width, height, created_at FROM master_artworks_12m WHERE cdn_url LIKE ?;", (f"https://cdn.cara.app/production/posts/%/{art_hash}",))
356
+ match = cur.fetchone()
357
+
358
+ # Fallback Path 3: Substring search
359
+ if not match:
360
+ cur.execute("SELECT post_id, author_slug, slide_number, title, cdn_url, width, height, created_at FROM master_artworks_12m WHERE cdn_url LIKE ?;", (f"%{art_hash}%",))
361
+ match = cur.fetchone()
362
+
363
+ # Fallback Path 4: Check cover thumbnails in artworks
364
+ if not match:
365
+ cur.execute("SELECT post_id, author_slug, cdn_url, created_at FROM artworks WHERE cdn_url LIKE ?;", (f"%{art_hash}%",))
366
+ cover_match = cur.fetchone()
367
+ if cover_match:
368
+ print("\n" + "=" * 80)
369
+ print("🔍 REVERSE ARTWORK TRACER (Feed Cover Thumbnail)")
370
+ print("=" * 80)
371
+ print(f"🖼️ Thumbnail: {cover_match['cdn_url']}")
372
+ print(f"📌 Post ID: {cover_match['post_id']}")
373
+ print(f"👤 Creator: @{cover_match['author_slug']} (https://cara.app/{cover_match['author_slug']})")
374
+ print(f"🔗 Direct Web: https://cara.app/post/{cover_match['post_id']}")
375
+ print("=" * 80 + "\n")
376
+ conn.close()
377
+ return
378
+
379
+ if not match:
380
+ print("\n" + "=" * 80)
381
+ print(f"❌ Artwork image '{art_hash}' was not found in the database.")
382
+ print("=" * 80 + "\n")
383
+ conn.close()
384
+ return
385
+
386
+ pid = match["post_id"]
387
+ cur.execute("SELECT * FROM post_metadata WHERE post_id = ?;", (pid,))
388
+ meta = cur.fetchone()
389
+
390
+ print("\n" + "=" * 80)
391
+ print("🔍 REVERSE ARTWORK TRACER (Master Full-Res Artwork)")
392
+ print("=" * 80)
393
+ print(f"🖼️ Image Link: {match['cdn_url']}")
394
+ print(f"📐 Resolution: {match['width']}x{match['height']} (Slide {match['slide_number']})")
395
+ print(f"📌 Post ID: {match['post_id']}")
396
+ print(f"👤 Creator: @{match['author_slug']} (https://cara.app/{match['author_slug']})")
397
+ print(f"🎨 Title: {match['title'] or 'Untitled'}")
398
+ print(f"📅 Upload Date: {match['created_at']}")
399
+ print(f"🔗 Direct Web: https://cara.app/post/{match['post_id']}")
400
+
401
+ if meta:
402
+ try:
403
+ tags = json.loads(meta["tags"])
404
+ if tags:
405
+ print(f"🏷️ Post Tags: {tags[:6]}")
406
+ except Exception:
407
+ pass
408
+
409
+ print("=" * 80 + "\n")
410
+ conn.close()
411
+
412
+
413
+ def interactive_menu():
414
+ """Interactive CLI menu when run with zero arguments."""
415
+ print("\n" + "=" * 80)
416
+ print("🎨 CARA MASTER INDEX DATASET EXPLORER")
417
+ print("=" * 80)
418
+ print("Choose an option:")
419
+ print(" 1. Look up an Artist / Username (Summary Overview)")
420
+ print(" 2. Look up an Artist / Username (Full Artwork Links)")
421
+ print(" 3. Look up a Post Link / Post UUID")
422
+ print(" 4. Reverse Trace an Artwork CDN Image URL")
423
+ print(" 5. Exit")
424
+ print("=" * 80)
425
+
426
+ choice = input("\nEnter choice (1-5): ").strip()
427
+ if choice == "1":
428
+ user_input = input("Enter username or profile URL: ").strip()
429
+ explore_user(user_input, is_overview=True)
430
+ elif choice == "2":
431
+ user_input = input("Enter username or profile URL: ").strip()
432
+ explore_user(user_input, is_overview=False)
433
+ elif choice == "3":
434
+ post_input = input("Enter post URL or UUID: ").strip()
435
+ explore_post(post_input)
436
+ elif choice == "4":
437
+ art_input = input("Enter CDN URL or image filename: ").strip()
438
+ explore_artwork(art_input)
439
+ elif choice == "5" or choice.lower() in ["q", "exit", "quit"]:
440
+ print("Goodbye!")
441
+ sys.exit(0)
442
+ else:
443
+ print("Invalid choice. Exiting.")
444
+
445
+
446
+ def main():
447
+ parser = argparse.ArgumentParser(description="Cara Master Index Dataset CLI Tool")
448
+ parser.add_argument("--user", help="Query creator handle (e.g. --user alex123)")
449
+ parser.add_argument("--overview", action="store_true", help="Clean summary overview (disables showing image links)")
450
+ parser.add_argument("--post", help="Query post metadata, lore & gallery (e.g. --post https://cara.app/post/...)")
451
+ parser.add_argument("--art", help="Reverse trace an image CDN link back to creator & post")
452
+
453
+ if len(sys.argv) == 1:
454
+ interactive_menu()
455
+ return
456
+
457
+ args = parser.parse_args()
458
+
459
+ if args.user:
460
+ explore_user(args.user, is_overview=args.overview)
461
+ elif args.post:
462
+ explore_post(args.post)
463
+ elif args.art:
464
+ explore_artwork(args.art)
465
+ else:
466
+ interactive_menu()
467
+
468
+
469
+ if __name__ == "__main__":
470
+ main()