google-photo-to-vcard/google_photo_to_vcard/download_photos.py

24 lines
674 B
Python
Raw Normal View History

2018-04-04 23:55:09 +00:00
import urllib.request as request
from pathlib import Path
from urllib.error import HTTPError
from google_photo_to_vcard.util import build_photo_path
from google_photo_to_vcard.util import download_url_to_path
from google_photo_to_vcard.util import read_email_photo_json
def main():
email_to_photo = read_email_photo_json()
for email, photo_url in email_to_photo.items():
print(email, photo_url)
photo_path = Path(build_photo_path(email))
if photo_path.exists():
print('Photo already downloaded')
continue
else:
download_url_to_path(photo_url, photo_path)
if __name__ == '__main__':
main()