One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
app5000
8 years agoExplorer | Level 3
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.
- 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.
- app5000Explorer | 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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,945 PostsLatest Activity: 6 hours ago
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 or Facebook.
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!