Skip to main content

remove two unused scripts

ID
42b9cd1
date
2023-05-13 22:06:07+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
658b66e
message
remove two unused scripts
changed files
2 files, 112 deletions

Changed files

get_albums_for_photo.swift (1023) → get_albums_for_photo.swift (0)

diff --git a/get_albums_for_photo.swift b/get_albums_for_photo.swift
deleted file mode 100644
index 737ac69..0000000
--- a/get_albums_for_photo.swift
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env swift
-// Print a list of album names that contain this photo.
-//
-// This takes one arguments: the UUID of the photo.
-//
-// == Usage ==
-//
-//    $ swift get_albums_for_photo.swift 9D28ABBE-79F6-402F-8750-8674840EDA3D
-//    ["Flagged"]
-//
-
-import Photos
-
-func getPhotoWith(uuid: String) -> PHAsset {
-  let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: [uuid], options: nil)
-
-  if fetchResult.count == 1 {
-    return fetchResult.firstObject!
-  } else {
-    fputs("Unable to find photo with ID: \(uuid).\n", stderr)
-    exit(1)
-  }
-}
-
-let arguments = CommandLine.arguments
-
-if arguments.count != 2 {
-  fputs("Usage: \(arguments[0]) PHOTO_ID\n", stderr)
-  exit(1)
-}
-
-let photo = getPhotoWith(uuid: arguments[1])
-
-let collections = PHAssetCollection.fetchAssetCollectionsContaining(
-  photo, with: .album, options: nil
-)
-
-var titles: [String] = []
-
-collections.enumerateObjects({ (album, index, stop) in
-  if (album.localizedTitle != nil) {
-    titles.append(album.localizedTitle!)
-  }
-})
-
-print(titles)

remove_image_from_album.swift (1691) → remove_image_from_album.swift (0)

diff --git a/remove_image_from_album.swift b/remove_image_from_album.swift
deleted file mode 100644
index 9b4db30..0000000
--- a/remove_image_from_album.swift
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env swift
-// Remove a photo from a photo album.
-//
-// This takes two arguments: the name of the album, and the UUID of
-// the photo in the album.  It assumes the album name is globally unique.
-//
-// == Usage ==
-//
-// Pass the album name as the first argument, and the UUID as the second:
-//
-//    $ remove_image_from_album "Flagged" "9D28ABBE-79F6-402F-8750-8674840EDA3D"
-//
-
-import Photos
-
-func getAlbumWith(name: String) -> PHAssetCollection {
-  let collections =
-    PHAssetCollection
-    .fetchAssetCollections(with: .album, subtype: .albumRegular, options: nil)
-
-  var thisAssetCollection: PHAssetCollection? = nil
-
-  collections.enumerateObjects({ (album, index, stop) in
-    let assetCollection = album
-
-    if assetCollection.localizedTitle == Optional(name) {
-      thisAssetCollection = assetCollection
-    }
-  })
-
-  if thisAssetCollection != nil {
-    return thisAssetCollection!
-  } else {
-    fputs("Unable to find album with name: \(name).\n", stderr)
-    exit(1)
-  }
-}
-
-func getPhotoWith(uuid: String) -> PHAsset {
-  let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: [uuid], options: nil)
-
-  if fetchResult.count == 1 {
-    return fetchResult.firstObject!
-  } else {
-    fputs("Unable to find photo with ID: \(uuid).\n", stderr)
-    exit(1)
-  }
-}
-
-let arguments = CommandLine.arguments
-
-if arguments.count != 2 {
-  fputs("Usage: \(arguments[0]) ALBUM_NAME PHOTO_ID\n", stderr)
-  exit(1)
-}
-
-let album = getAlbumWith(name: arguments[1])
-let photo = getPhotoWith(uuid: arguments[2])
-
-try PHPhotoLibrary.shared().performChangesAndWait {
-  let request =
-    PHAssetCollectionChangeRequest(for: album)
-
-  request!.removeAssets([photo] as NSFastEnumeration)
-}
-[]
\ No newline at end of file