mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-27 15:48:28 +00:00
[pp/XAttrMetadata] Add macOS "Where from" attribute (#12664)
Authored by: rolandcrosby
This commit is contained in:
parent
035b1ece8f
commit
3e918d825d
@ -33,8 +33,17 @@ class XAttrMetadataPP(PostProcessor):
|
||||
# (e.g., 4kB on ext4), and we don't want to have the other ones fail
|
||||
'user.dublincore.description': 'description',
|
||||
# 'user.xdg.comment': 'description',
|
||||
'com.apple.metadata:kMDItemWhereFroms': 'webpage_url',
|
||||
}
|
||||
|
||||
APPLE_PLIST_TEMPLATE = '''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array>
|
||||
\t<string>%s</string>
|
||||
</array>
|
||||
</plist>'''
|
||||
|
||||
def run(self, info):
|
||||
mtime = os.stat(info['filepath']).st_mtime
|
||||
self.to_screen('Writing metadata to file\'s xattrs')
|
||||
@ -44,6 +53,8 @@ def run(self, info):
|
||||
if value:
|
||||
if infoname == 'upload_date':
|
||||
value = hyphenate_date(value)
|
||||
elif xattrname == 'com.apple.metadata:kMDItemWhereFroms':
|
||||
value = self.APPLE_PLIST_TEMPLATE % value
|
||||
write_xattr(info['filepath'], xattrname, value.encode())
|
||||
|
||||
except XAttrUnavailableError as e:
|
||||
|
Loading…
Reference in New Issue
Block a user