28 lines
769 B
Python
28 lines
769 B
Python
import logging
|
|
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
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
|
def main():
|
|
email_to_photo = read_email_photo_json()
|
|
for email, photo_url in email_to_photo.items():
|
|
loging.info('Downloading (%s, %s)', email, photo_url)
|
|
photo_path = Path(build_photo_path(email))
|
|
if photo_path.exists():
|
|
loging.debug('Photo already downloaded')
|
|
continue
|
|
else:
|
|
download_url_to_path(photo_url, photo_path)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|