{"library":"pyobjc-framework-linkpresentation","title":"PyObjC LinkPresentation Framework","description":"PyObjC is a bridge between Python and Objective-C, enabling Python scripts to interact with macOS Cocoa frameworks. This specific package, `pyobjc-framework-linkpresentation`, provides Python wrappers for Apple's LinkPresentation framework on macOS, allowing developers to fetch and present rich link previews from URLs. It is actively maintained with regular releases, currently at version 12.1.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-linkpresentation"],"cli":null},"imports":["import LinkPresentation"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import LinkPresentation\nimport Foundation\nimport objc\nimport threading\n\n# Use a threading.Event to signal when the metadata fetching is complete\ndone_fetching = threading.Event()\nmetadata_result = None\nerror_result = None\n\ndef completion_handler(metadata, error):\n    global metadata_result, error_result\n    metadata_result = metadata\n    error_result = error\n    done_fetching.set() # Signal that fetching is done\n\n@objc.python_block\ndef py_completion_handler(metadata, error):\n    completion_handler(metadata, error)\n\ndef fetch_link_metadata(url_string):\n    global metadata_result, error_result\n    metadata_result = None\n    error_result = None\n    done_fetching.clear()\n\n    url = Foundation.NSURL.URLWithString_(url_string)\n    if not url:\n        print(f\"Invalid URL: {url_string}\")\n        return\n\n    provider = LinkPresentation.LPMetadataProvider.alloc().init()\n    provider.startFetchingMetadataForURL_completionHandler_(url, py_completion_handler)\n\n    # Wait for the completion handler to be called\n    print(f\"Fetching metadata for {url_string}...\")\n    if not done_fetching.wait(timeout=10): # Wait up to 10 seconds\n        print(\"Fetching timed out.\")\n        return\n\n    if error_result:\n        print(f\"Error fetching metadata: {error_result}\")\n    elif metadata_result:\n        print(\"Metadata fetched successfully:\")\n        print(f\"  Title: {metadata_result.title()}\")\n        print(f\"  URL: {metadata_result.URL()}\")\n    else:\n        print(\"No metadata or error received.\")\n\nif __name__ == \"__main__\":\n    # Fetch metadata for a remote URL\n    test_url = os.environ.get('TEST_URL', 'https://www.apple.com')\n    fetch_link_metadata(test_url)\n    \n    # Create and inspect custom metadata\n    print(\"\\nCreating custom metadata:\")\n    custom_metadata = LinkPresentation.LPLinkMetadata.alloc().init()\n    custom_metadata.setOriginalURL_(Foundation.NSURL.URLWithString_(\"https://example.com/custom\"))\n    custom_metadata.setURL_(Foundation.NSURL.URLWithString_(\"https://example.com/custom\"))\n    custom_metadata.setTitle_(\"My Custom Link Title\")\n    print(f\"  Title: {custom_metadata.title()}\")\n    print(f\"  URL: {custom_metadata.URL()}\")","lang":"python","description":"This quickstart demonstrates how to fetch rich link metadata from a URL using `LPMetadataProvider` and how to create custom `LPLinkMetadata` objects. It includes a mechanism to handle the asynchronous nature of `startFetchingMetadataForURL_completionHandler_` using a `threading.Event` to wait for the Objective-C callback.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.2,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.2,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.7,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-linkpresentation","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.8,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}