class VideoChannelCollection
A collection class that manages VideoChannel entities in SharePoint, providing methods to query, retrieve, and manipulate video channels.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/publishing/video/channel_collection.py
5 - 9
simple
Purpose
VideoChannelCollection serves as a container and manager for VideoChannel objects within the SharePoint publishing video framework. It inherits from EntityCollection to provide standard collection operations like querying, filtering, adding, and removing video channels. This class acts as an intermediary between the SharePoint context and individual VideoChannel entities, enabling batch operations and efficient data retrieval for video channel management.
Source Code
class VideoChannelCollection(EntityCollection):
def __init__(self, context, resource_path=None):
super(VideoChannelCollection, self).__init__(
context, VideoChannel, resource_path
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
EntityCollection | - |
Parameter Details
context: The SharePoint client context object that provides authentication and connection details to the SharePoint site. This context is used to execute queries and operations against the SharePoint server.
resource_path: Optional string representing the server-relative URL path to the video channel collection resource. If None, the path will be determined automatically based on the parent entity. This path is used to construct API endpoints for REST operations.
Return Value
Instantiation returns a VideoChannelCollection object that represents a collection of VideoChannel entities. The object provides inherited methods from EntityCollection for querying and manipulating the collection. Individual method returns depend on the inherited EntityCollection interface, typically returning self for chaining, individual VideoChannel objects, or query results.
Class Interface
Methods
__init__(self, context, resource_path=None)
Purpose: Initializes a new VideoChannelCollection instance with the provided SharePoint context and optional resource path
Parameters:
context: SharePoint client context for authentication and API communicationresource_path: Optional server-relative URL path to the collection resource
Returns: None (constructor)
get(self) -> VideoChannelCollection
Purpose: Prepares a query to retrieve all video channels in the collection from SharePoint (inherited from EntityCollection)
Returns: Self reference for method chaining, actual data loaded after execute_query()
filter(self, expression: str) -> VideoChannelCollection
Purpose: Filters the collection based on an OData filter expression (inherited from EntityCollection)
Parameters:
expression: OData filter expression string (e.g., 'Title eq "Marketing"')
Returns: Self reference for method chaining with filter applied
add(self, properties: dict) -> VideoChannel
Purpose: Creates and adds a new VideoChannel to the collection (inherited from EntityCollection)
Parameters:
properties: Dictionary containing properties for the new video channel
Returns: The newly created VideoChannel object
get_by_id(self, channel_id: str) -> VideoChannel
Purpose: Retrieves a specific video channel by its unique identifier (inherited from EntityCollection)
Parameters:
channel_id: The unique identifier of the video channel
Returns: VideoChannel object representing the requested channel
execute_query(self) -> VideoChannelCollection
Purpose: Executes all pending queries against SharePoint server (inherited from EntityCollection)
Returns: Self reference after query execution
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | The SharePoint client context used for all operations | instance |
resource_path |
str or None | The server-relative URL path to the collection resource | instance |
_item_type |
type | The type of entities in this collection (VideoChannel), set by parent constructor | instance |
Dependencies
office365-rest-python-client
Required Imports
from office365.sharepoint.publishing.video.channel_collection import VideoChannelCollection
from office365.sharepoint.client_context import ClientContext
Usage Example
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.publishing.video.channel_collection import VideoChannelCollection
# Authenticate to SharePoint
ctx = ClientContext('https://yourtenant.sharepoint.com/sites/yoursite').with_credentials(
UserCredential('username@tenant.com', 'password')
)
# Get the video channel collection
video_channels = VideoChannelCollection(ctx, '/sites/yoursite/_api/VideoService/Channels')
# Load the collection
video_channels.get().execute_query()
# Iterate through channels
for channel in video_channels:
print(f'Channel: {channel.title}')
# Filter channels
filtered = video_channels.filter('Title eq "Marketing"')
filtered.get().execute_query()
Best Practices
- Always ensure the SharePoint context is properly authenticated before instantiating the collection
- Call execute_query() after operations like get(), filter(), or add() to actually execute the request against SharePoint
- Use the inherited filter() and select() methods to optimize queries and reduce data transfer
- Handle exceptions that may occur during SharePoint operations, especially network and authentication errors
- The collection follows lazy loading patterns - data is not fetched until execute_query() is called
- Reuse the same context object for multiple operations to maintain session state and improve performance
- Check SharePoint permissions before attempting to add or modify video channels
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class VideoChannel 86.5% similar
-
class VideoItemCollection 84.7% similar
-
class ChannelCollection 80.9% similar
-
class ChannelInfoCollection 75.2% similar
-
class VideoServiceManager 73.4% similar