Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

app5000's avatar
app5000
Explorer | Level 3
8 years ago

MediaInfo for Photos and Videos

I am working on extracting media information from photos and videos.  So far I have used mediainfo=dbx.files_get_metadata(file_id=fileid, include_media_info=True).media_info to get MediaInfo which includes PhotoMetadata with location and time_taken values.  However, I can not find a way to get the location and time_taken values out of PhotoMetadata.  I have used photometadata=MediaInfo.PhotoMetadata, location=mediainfo.PhotoMetadata.location and time_taken=mediainfo.PhotoMetadata.time_taken but got "no attribute PhotoMetadata", "no attribute location" and "no attribute time_taken" errors at different times.  When I printed out MediaInfo it looks like (u'metadata', PhotoMetadata( dimension=xxx, location=None, time_taken=None)) but I can not . out the two values.  Can someone show me what is the correct way to write the codes so I can get the value of location and time_taken?  Thanks.

6 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    It sounds like you want to do something like this:

     

    file_metadata = dbx.files_get_metadata(path=file_id, include_media_info=True)
    
    if file_metadata.media_info:
        if file_metadata.media_info.is_metadata():
            media_metadata = file_metadata.media_info.get_metadata()
            print(media_metadata.dimensions)
            print(media_metadata.location)
            print(media_metadata.time_taken)
        elif file_metadata.media_info.is_pending():
            print("Meda info is peninding.")

    Note that any of those three values may be None though, e.g., if the photo doesn't have that information.

  • app5000's avatar
    app5000
    Explorer | Level 3
    8 years ago

    Thanks, Greg.  I think this works.  Should I always set path=fileid whenever path is asked for?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    There are a few different path formats, and exactly what you should use in each case depends on what you want your app to do, what method you're using, etc. In general though, yes, you can just supply the file ID as the path value.
  • app5000's avatar
    app5000
    Explorer | Level 3
    8 years ago

    Ok, I will keep that in mind.  By the way, can I use similar codes to get metadata for videos?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    Yes, it should work the same way for videos.

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!