cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MediaInfo for Photos and Videos

MediaInfo for Photos and Videos

app5000
Explorer | Level 3

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 6

Greg-DB
Dropbox Staff

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
Explorer | Level 3

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

Greg-DB
Dropbox Staff
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
Explorer | Level 3

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

Greg-DB
Dropbox Staff
Yes, it should work the same way for videos.

app5000
Explorer | Level 3

Thank you, you are the best.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    app5000 Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?