Spaces:
Sleeping
Sleeping
Download lib/db_service.py from thesis-sd3a/digital-art-api: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/thesis-sd3a/digital-art-api/resolve/main/lib/db_service.py
- Command line
-
hf download hf://spaces/thesis-sd3a/digital-art-api/lib/db_service.py
-
curl -L -o db_service.py https://huggingface.co/spaces/thesis-sd3a/digital-art-api/resolve/main/lib/db_service.py
1.04 kB
| import os | |
| from supabase import create_client | |
| SUPABASE_URL = os.getenv("SUPABASE_URL") | |
| SUPABASE_KEY = os.getenv("SUPABASE_ANON_KEY") | |
| supabase = create_client(SUPABASE_URL, SUPABASE_KEY) | |
| def get_all_artwork_hashes(): | |
| """ | |
| Fetch all plagiarism hashes from registered_arts | |
| and prepare them for similarity scanning. | |
| """ | |
| response = ( | |
| supabase | |
| .table("registered_arts") | |
| .select("id, plagiarism_hashes, c_secure_url") | |
| .not_.is_("plagiarism_hashes", "null") | |
| .neq("status", "removed") | |
| .execute() | |
| ) | |
| artworks = [] | |
| for row in response.data: | |
| try: | |
| hashes = row["plagiarism_hashes"] | |
| if hashes is None: | |
| continue | |
| artworks.append({ | |
| "id": row["id"], | |
| "perceptual_hash": hashes, | |
| "c_secure_url": row["c_secure_url"] | |
| }) | |
| except Exception as e: | |
| print("Error parsing artwork:", e) | |
| print("Database Fetching Done!") | |
| return artworks |