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

osxbundle: refactor Information Property List #13723

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxdunbar
Copy link
Contributor

Replaces deprecated CFBundleTypeExtensions with LSItemContentTypes.
LSHandlerRank ranks apps that declare as editors or viewers of a specific file type. Default value was chosen since mpv is a viewer of file types as opposed to an editor.
I tested this patch with some filetypes (avi,mkv,mov,wav) and the launch service seemed to behave appropriately.

Copy link

github-actions bot commented Mar 18, 2024

Download the artifacts for this pull request:

Windows
macOS

@Akemi Akemi added the os:mac label Mar 19, 2024
@Akemi
Copy link
Member

Akemi commented Mar 20, 2024

i don't think CFBundleTypeExtensions and LSItemContentTypes are interchangeable. from the documentation former expects file extensions and the latter expects UTIs (all UTIs).

if we want to support file extensions that aren't defined by Apple we do need to define them and make them conform to one of the existing UTIs, eg with UTExportedTypeDeclarations and UTTypeConformsTo. probably similar to what we or VLC does.

@Akemi Akemi marked this pull request as draft March 27, 2024 18:47
@Akemi
Copy link
Member

Akemi commented Mar 27, 2024

okay let get this a little bit sorted. lets start by cleaning up the CFBundleDocumentTypes and UTImportedTypeDeclarations node.

lets keep it to 3 different CFBundleDocumentTypes like currently, video, audio and subtitle files. though lets order them a bit different. the flat nodes at top and the collections/arrays at the bottom. for audio i would start with the general public.audio, video with public.video and public.movie and subtitles public.plain-text.

<dict>
    <key>CFBundleTypeIconFile</key>
    <string>document.icns</string>
    <key>CFBundleTypeName</key>
    <string>Audio file</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSTypeIsPackage</key>
    <false/>
    <key>NSPersistentStoreTypeKey</key>
    <string>Binary</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>UTI.URL.HERE</string>
        ...
    </array>
</dict>

after that we start to sort out the UTImportedTypeDeclarations node. ever entry should conform (UTTypeConformsTo node) to either public.audio, public.movie or public.plain-text depending on the type. take over, fill or extend the UTTypeIdentifier (UTI), UTTypeTagSpecification (with extension and mime-type declaration). any UTTypeIdentifier added here should be added to one of the three CFBundleDocumentTypes contained nodes (audio, video, subtitle) in the LSItemContentTypes array node. also lets try to sort those nodes, first all audio nodes, then all video node and at the bottom all subtitle nodes. all io.mpv.* UTIs should be replaces with the official UTIs, if possible and existent.

<dict>
    <key>UTTypeConformsTo</key>
    <array>
        <string>GENERAL.UTI.HERE</string>
    </array>
    <key>UTTypeDescription</key>
    <string>AC3 Audio</string>
    <key>UTTypeIconFile</key>
    <string>document.icns</string>
    <key>UTTypeIdentifier</key>
    <string>UTI.URL.HERE</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>public.filename-extension</key>
        <array>
            <string>EXTENSION</string>
            ...
        </array>
        <key>public.mime-type</key>
        <array>
            <string>MIME/TYPE</string>
            ...
        </array>
    </dict>
</dict>

lastly i would go through the list again and add all the other audio/video UTIs to the CFBundleDocumentTypes if they aren't already in some way in the UTImportedTypeDeclarations nodes.

References:
UTIs: https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
Nodes: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685

@maxdunbar
Copy link
Contributor Author

I reordered CFBundleDocumentTypes types to flat nodes at top and the collections/arrays at the bottom. There are still a few UTI's under LSItemContentTypes that I could not find. (I assume I will need to declare them as io.mpv.***.
I also couldn't find public.mime-type for
PCM
HDV
NUV
HEVC
YUV
Y4M

@Akemi
Copy link
Member

Akemi commented Apr 10, 2024

okay, i probably can't review your changes this week. it's a bit busy and i am not home at the weekend. just wanted to give you a heads up that i will try to look at everything as soon as possible.

@maxdunbar
Copy link
Contributor Author

okay, i probably can't review your changes this week. it's a bit busy and i am not home at the weekend. just wanted to give you a heads up that i will try to look at everything as soon as possible.

Thanks, no rush!

TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
@Akemi
Copy link
Member

Akemi commented Apr 18, 2024

hope i've got everything.

TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Outdated Show resolved Hide resolved
TOOLS/osxbundle/mpv.app/Contents/Info.plist Show resolved Hide resolved
@Akemi
Copy link
Member

Akemi commented May 18, 2024

hope this will be the last batch of comments.

@Akemi Akemi marked this pull request as ready for review May 20, 2024 14:14
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.rt</string>
<key>UTTypeReferenceURL</key>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just tried to build a new bundle and it was broken, same for the nightly bundles from the pipeline.

this must be the reason, when you removed the URL you forgot to remove the key for it too.

@Akemi
Copy link
Member

Akemi commented May 20, 2024

only this one last thing. after this feel free to squash the commits and force push. then we can finally get this merged.

thank you for you hard work on this one, i really appreciate it.

Includes cleanup of CFBundleDocumentTypes, UTImportedTypeDeclarations,
LSItemContentTypes. Reordered general structure of the Property List as
in nodes/collections/arrays. Declared MIME types.
@maxdunbar maxdunbar changed the title osxbundle: replace deprecated keys osxbundle: refactor Information Property List May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants