This is the internal code reference for gphotos_sync
- class gphotos_sync.DatabaseMedia.DatabaseMedia(_id: str = '', _uid: str = '', _url: str = '', _relative_folder: Path = PosixPath('.'), _filename: str = '', _orig_name: str = '', _duplicate_number: int = 0, _size: int = 0, _mime_type: str = '', _description: str = '', _date: datetime = datetime.datetime(1900, 1, 1, 0, 0), _create_date: datetime = datetime.datetime(1900, 1, 1, 0, 0), _downloaded: bool = False, _location: str = '')
A Class for reading and writing BaseMedia objects to and from database tables
The standard BaseMedia attributes are represented here. This dumb class is used for representing any MediaBase derived class that has been read out of the Database.
remote identifier from Google Photos
the ‘product URL’ which takes you to the Web view for this file
root relative path to file
as above minus any duplicate number suffix
which instance if > 1 file has same orig_name
files size on disk
string representation of file type
true if previously downloaded to disk
- class gphotos_sync.GooglePhotosDownload.GooglePhotosDownload(api: RestClient, root_folder: Path, db: LocalData, settings: Settings)
A Class for managing the indexing and download of Google Photos
api – object representing the Google REST API
root_folder – path to the root of local file synchronization
db – local database for indexing
settings – further arguments
here we batch up our requests to get base url for downloading media. This avoids the overhead of one REST call per file. A REST call takes longer than downloading an image
- download_batch(batch: Mapping[str, DatabaseMedia])
Downloads a batch of media items collected in download_photo_media.
A fresh ‘base_url’ is required since they have limited lifespan and these are obtained by a single call to the service function mediaItems.batchGet.
- download_file(media_item: DatabaseMedia, media_json: dict)
farms a single media download off to the thread pool.
Uses a dictionary of Futures -> mediaItem to track downloads that are currently scheduled/running. When a Future is done it calls do_download_complete to remove the Future from the dictionary and complete processing of the media item.
- do_download_file(base_url: str, media_item: DatabaseMedia)
Runs in a process pool and does a download of a single media item.
- do_download_complete(futures_list: Mapping[Future, DatabaseMedia] | List[Future])
runs in the main thread and completes processing of a media item once (multi threaded) do_download has completed