Last active
February 9, 2025 14:28
-
-
Save dahool/7cdd66d17b1b26c885c298f0c324d88c to your computer and use it in GitHub Desktop.
Revisions
-
dahool revised this gist
Feb 9, 2025 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,6 @@ #!/usr/bin/python3 import requests import json API_KEY = '<YOUR_API_KEY>' BASE_URL = 'http://localhost:2283/api' # IMMICH URL -
dahool created this gist
Feb 9, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ #!/usr/bin/python3 import requests import os import json from datetime import datetime API_KEY = '<YOUR_API_KEY>' BASE_URL = 'http://localhost:2283/api' # IMMICH URL HEADERS = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'x-api-key': API_KEY } def do_get(url): response = requests.get(f'{BASE_URL}/{url}', headers=HEADERS) return response.json() def delete_assets(asset_list): ids = list(map(lambda item: item['id'], asset_list)) payload = json.dumps({ "force": False, "ids": ids }) requests.request("DELETE", f'{BASE_URL}/assets', headers=HEADERS, data=payload) print(f'Removed {len(ids)} assets') def list_dups(): print('Retrieving duplicates list...') response = do_get('duplicates') remove_assets_list = [] for dupItem in response: heic_file = False temp_asset = [] for asset in dupItem['assets']: if 'image/heic' != asset['originalMimeType']: temp_asset.append(asset) else: heic_file = True if heic_file and temp_asset: remove_assets_list.extend(temp_asset) if remove_assets_list: print('Review the following list and confirm to remove:\n') for item in remove_assets_list: print(item['originalFileName']) user_input = input('\nProceed? (y/n)') if user_input.lower() in ('y','yes'): delete_assets(remove_assets_list) else: print('Cancelled.') else: print('No duplicates found.') def main(): list_dups() if __name__ == "__main__": main()