Code Monkey home page Code Monkey logo

google-takeout-helper's People

Contributors

treymo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

google-takeout-helper's Issues

Import mail.py and photos.py only if required

Thanks for this! Downloaded this script only to extract attachments from my mbox file. Since I was just using the mail.py utility, I didn't install the requirements for photos.py, however, I had to comment out the import photos in order for the script to run.

For people in a similar situation, it would be helpful if the program only imported dependencies required for the run. This could be done by removing the imports from the beginning of the script, and import within the methods themselves.

Removed:

import mail
import photos

Changed:

def _maybe_organize_photos_takeout(takeout_dir):
    if not takeout_dir:
        print('Invalid (or no) Photos takeout archive directory specified. Not '
              'extracting photos from archives.')
        return
    else:
        organize_photos = input('Organize Photos takeout archives? y/n: ')
        organize_photos = distutils.util.strtobool(organize_photos)
        if not organize_photos:
            return
    import photos
    photos.organize_photos_takeout(takeout_dir)


def _maybe_extract_email_attachments(mbox_file_path):
    if (mbox_file_path and os.path.isfile(mbox_file_path) and
            mbox_file_path.endswith('.mbox')):
        answer = input('Extract mailbox attachments? y/n: ')
        answer = distutils.util.strtobool(answer)
        if answer:
            import mail
            mail.extract_mail_attachments(mbox_file_path)
    else:
        print('Invalid (or no) .mbox path specified. Not extracting email '
              'attachments.')

Error from creation date string

Thanks for creating this script. It is a huge help! However I get the following error:

D:\Backups\GoogleFotosTakeoutLine301120\Takeout\GoogleFotos/1980-01-01/1988 Ferie 09.jpg
Error setting creation date from string:
time data '2007:12:28 14:31: 2' does not match format '%Y:%m:%d %H:%M:%S'
Traceback (most recent call last):
File "c:\users\emil\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users\emil\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Emil\anaconda3\Scripts\google-photos-takeout-helper.exe_main
.py", line 7, in
File "c:\users\emil\anaconda3\lib\site-packages\google_photos_takeout_helper_main
.py", line 356, in main
filter_fun=lambda f: (is_photo(f) or is_video(f))
File "c:\users\emil\anaconda3\lib\site-packages\google_photos_takeout_helper_main_.py", line 99, in for_all_files_recursive
for_all_files_recursive(file, file_function, folder_function, filter_fun)
File "c:\users\emil\anaconda3\lib\site-packages\google_photos_takeout_helper_main_.py", line 102, in for_all_files_recursive
file_function(dir, file)
File "c:\users\emil\anaconda3\lib\site-packages\google_photos_takeout_helper_main_.py", line 274, in fix_metadata
set_creation_date_from_exif(file)
File "c:\users\emil\anaconda3\lib\site-packages\google_photos_takeout_helper_main_.py", line 241, in set_creation_date_from_exif
set_creation_date_from_str(file, datetime_str)
File "c:\users\emil\anaconda3\lib\site-packages\google_photos_takeout_helper_main_.py", line 226, in set_creation_date_from_str
_os.utime(file, (timestamp, timestamp))
UnboundLocalError: local variable 'timestamp' referenced before assignment

I seem to get this error when the script tries to process photos that I have manually uploaded to Gphotos, rather than those uploaded by my phone automatically. I should mention that i use the --divide-to-dates tag.

Is it possible to include an ignore-errors flag that simply skips photos with incorrect date strings? Alternatively, puts the photos into a non-sorted folder?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.