PyObjC Framework VideoSubscriberAccount
pyobjc-framework-videosubscriberaccount provides Python wrappers for Apple's VideoSubscriberAccount framework on macOS. It enables Python applications to interact with TV provider authentication services and manage user subscriptions. The current version is 12.1 and it maintains an active release cadence, frequently aligning with macOS SDK updates and Python version support.
Warnings
- breaking PyObjC frequently drops support for older Python versions. PyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 dropped Python 3.8. Ensure your Python version is compatible with the PyObjC version you are installing.
- breaking PyObjC 11.1 changed how initializer methods (those in the 'init' family) are modeled, now correctly reflecting that they 'steal' a reference to `self` and return a new one, as per clang's ARC documentation. This affects object lifecycle and reference counting.
- gotcha PyObjC framework wrappers, including `pyobjc-framework-videosubscriberaccount`, do not contain direct API documentation. Developers must refer to Apple's official VideoSubscriberAccount documentation for details on how to use the framework's classes, methods, and properties.
- gotcha The `VideoSubscriberAccount` framework is deeply integrated with macOS security features and often requires specific application entitlements to function correctly (e.g., `com.apple.developer.video-subscriber-account.request`). Without these, framework calls may fail or return no data, particularly for authentication requests.
- gotcha When subclassing Objective-C classes in Python and implementing both `__new__` and `__init__`, special care is needed. PyObjC 10.3 initially broke support for calling `__init__` when `__new__` was user-implemented, though 10.3.1 reintroduced some compatibility. Code relying on the PyObjC-provided `__new__` still cannot use `__init__` for custom initialization.
Install
-
pip install pyobjc-framework-videosubscriberaccount
Imports
- VideoSubscriberAccount
import VideoSubscriberAccount
- VSAccountManager
from VideoSubscriberAccount import VSAccountManager
Quickstart
import VideoSubscriberAccount
from Foundation import NSObject # NSObject is fundamental to Objective-C, often needed for PyObjC examples
# The VideoSubscriberAccount framework primarily interacts with TV provider authentication
# and subscription management, typically within a full macOS application context
# and requires specific entitlements. This example demonstrates basic class access.
# Get the shared account manager instance
manager = VideoSubscriberAccount.VSAccountManager.sharedAccountManager()
print(f"VSAccountManager instance: {manager}")
# Attempting to fetch a property (e.g., current account) would typically
# require an active application, user interaction, and entitlements.
# For example, to get the primary account, you would usually call
# manager.enqueueAccountMetadataRequest:completionHandler:
# But this is often asynchronous and requires more setup than a quickstart.
# A simple synchronous property if available (conceptual example, may not directly map without setup)
# if manager.isKeyLoaded(): # Not a real method for VSAccountManager, just illustrative
# print("Account manager key is loaded.")
# else:
# print("Account manager key not yet loaded or not applicable in this context.")
# The framework is used to present authentication requests to the user.
# E.g., presenting a sign-in view controller via VSAccountManager.presentViewController:.
# This requires a running Cocoa app and is beyond a simple script quickstart.