1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-18 03:08:31 +00:00

Inline value formatting

This commit is contained in:
Roland Crosby 2025-03-19 18:34:29 -04:00
parent bac71d6a75
commit 2737255d94
No known key found for this signature in database

View File

@ -44,13 +44,6 @@ class XAttrMetadataPP(PostProcessor):
</array>
</plist>'''
def format_value(self, xattrname, infoname, value):
if infoname == 'upload_date':
return hyphenate_date(value)
if xattrname == 'com.apple.metadata:kMDItemWhereFroms':
return self.APPLE_PLIST_TEMPLATE % value
return value
def run(self, info):
mtime = os.stat(info['filepath']).st_mtime
self.to_screen('Writing metadata to file\'s xattrs')
@ -58,7 +51,10 @@ def run(self, info):
try:
value = info.get(infoname)
if value:
value = self.format_value(xattrname, infoname, 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: