title: Mac OS photos : programatic access to the recently deleted photos folder?
body: <p>In order to do a deep learning model auto classifying my pictures, I would like to make a copy of all my deleted photos in Mac's photo (unfortunately the &quot;recover&quot; photo put it back on the main photo album, so I loose the fact it was deleted at first).</p>
  <p>How can I access the deleted photos ?
  Having a look on the &quot;photos&quot; package, the data organisation is quite obscure.</p>
  <p>At the same time : how can I access the &quot;favorite&quot; tag on each photo (my model should classify in favorite/deleted/not deleted).</p>
  <p>I am rather pythonista at first.</p>
  <p>Thx,
  Romain.</p>
  <h2>EDIT #1</h2>
  <p>I found this package : <a href="https://pypi.org/project/osxphotos/#osxphotos" rel="nofollow noreferrer">https://pypi.org/project/osxphotos/#osxphotos</a>
  which should do the trick, but I've got an error :</p>
  <pre><code>import osxphotos
  path = &quot;/Users/romain/Pictures/Photothèque.photoslibrary/&quot;
  photosdb = osxphotos.PhotosDB(path)
  </code></pre>
  <p>Gives :</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  /Applications/anaconda3/envs/python38/lib/python3.8/site-packages/osxphotos/photosdb/photosdb.py in _process_database4(self)
      798             try:
  --&gt; 799                 self._dbphotos[uuid][&quot;imageDate&quot;] = datetime.fromtimestamp(row[5] + td)
      800             except ValueError:
  
  ValueError: year 0 is out of range
  
  During handling of the above exception, another exception occurred:
  
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-8-42282d7447c7&gt; in &lt;module&gt;
        1 import osxphotos
        2 path = &quot;/Users/romain/Pictures/Photothèque.photoslibrary/&quot;
  ----&gt; 3 photosdb = osxphotos.PhotosDB(path)
  
  /Applications/anaconda3/envs/python38/lib/python3.8/site-packages/osxphotos/photosdb/photosdb.py in __init__(self, dbfile, *dbfile_)
      287 
      288         if int(self._db_version) &lt;= int(_PHOTOS_4_VERSION):
  --&gt; 289             self._process_database4()
      290         else:
      291             self._process_database5()
  
  /Applications/anaconda3/envs/python38/lib/python3.8/site-packages/osxphotos/photosdb/photosdb.py in _process_database4(self)
      799                 self._dbphotos[uuid][&quot;imageDate&quot;] = datetime.fromtimestamp(row[5] + td)
      800             except ValueError:
  --&gt; 801                 self._dbphotos[uuid][&quot;imageDate&quot;] = datetime.date(1970, 1, 1)
      802 
      803             self._dbphotos[uuid][&quot;mainRating&quot;] = row[6]
  
  TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object
  </code></pre>
  <h1>Edit#2</h1>
  <p>I modified the file  :</p>
  <pre><code>#self._dbphotos[uuid][&quot;imageDate&quot;] = datetime.date(1970, 1, 1)
  self._dbphotos[uuid][&quot;imageDate&quot;] = datetime(1970, 1, 1)
  </code></pre>