@masscode could you try please this script
import photos
import console
from objc_util import *
NSBundle.bundleWithPath_('/System/Library/Frameworks/Photos.framework').load()
PHAssetCollection = ObjCClass('PHAssetCollection')
PHAsset = ObjCClass('PHAsset')
PHFetchOptions = ObjCClass('PHFetchOptions').alloc()
def main():
console.clear()
assets = photos.get_assets(media_type='image', include_hidden=True)
for asset in assets:
if asset.hidden:
ao = ObjCInstance(asset)
fn = str(ao.valueForKey_('filename'))
#print(ao)
PHAssetCollectionType = 1 # album
fetchresult = PHAssetCollection.fetchAssetCollectionsContainingAsset_withType_options_(ao, PHAssetCollectionType,None)
n_albums = fetchresult.count()
for i in range(n_albums):
coll = fetchresult.objectAtIndex_(i)
album = str(coll.localizedTitle())
print(f" hidden {fn} belongs to album {album}")
main()
Thus your request is
import photos
import console
from objc_util import *
NSBundle.bundleWithPath_('/System/Library/Frameworks/Photos.framework').load()
PHAssetCollection = ObjCClass('PHAssetCollection')
PHAsset = ObjCClass('PHAsset')
PHFetchOptions = ObjCClass('PHFetchOptions').alloc()
def main():
console.clear()
album_assets = []
for album in photos.get_albums():
if album.title == "Test":
album_assets.append(album.assets)
break
print(len(album_assets))
assets = photos.get_assets(media_type='image', include_hidden=True)
for asset in assets:
if asset.hidden:
ao = ObjCInstance(asset)
fn = str(ao.valueForKey_('filename'))
#print(ao)
PHAssetCollectionType = 1 # album
fetchresult = PHAssetCollection.fetchAssetCollectionsContainingAsset_withType_options_(ao, PHAssetCollectionType,None)
n_albums = fetchresult.count()
for i in range(n_albums):
coll = fetchresult.objectAtIndex_(i)
album = str(coll.localizedTitle())
print(f" hidden {fn} belongs to album {album}")
if album == 'Test':
album_assets.append(asset)
print(len(album_assets))
main()