IMPORTANT NOTICE: as of 2018/09/01 this project is going to be deprecated, since Google now released an official google photos API.
The new projects built on top of the Google photos API are:
https://github.com/nmrshll/gphotos-uploader-cli for a command-line uploader
https://github.com/nmrshll/google-photos-api-client-go for a go client libraryThe new projects currently count against yout storage quota, once the client side compression is implemented this project will be deprecated.
Google Photos does not have a desktop uploader for Linux, neither an API to upload a photo programmatically. (now there is an Official Google Photos API).
G Photos Uploader lets you upload photos from Linux (and, in theory, any OS for which you can compile a Go program) specifying the file name or watching a directory for changes. Furthermore, the project can also be used as a library that you can include in other Go programs.
G Photos Uploader is an unofficial tool, I (and any possible contributor) don't guarantee any result. Any security or other kind of issues are at your own risk.
To use the tool you need to install Go and Git (used by go get
to download the dependencies). If you will use the authentication wizard you will also need a WebDriver.
go get github.com/muyouming/gphotosuploader
To launch the tool you have two options:
- Add the $GOPATH/bin folder to your path: doing this you can start the program just typing
gphotosuploader
(if you use this method and don't specify the auth.json and uploaded.txt file paths, these files will be created in the current working directory); - Enter the project folder and use
go run main.go
;
To use G Photos Uploader as a standalone tool you need to be authenticated. Authentication is implemented with a JSON file that contains your cookies and user ID.
Every time you run the tool, it will check for the auth file. If the file is not found or the cookies seem to be expired, the tool will ask you if you want to run a wizard to get new cookies.
The authentication wizard uses the WebDrivers protocol, which is usually used to perform automation tests, that allows G Photos Uploader to control a browser and read the cookies from it. To use the WebDrivers Protocol you need to install a web driver (e.g. chromedriver):
- On Ubuntu
sudo apt-get install chromium-chromedriver
# Create a link to launch the driver just typing 'chromedriver'
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
# Then launch
chromedriver
- On macOS Install Homebrew and then:
brew install chromedriver
# Then launch
chromedriver
- On Windows:
- Download latest Chrome Web Driver from Google;
- Copy chromedriver.exe in the path (
C:\WINDOWS
for example); - Then launch it with a command prompt or
Win key + R
thenchromedriver.exe
;
Note: If you are running G Photos Uploader on a headless machine, you can run chromedriver on a separate machine as such:
chromedriver --whitelisted-ips="HEADLESS_MACHINE_IP"
When the Driver starts it will print the address at which it is listening.
Once you enter the name of the browser (refer to browserName here) and the address of the web driver in the tool, a new browser window will appear with the Google Photos Login page.
Then you can login with your account just like you always do. When you're logged in the tool will read the cookies from the browser, save them into the auth file and close the browser window.
You can now stop the web driver server.
You can also get the authentication file using a Chrome extension. You can read more about it here.
Once you have the auth file, you're ready to go. For example, to upload a file named image.png:
gphotosuploader --upload ./image.png
Or to watch a directory:
gphotosuploader --watch path/to/photos --maxConcurrent 4
You can even upload all the photos of a directory and then start to watch another one:
gphotosuploader --upload /path/to/old/photos --upload /downloads/cat.png --watch path/to/new/photos
If you also want to add your photos to a specific existing album you can use the 'album' argument:
gphotosuploader --album albumId --upload ./image.png
Where the albumId is the string that you see in the url when you open the album in the Google Photos Web App (something like: https://photos.google.com/u/2/album/album_id)
If you also want create a new album to add your photos, you can use the 'albumName' argument:
gphotosuploader --albumName foo --upload ./image.png
The tool creates a file (default name: uploaded.txt) which is a list of uploaded files, which will not be re-uploaded. You can specify your own file using the uploadedList argument. To see all the available arguments, use --help.
You can read a simple example here or get the documentation here.
if you want to continue the development of this tool/library, execute first the following script:
githooks/create-links
This will links the hooks used to handle the version of the tool.