11#!/usr/bin/env python3
2- """CLI tool for uploading images/videos to GCS with short transitapp.com URLs ."""
2+ """CLI tool for uploading images/videos to GCS."""
33
44import argparse
55import base64
1717import uuid
1818from pathlib import Path
1919
20- VERSION = "1.3 .0"
20+ VERSION = "1.4 .0"
2121CONFIG_DIR = Path .home () / ".config" / "image-upload-transit"
2222
2323IMAGE_EXTENSIONS = {".jpg" , ".jpeg" , ".png" , ".gif" , ".webp" , ".avif" , ".heic" , ".bmp" , ".tiff" , ".tif" , ".svg" }
2828MAX_VIDEO_SIZE = 100 * 1024 * 1024 # 100 MB
2929
3030BUCKET = "image-upload-cli-tool"
31- BASE_URL = "https://img.transitapp .com"
31+ BASE_URL = f "https://storage.googleapis .com/ { BUCKET } "
3232
33+ OP_ACCOUNT = "transit.1password.com"
3334OP_VAULT = "Shared"
3435OP_ITEM = "image-upload-transit Service Account (Production)"
3536
@@ -57,7 +58,7 @@ def check_op_cli() -> None:
5758 except subprocess .CalledProcessError :
5859 raise CredentialsError ("1Password CLI check failed" )
5960
60- result = subprocess .run (["op" , "account" , "list" ], capture_output = True )
61+ result = subprocess .run (["op" , "account" , "list" , "--account" , OP_ACCOUNT ], capture_output = True )
6162 if result .returncode != 0 or not result .stdout .strip ():
6263 raise CredentialsError ("Not signed in to 1Password. Run: op signin" )
6364
@@ -73,7 +74,7 @@ def get_credentials(force_refresh: bool = False) -> dict:
7374 check_op_cli ()
7475
7576 result = subprocess .run (
76- ["op" , "item" , "get" , OP_ITEM , "--vault" , OP_VAULT , "--format" , "json" ],
77+ ["op" , "item" , "get" , OP_ITEM , "--vault" , OP_VAULT , "--account" , OP_ACCOUNT , "-- format" , "json" ],
7778 capture_output = True ,
7879 text = True ,
7980 )
@@ -227,7 +228,7 @@ def upload_file(filepath: str, credentials: dict) -> str:
227228def main () -> int :
228229 """Main entry point."""
229230 parser = argparse .ArgumentParser (
230- description = "Upload images/videos to GCS with short transitapp.com URLs " ,
231+ description = "Upload images/videos to GCS" ,
231232 prog = "image-upload-transit" ,
232233 epilog = """
233234Examples:
@@ -236,7 +237,7 @@ def main() -> int:
236237 %(prog)s --json photo.jpg Output result as JSON (for scripting/agents)
237238
238239JSON Output Format (--json):
239- Success: {"file": "image.png", "url": "https://img.transitapp .com/abc123.png", "success": true}
240+ Success: {"file": "image.png", "url": "https://storage.googleapis .com/image-upload-cli-tool /abc123.png", "success": true}
240241 Error: {"file": "bad.txt", "error": "Unsupported file type", "success": false}
241242 Multiple files produce one JSON object per line (JSONL format).
242243
0 commit comments