On Mac OS, when you "Get Info" from a file, in "More info", there's a "Where from" information that shows me the original url from where I download the file.
I want to get to this information using Python, and I cannot seem to find a way to do it.
The os.path library doesn't seem to help since it only gives me information on things like creation time, size, etc. and nothing about the original download link.
If you download a file using google chrome you can see its by using shortcut Ctrl+J or directly go to your downloads and under every download there is its original download URL. If you can't see the complete URL then you can right click on that URL and Copy Link.
IMPORTANT: This answer only applies to macOS.
The additional information is stored as a "file attribute". As far as I am aware, the os.path
and pathlib
cannot read arbitrary attributes.
However, you can use libraries, such as xattr to read "non-standard"1 attributes.
Something like this should work2:
import xattr
value = xattr.getxattr("file.txt", "some_key").decode("utf-8")
macOS stores informations such as the "Where from" attribute under the key com.apple.metadata:kMDItemWhereFroms
.
1 I consider the values returned by fstat
as standard attributes. I am aware, that there is no "true" standard.
2 The code hasn't been tested yet; I left my device at home.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With