# On Unix, and can't find pyxattr, setfattr, or xattr.
ifsys.platform.startswith('linux'):
self._downloader.report_error("Couldn't find a tool to set the xattrs. Install either the python 'pyxattr' or 'xattr' modules, or the GNU 'attr' package (which contains the 'setfattr' tool).")
elifsys.platform=='darwin':
self._downloader.report_error("Couldn't find a tool to set the xattrs. Install either the python 'xattr' module, or the 'xattr' binary.")
else:
# Write xattrs to NTFS Alternate Data Streams: http://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_.28ADS.29
defwrite_xattr(path,key,value):
assert(key.find(":")<0)
assert(path.find(":")<0)
assert(os.path.exists(path))
f=open(path+":"+key,"w")
f.write(value)
f.close()
# Write the metadata to the file's xattrs
self._downloader.to_screen('[metadata] Writing metadata to file\'s xattrs...')
filename=info['filepath']
try:
xattr_mapping={
'user.xdg.referrer.url':'webpage_url',
# 'user.xdg.comment': 'description',
'user.dublincore.title':'title',
'user.dublincore.date':'upload_date',
'user.dublincore.description':'description',
'user.dublincore.contributor':'uploader',
'user.dublincore.format':'format',
}
forxattrname,infonameinxattr_mapping.items():
value=info.get(infoname)
ifvalue:
ifinfoname=="upload_date":
value=hyphenate_date(value)
write_xattr(filename,xattrname,value)
returnTrue,info
exceptOSError:
self._downloader.report_error("This filesystem doesn't support extended attributes. (You may have to enable them in your /etc/fstab)")