Last active
March 29, 2024 10:57
-
-
Save fulcrum6378/d692b65dbfb4d9de4523a346d73a1284 to your computer and use it in GitHub Desktop.
Groups a collection of photos based on their DeviantArt authors, specialised for Zoey's gallery.
This file contains 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 | |
import os | |
from typing import Dict, List | |
path = 'D:\\Gallery\\ZOEY' | |
cache = 'toolbox\\zoey_gallery.json' | |
deviantArt: Dict[str, List[str]] = {} | |
daCount = 0 | |
others = [] | |
for f in os.listdir(path): | |
if f in ['desktop.ini']: | |
continue | |
try: | |
byx = f.rindex('_by_') | |
ending = f[(byx + 4):] | |
acc = ending[:ending.rindex('_')] | |
if acc not in deviantArt: | |
deviantArt[acc] = list() | |
deviantArt[acc].append(f) | |
daCount += 1 | |
except ValueError: | |
others.append(f) | |
continue | |
deviantArt = dict(sorted(deviantArt.items(), key=lambda item: len(item[1])).__reversed__()) | |
if not os.path.isfile(cache): | |
open(cache, 'w').write(json.dumps(deviantArt, indent=4)) | |
print('Non-DeviantArt files:', json.dumps(others, indent=2) + '\n') | |
print(daCount, 'deviants from', len(deviantArt.keys()), 'people:\n') | |
for acc, files in deviantArt.items(): | |
print(str(len(files)) + ':', 'https://www.deviantart.com/' + acc + '/gallery?q=zoey') | |
for f in files: | |
print(' ' + f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment