Last active
March 9, 2019 17:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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