Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write --xattrs metadata as macOS Spotlight metadata (rev 2) #29390

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Write --xattrs metadata as macOS Spotlight metadata (rev 2) #29390

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 25, 2021

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Modified the line of my previous #29184 about checking the availability of plistlib.dumps (from sys.version_info to hasattr().) Everything else unchanged.

Resolves #2545, resolves #8089, resolves #28945.

On macOS, it is preferable to write --xattrs metadata as Spotlight metadata so that they are shown in Finder's Get Info window and searchable by Spotlight/Finder.

These metadata will be written to Spotlight metadata: webpage_url, title, description and uploader.
Other metadata, upload_date and format, are written to dublin core as before since there seem to be no corresponding Spotlight metadata.

Uses standard plistlib on Python 3.4+, PyObjC module if available, or plutil command.
Tries to find Apple's xattr command which can set binary data if xattr module is not available.
PyObjC is usually pre-installed for Python 2.7 on macOS and can be installed with pip (pyobjc-framework-Cocoa is enough). plutil and xattr commands are usually pre-installed on macOS.

@porg
Copy link

porg commented Nov 5, 2023

Hi, I'm the one who proposed #8089 and am glad that someone made a code contribution for this!

Can you please explain how you mapped?

  • For upload_date and format I also provide what I think are the corresponding Spotlight metadata fields
  • All integrated into the following table:
xattr Spotlight Metadata Attribute
user.dublincore.contributor ("uploader" in Youtube terminology) kMDItemContributors
user.dublincore.date kMDItemContentCreationDate and/or simply the Creation Date via filesystem calls
user.dublincore.description kMDItemDescription
user.dublincore.format kMDItemFinderComment (plain text , user editable in Finder) or kMDItemCodecs (parse and map against proper identifiers which is certainly more complex or maybe even impossible)
user.dublincore.title kMDItemTitle
user.xdg.referrer.url kMDItemWhereFroms

Could you please provide a build of this?

  • Compatible with an Intel Mac on macOS 11 Big Sur so that I can test and report?
  • I installed yt-dlp via brew, so I should have all the latest dependencies.
  • I'm just not that git-savvy atm, don't know so well how to download (merge?) and build myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants