Skip to content

Instantly share code, notes, and snippets.

@deeuu
Last active March 9, 2019 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeuu/740cab4ac24fc3431d35c8d66c182f0d to your computer and use it in GitHub Desktop.
Save deeuu/740cab4ac24fc3431d35c8d66c182f0d to your computer and use it in GitHub Desktop.
Xonsh script wrapper around upload-gphotos to upload all personal image/video folders to google-photo albums
# see https://github.com/3846masa/upload-gphotos
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument('--folder',
help='Folder of images. Can contain subdirectories')
parser.add_argument('--username', help='Your Google Photos username')
parser.add_argument('--password', help='Your Google Photos password')
parser.add_argument('--ftypes', nargs='+',
help='Only upload file of this filetype(s)',
default=['jpg', 'png', 'mov'],
required=False)
args = parser.parse_args()
ftypes = tuple([_.upper() for _ in args.ftypes] + args.ftypes)
for dirpath, dirs, files in os.walk(os.path.abspath(args.folder)):
album_name = os.path.basename(dirpath)
if album_name.startswith('.'):
continue
files = [os.path.join(dirpath, f) for f in files if f.endswith(ftypes)]
if len(files):
print('Processing ', dirpath)
upload-gphotos @(files) @(['--username', args.username, '--password', args.password, '--album', album_name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment