API
gphotos_sync
This is the internal code reference for gphotos_sync
gphotos_sync.__main__
gphotos_sync.BaseMedia
gphotos_sync.DatabaseMedia
- 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 = '', _is_shared_album: bool = False)[source]
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.
- _id
remote identifier from Google Photos
- _url
the ‘product URL’ which takes you to the Web view for this file
- _relative_folder
root relative path to file
- _filename
local filename
- _orig_name
as above minus any duplicate number suffix
- _duplicate_number
which instance if > 1 file has same orig_name
- _size
files size on disk
- _mime_type
string representation of file type
- _date
modification date
- _create_date
creation date
- _description
- _downloaded
true if previously downloaded to disk
gphotos_sync.GooglePhotosMedia
gphotos_sync.GoogleAlbumMedia
gphotos_sync.LocalFilesMedia
gphotos_sync.GooglePhotosDownload
- class gphotos_sync.GooglePhotosDownload.GooglePhotosDownload(api: RestClient, root_folder: Path, db: LocalData, settings: Settings)[source]
A Class for managing the indexing and download of Google Photos
- Parameters:
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
- download_photo_media()[source]
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])[source]
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)[source]
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)[source]
Runs in a process pool and does a download of a single media item.
- do_download_complete(futures_list: Mapping[Future, DatabaseMedia] | List[Future])[source]
runs in the main thread and completes processing of a media item once (multi threaded) do_download has completed
- find_bad_items(batch: Mapping[str, DatabaseMedia])[source]
a batch get failed. Now do all of its contents as individual gets so we can work out which ID(s) cause the failure