SyncMedia
Synchronizes all media content (series and VOD streams) from the Xtream Codes API.Signature
Parameters
No parameters required.Process Overview
The sync process follows these steps:- Remove from search index - Clear existing search entries
- Delete existing data - Remove all series and VOD streams from database
- Fetch series - Retrieve all series from Xtream Codes API
- Upsert series - Insert/update series in chunks of 1,000
- Fetch VOD streams - Retrieve all VOD streams from API
- Upsert VOD streams - Insert/update VOD streams in chunks of 1,000
- Bust DTO cache - Invalidate cached API responses
- Rebuild search index - Make all content searchable
Example
Implementation Details
Search Index Management
Before syncing, the action safely removes items from the search index:Data Deletion
All existing data is cleared before syncing:Series Synchronization
Series are fetched and upserted in chunks:VOD Stream Synchronization
VOD streams follow a similar pattern:Cache Invalidation
The DTO cache namespace is incremented to invalidate cached responses:Search Index Rebuild
After sync, content is made searchable in batches:SyncCategories
Synchronizes category information from Xtream Codes API and manages category assignments.Signature
Parameters
Allow applying empty VOD category list (destructive operation)
Allow applying empty series category list (destructive operation)
User ID who initiated the sync (for audit tracking)
Returns
The sync run record with status and summary information:
status: Success, SuccessWithWarnings, or Failedsummary: Counts of created, updated, removed categoriestop_issues: Array of warning/error messages (max 20)started_at,finished_at: Timestamps
Example
Process Overview
- Create sync run record - Track sync progress
- Ensure system categories - Create “Uncategorized” categories
- Fetch VOD categories - Retrieve from Xtream Codes API
- Fetch series categories - Retrieve from Xtream Codes API
- Apply VOD categories - Create/update categories, mark as in_vod
- Apply series categories - Create/update categories, mark as in_series
- Cleanup missing categories - Remove categories no longer in both sources
- Move orphaned content - Reassign content to “Uncategorized”
- Remap content - Restore content to valid categories when possible
- Finalize run - Update run status and summary
Summary Metrics
The sync run returns the following metrics:System Categories
Two special categories are automatically maintained: Uncategorized (VOD)provider_id: "__uncategorized_vod"in_vod: truein_series: falseis_system: true
Uncategorized (Series)provider_id: "__uncategorized_series"in_vod: falsein_series: trueis_system: true
Error Handling
Empty Category Lists
If the API returns an empty category list, the sync will warn and skip applying changes unless forced:Partial Failures
If one source fails but the other succeeds, the run status isSuccessWithWarnings:
Content Migration
Moving to Uncategorized
Content is moved to “Uncategorized” if its category is:nullor empty string- Not in the valid provider ID list
Remapping from Uncategorized
If a previously valid category becomes available again, content is automatically restored:Related Jobs
RefreshMediaContents
Scheduled job that triggers full media synchronization. Queue: DefaultSchedule: Configured via settings
Unique: No
SyncCategories (Job)
Job wrapper for the SyncCategories action. Queue: DefaultSchedule: Can be triggered manually or on schedule
API Integration
Xtream Codes API Requests
GetSeriesRequestFetches all series from the Xtream Codes API. GetVodStreamsRequest
Fetches all VOD streams from the Xtream Codes API. GetSeriesCategoriesRequest
Fetches series category definitions. GetVodCategoriesRequest
Fetches VOD category definitions.
Connector Configuration
TheXtreamCodesConnector manages:
- Base URL configuration
- Authentication (username/password)
- DTO caching with namespace versioning
- Request/response handling