This API is only compatible with live channels that can leverage schedule entries.
Learn more.
Administer schedule entries associated with a live channel through the following endpoints:
Endpoint | Description |
---|---|
POST /channels/Live Channel ID/schedules
|
Adds a schedule entry to a live channel. |
Add Schedule Entries by Playlist POST /channels/Live Channel ID/schedule-playlist
|
Adds a playlist's assets and ad breaks as entries within a live channel's schedule. |
Delete Multiple Schedule Entries DELETE /channels/Live Channel ID/schedules
|
Deletes all schedule entries that fall within the specified date range. |
Delete Schedule Entry / Linked Schedule Entries DELETE /channels/Live Channel ID/schedules/Schedule Entry ID
Delete linked schedule entries: DELETE /channels/Live Channel ID/schedules/Schedule Entry ID?include_linked=true
|
Deletes a schedule entry from a live channel. If the entry was scheduled as a result of a playlist, then you may also delete all of the other entries that were scheduled at that time. |
GET /channels/Live Channel ID/schedules
|
Retrieves the set of schedule entries associated with a live channel for a specific time period. |
GET /channels/Live Channel ID/schedules/Schedule Entry ID
|
Retrieves a specific schedule entry. |
PATCH /channels/Live Channel ID/schedules/Schedule Entry ID
|
Updates a specific schedule entry. |
Adds a schedule entry to a live channel.
By default, a new schedule entry cannot conflict with an existing one. Use the conflict_resolution property to resolve scheduling conflicts.
Request syntax:
Define the following variable when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Request body:
Define a schedule entry through the following properties:
Name |
Data Type |
Description |
---|---|---|
ad_breaks |
List of integers |
Determines the duration for each ad break associated with the asset. Key information:
|
conflict_resolution |
String |
Determines how scheduling conflicts are handled. Valid values are:
Prevent previously scheduled entries from being overwritten by excluding this property from the request. Omitting this property causes our service to respond with a 409 Conflict when a scheduling conflict arises. Trimming an asset can affect the number of ads served. Specifically, we will not serve ads for an ad break positioned within a portion of the asset that is trimmed. |
content_id Required content_id |
String |
Identifies an asset by its system-defined ID You may only schedule another user's Live Slicer if it is streaming to a library shared with your account. |
content_owner |
String |
content_type: slicer Only Identifies the user that owns the scheduled Live Slicer by its system-defined ID. |
content_type Required |
String |
Determines whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
desc |
String |
Defines the schedule entry's description. |
dur Required |
Integer |
Determines the schedule entry's duration in milliseconds. Key information:
|
external_id |
String |
Defines a schedule entry's custom ID. |
overwrite Deprecated |
String |
Determines how scheduling conflicts are handled. The conflict_resolution property takes precedence over this deprecated property. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
start Required |
String |
Determines the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
Key information:
|
Pass a digital signature based off of msg.
The response for a successful request contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to an endpoint that returns this schedule entry. You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-. |
@type |
String |
Returns Schedule. |
ad_breaks |
List of integers |
Indicates the duration for each ad break associated with the asset. |
content_id |
String |
content_type: asset Identifies an asset by its system-defined ID |
content_owner |
String |
content_type: slicer Only Identifies the user that owns the scheduled Live Slicer by its system-defined ID. This property is only returned for Live Slicers that belong to another user. |
content_type |
String |
Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
created |
String |
Indicates the timestamp (UTC) at which the schedule entry was created. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
deleted |
String |
include_deleted=1 Only Indicates the timestamp (UTC) at which the schedule entry was deleted. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
desc |
String |
Indicates the schedule entry's description.
Schedule entries created through the CMS are not assigned a description. |
dur |
Integer |
Indicates the schedule entry's duration in milliseconds. |
end |
String |
Indicates the schedule entry's end time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
external_id |
String |
Indicates a schedule entry's custom ID. |
id |
String |
Identifies a schedule entry by its system-defined ID. |
lastmod |
String |
Indicates the timestamp (UTC) at which the schedule entry was last modified. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
offset |
Integer |
Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past. Example: An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000. |
owner |
String |
Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
start |
String |
Indicates the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
type |
String |
Indicates the type of schedule entry. Valid values are:
|
Call the add_schedule_entry module (Python 3) to adds a schedule entry. This module imports names from the api_auth module.
import json, requests, datetime, time from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. asset_id = 'ae071e89574248c2ab179fe73d436c3e' # Replace with the ID for the desired asset. def convert_ts(utc_tstamp): """ Convert a UTC timestamp to ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ). :param utc_tstamp: The UTC timestamp to convert (expected milliseconds) """ iso_format = "%Y-%m-%dT%H:%M:%S.%fZ" try: _ts = float("{0:.3f}".format(utc_tstamp/1000.0)) return "{}{}".format(datetime.datetime.utcfromtimestamp(_ts).strftime(iso_format)[:-4], "Z") except Exception: print ("Invalid timestamp: {}".format(utc_tstamp)) raise class ScheduleEntry: def __init__(self): self.host = "https://services.uplynk.com" def run(self): """ Create a schedule entry. """ self._create_schedule_entry() def _create_schedule_entry(self): url = "{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules") start = int((time.time() + 3600) * 1000.0) # 1 hour from now start = convert_ts(start) payload = { 'content_id': asset_id, 'content_type': 'asset', 'start': start } headers = {'Content-Type': 'application/json'} response = requests.post( url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers ) print(response.json()) ScheduleEntry().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12', '@type': 'Schedule', 'created': '2021-02-16T00:57:10.402Z', 'lastmod': '2021-02-16T00:57:10.402Z', 'id': '2158c7452b7841158972e019a5bd5f12', 'owner': 'ab533864a92b46a1a286cdd49b0a9bd3', 'content_id': 'ae071e89574248c2ab179fe73d436c3e', 'content_type': 'asset', 'desc': 'Sports Segment', 'dur': 2343598, 'external_id': '', 'start': '2021-02-16T00:57:10.402Z', 'end': '2021-02-16T01:36:14.000Z', 'type': 'Time', 'ad_breaks': [] }
Adds a playlist's assets and ad breaks as entries within a live channel's schedule.
By default, a new schedule entry cannot conflict with an existing one. Use the conflict_resolution property to resolve scheduling conflicts.
Request syntax:
Define the following variable when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Request body:
Define a schedule entry through the following properties:
Name |
Data Type |
Description |
---|---|---|
conflict_resolution |
String |
Determines how scheduling conflicts are handled. Valid values are:
Prevent previously scheduled entries from being overwritten by excluding this property from the request. Omitting this property causes our service to respond with a 409 Conflict when a scheduling conflict arises. Trimming an asset can affect the number of ads served. Specifically, we will not serve ads for an ad break positioned within a portion of the asset that is trimmed. |
overwrite Deprecated |
String |
Determines how scheduling conflicts are handled. The conflict_resolution property takes precedence over this deprecated property. |
playlist_id Required |
String |
Identifies a playlist by its system-defined ID. Use the Get All Virtual Linear Playlists endpoint to retrieve a list of virtual linear playlists and their system-defined IDs. |
start Required |
String |
Indicates the start time (UTC) for the starting point at which schedule entries will be inserted. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
Key information:
|
Pass a digital signature based off of msg.
The response for a successful request contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to the requested endpoint. |
@type |
String |
Returns Collection. |
List of dictionaries |
Contains a list of the schedule entries that were created. |
|
total_items |
Integer |
Indicates the total number of recently created schedule entries. |
The items list describes each schedule entry through the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to an endpoint that returns this schedule entry. |
@type |
String |
Returns Schedule. |
ad_breaks |
List of integers |
Indicates the duration for each ad break associated with the asset. |
content_id |
String |
content_type: asset Identifies an asset by its system-defined ID. |
content_type |
String |
Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
created |
String |
Indicates the timestamp (UTC) at which the schedule entry was created. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
desc |
String |
Indicates the schedule entry's description.
Schedule entries created through the CMS are not assigned a description. |
dur |
Integer |
Indicates the schedule entry's duration in milliseconds. |
end |
String |
Indicates the schedule entry's end time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
external_id |
String |
Indicates a schedule entry's custom ID. |
id |
String |
Identifies a schedule entry by its system-defined ID. |
lastmod |
String |
Indicates the timestamp (UTC) at which the schedule entry was last modified. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
offset |
Integer |
Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past. Example: An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000. |
owner |
String |
Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
Dictionary |
Identifies the playlist from which this schedule entry was created. |
|
start |
String |
Indicates the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
The source dictionary identifies the playlist from which this schedule entry was created.
Name |
Data Type |
Description |
---|---|---|
id |
String |
Indicates the system-defined ID for the playlist from which this schedule entry was created. |
type |
String |
Returns playlist. |
Call the add_schedule_entries_by_playlist module (Python 3) to create schedule entries from the assets and ad breaks associated with a playlist. This module imports names from the api_auth module.
import json, requests, datetime, time from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. playlist_id = 'gh35hs89274748j2ab459ne7ud4f6cl3' # Replace with the ID for the desired playlist. def convert_ts(utc_tstamp): """ Convert a UTC timestamp to ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ). :param utc_tstamp: The UTC timestamp to convert (expected milliseconds) """ iso_format = "%Y-%m-%dT%H:%M:%S.%fZ" try: _ts = float("{0:.3f}".format(utc_tstamp/1000.0)) return "{}{}".format(datetime.datetime.utcfromtimestamp(_ts).strftime(iso_format)[:-4], "Z") except Exception: print ("Invalid timestamp: {}".format(utc_tstamp)) raise class ScheduleEntries: def __init__(self): self.host = "https://services.uplynk.com" def run(self): """ Create mulitple schedule entries. """ self._create_schedule_entries_by_playlist() def _create_schedule_entries_by_playlist(self): url = "{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedule-playlist") start = int((time.time() + 3600) * 1000.0) # 1 hour from now start = convert_ts(start) payload = { 'playlist_id': playlist_id, 'start': start } headers = {'Content-Type': 'application/json'} response = requests.post( url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers ) print(response.json()) ScheduleEntries().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules?start=now&end=now+240m', '@type': 'TimeSeries', 'start': '2022-12-19T19:48:24.000Z', 'end': '2022-12-19T23:48:24.000Z', 'items': [{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/631c7c0accbb4bc999ea5536aa81ce91', '@type': 'Schedule', 'id': '631c7c0accbb4bc999ea5536aa81ce91', 'content_id': '5574ff5e41c04bdd9ed5ed485c6a3211', 'content_type': 'asset', 'deleted': '', 'desc': 'marketing-conference-2022-green-room-morning', 'dur': 227968, 'end': '2022-12-19T20:35:30.474Z', 'external_id': '', 'owner': '1234567890abcdefghijklmnopqrstu', 'source': { 'id': '18495b21df6c410a968f89da32a025ff', 'type': 'playlist' }, 'start': '2022-12-19T20:31:42.506Z', 'ad_breaks': [], 'lastmod': '2022-12-19T19:31:43.065Z', 'created': '2022-12-19T19:31:43.065Z' }, { '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/05a882f291434e788fe09b413a83e8b4', '@type': 'Schedule', 'id': '05a882f291434e788fe09b413a83e8b4', 'content_id': 'fb19109d3cf6470a806e85307c70842e', 'content_type': 'asset', 'deleted': '', 'desc': 'marketing-conference-2022-red-room-morning', 'dur': 9856, 'end': '2022-12-19T20:44:01.217Z', 'external_id': '', 'owner': '1234567890abcdefghijklmnopqrstu', 'source': { 'id': '18495b21df6c410a968f89da32a025ff', 'type': 'playlist' }, 'start': '2022-12-19T20:43:51.361Z', 'ad_breaks': [], 'lastmod': '2022-12-19T19:43:51.709Z', 'created': '2022-12-19T19:43:51.709Z' }, { '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2be08e891c544312a984361614b7ae35', '@type': 'Schedule', 'id': '2be08e891c544312a984361614b7ae35', 'content_id': 'a404b63430a7437a99995d3285a48be6', 'content_type': 'asset', 'deleted': '', 'desc': 'marketing-conference-2022-blue-room-morning', 'dur': 24493, 'end': '2022-12-19T20:44:25.710Z', 'external_id': '', 'owner': '1234567890abcdefghijklmnopqrstu', 'source': { 'id': '18495b21df6c410a968f89da32a025ff', 'type': 'playlist' }, 'start': '2022-12-19T20:44:01.217Z', 'ad_breaks': [], 'lastmod': '2022-12-19T19:43:51.709Z', 'created': '2022-12-19T19:43:51.709Z' } ] }
Deletes all schedule entries that fall within the specified date range.
The duration of the specified date range cannot exceed 5 days.
You may only delete schedule entries that occur in the future. Scheduled entries that occurred in the past cannot be deleted. Attempting to delete the currently active schedule entryIdentifies a schedule entry that is currently serving as the source for the live channel's feed. will truncate it.
Request syntax:
Define the following variables when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Required |
Identifies the start of the time period for which schedule entries will be deleted. Specify a timestamp (ISO 8601 - milliseconds; UTC). If you specify a time in the past, then the start query string parameter will be set to the present. Syntax: YYYY-MM-DDThh:mm:ss.sssZ
Example: start=2024-01-08T20:31:11.510Z
Default value: The default value varies according to whether the end parameter has been defined.
|
Required |
Identifies the end of the time period for which schedule entries will be deleted. Specify a timestamp (ISO 8601 - milliseconds; UTC). Syntax: YYYY-MM-DDThh:mm:ss.sssZ
Example: end=2024-01-08T20:31:11.510Z
Default value: The default value varies according to whether the start parameter has been defined.
|
keep_live |
Set to 1 to exclude the currently active schedule entryIdentifies a schedule entry that is currently serving as the source for the live channel's feed. from deletion. Default behavior: If this parameter is not defined, then attempting to delete the currently active schedule entry will truncate it to the point-in-time at which this API request is processed. |
Pass a digital signature based off of msg.
The response for a successful request is a 200 OK and it contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to this endpoint. |
@type |
String |
Returns Schedule. |
message |
String |
Returns the following value for successful deletions: Deleted entries: Number of Deleted Entries
|
If one or more schedule entries cannot be deleted, then this endpoint will not delete any schedule entries and it will return one of the following status codes:
Call the delete_multiple_schedule_entries module (Python 3) to delete all of the schedule entries that fall within a specified date range. This module imports names from the api_auth module.
import json, requests, datetime, time from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. def convert_ts(utc_tstamp): """ Convert a UTC timestamp to ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ). :param utc_tstamp: The UTC timestamp to convert (expected milliseconds) """ iso_format = "%Y-%m-%dT%H:%M:%S.%fZ" try: _ts = float("{0:.3f}".format(utc_tstamp/1000.0)) return "{}{}".format(datetime.datetime.utcfromtimestamp(_ts).strftime(iso_format)[:-4], "Z") except Exception: print ("Invalid timestamp: {}".format(utc_tstamp)) raise class DeleteMultipleScheduleEntries: def __init__(self): self.host = "https://services.uplynk.com" def run(self): """ Deletes a schedule entry. """ self._delete_schedule_entry() def _delete_schedule_entry(self): start = int((time.time() + 3600) * 1000.0) # 1 hour from now start = convert_ts(start) end = int((time.time() + 7200) * 1000.0) # 2 hours from now end = convert_ts(end) url = "{}{}{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules?start=", start, "&end=", end) response = requests.delete( url, params=APIParams(APICredentials()).get_params({}) ) print(response.json()) DeleteMultipleScheduleEntries().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules?start=2021-04-28T23:08:35.769Z&end=2021-04-29T00:08:35.771Z', '@type': 'Schedule', 'message': 'Deleted entries: 1' }
Deletes:
Optional. If that entry was scheduled as a result of a playlist, then you may also delete all of the other entries that were scheduled at that time.
You may only delete schedule entries that occur in the future. Scheduled entries that occurred in the past cannot be deleted. Attempting to delete the currently active schedule entryIdentifies a schedule entry that is currently serving as the source for the live channel's feed. will truncate it.
Request syntax (single schedule entry):
Request syntax (schedule entry and linked schedule entries):
Define the following variables when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Required |
Identifies a schedule entry by its system-defined ID. Use the Get Multiple Schedule Entries endpoint to retrieve schedule entries and their system-defined IDs. |
Pass a digital signature based off of msg.
The response for a successful request is a 200 OK and it contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to this endpoint. |
@type |
String |
Returns Schedule. |
message |
String |
Returns Deleted when the specified draft has been successfully deleted. |
If a schedule entry cannot be deleted, then the response will have one of the following status codes:
Call the delete_schedule_entry module (Python 3) to delete a schedule entry. This module imports names from the api_auth module.
import json, requests from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. schedule_id = '2158c7452b7841158972e019a5bd5f12' # Replace with the ID for the desired schedule entry. class DeleteScheduleEntry: def __init__(self): self.host = "https://services.uplynk.com" def run(self): """ Deletes a schedule entry. """ self._delete_schedule_entry() def _delete_schedule_entry(self): url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules/", schedule_id) response = requests.delete( url, params=APIParams(APICredentials()).get_params({}) ) print(response.json()) DeleteScheduleEntry().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12', '@type': 'Schedule', 'message': 'Deleted' }
Retrieves either:
Up to 500 schedule entries associated with a live channel for a specific time period.
We restrict the number of schedule entries that may be retrieved through this endpoint to 500. If the number of schedule entries in the requested time period exceeds this limit, then we will return the results for a shorter time period. Your script should check whether the requested end time (i.e., &end=End Time) matches the timestamp returned by the end response property. If there is a mismatch, then your script should submit another request with the start time set to the timestamp returned by the end response property and the end time set to the original requested end time.
Identify gaps within your schedule by including the include_empty=1 query string parameter. This parameter adds a placeholder schedule entry for each gap in your schedule within the requested time period. This occurs regardless of the duration of the gap in the schedule. For example, if you request schedule entries for a 12 hour period and have only scheduled entries for the first 7 hours, then the response will include a 5 hour placeholder schedule entry. Let's assume that there is also a 30 minute gap within the first 7 hours. In that case, the response will include 2 schedule entries whose durations are 30 minutes and 5 hours, respectively.
Information describing a scheduled entry is retained for 30 days after its end time.
Request syntax (recently updated schedule entries):
Define the following URL segment when submitting one of the above requests:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Define the following optional query string parameters when submitting one of the above requests:
Parameter |
Description |
---|---|
Identifies the start of the time period for which schedule entries will be retrieved. Specify a timestamp (ISO 8601 - milliseconds; UTC). Syntax: YYYY-MM-DDThh:mm:ss.sssZ
Example: start=2024-01-08T20:31:11.510Z
Default value: The default value varies according to whether the end parameter has been defined.
|
|
Identifies the end of the time period for which schedule entries will be retrieved. Specify a timestamp (ISO 8601 - milliseconds; UTC). Syntax: YYYY-MM-DDThh:mm:ss.sssZ
Example: end=2024-01-08T20:31:11.510Z
Default value: The default value varies according to whether the start parameter has been defined.
|
|
Pass include_deleted=1 to include deleted schedule entries in the response. The deleted response property is included for deleted schedule entries. Omit it to exclude this information. |
|
Pass include_empty=1 to include a placeholder schedule entry for each gap within your schedule for the requested time period. A placeholder schedule entry is limited to the following response properties: @id | @type | id | desc | dur | end | start | type
The type property for placeholder schedule entries is set to Empty. |
|
Pass slicer_assets=1 to include information that describes assets played within a live channel as a result of a Live Slicer. Omit it to exclude this information. |
|
Identifies a point-in-time for retrieving recently updated schedule entries. The response will only include schedule entries that were updated after this point-in-time. Specify a timestamp (ISO 8601 - milliseconds; UTC). The specified point-in-time may not exceed 10 minutes into the past. If you specify a point-in-time that is older than 10 minutes, then we will only return schedule entries that have been updated within the last 10 minutes. The after query string parameter takes precedence over the start and end parameters. Syntax: YYYY-MM-DDThh:mm:ss.sssZ
Example: after=2024-01-08T20:31:11.510Z
Default value: The default value is 10 minutes. |
Pass a digital signature based off of msg.
The response for a successful request contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to the requested endpoint. |
@type |
String |
This property's value varies according to whether you requested data by:
|
start |
String |
Indicates the timestamp (ISO 8601 - milliseconds; UTC) that identifies the start of the time period for which schedule entries were retrieved. Syntax: YYYY-MM-DDThh:mm:ss.sssZ
|
end |
String |
Indicates the timestamp (ISO 8601 - milliseconds; UTC) that identifies the end of the time period for which schedule entries were retrieved. We restrict the number of schedule entries that may be retrieved through this endpoint to 500. If the number of schedule entries in the requested time period exceeds this limit, then we will return the results for a shorter time period. Your script should check whether the requested end time (i.e., &end=End Time) matches the timestamp returned by the end response property. If there is a mismatch, then your script should submit another request with the start time set to the timestamp returned by the end response property and the end time set to the original requested end time. Syntax: YYYY-MM-DDThh:mm:ss.sssZ
|
List of dictionaries |
Contains a list of schedule entries. |
|
List of dictionaries |
slicer_assets=1 Only Contains a list of assets that were played within a live channel as a result of a Live Slicer. This list is restricted to the assets that were played during the time period defined by the start and end response parameter. |
|
@links |
Dictionary |
slicer_assets=1 Only Contains the assets dictionary. The assets dictionary contains the following property:
|
total_items |
Integer |
after={Last Modified Time} Only Indicates the total number of recently updated schedule entries. |
The items list describes each schedule entry through the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to an endpoint that returns this schedule entry. You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-. |
@type |
String |
Returns Schedule. |
ad_breaks |
List of integers |
Indicates the duration for each ad break associated with the asset. |
content_id |
String |
content_type: asset Identifies an asset by its system-defined ID |
content_owner |
String |
content_type: slicer Only Identifies the user that owns the scheduled Live Slicer by its system-defined ID. This property is only returned for Live Slicers that belong to another user. |
content_type |
String |
Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
created |
String |
Indicates the timestamp (UTC) at which the schedule entry was created. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
deleted |
String |
include_deleted=1 Only Indicates the timestamp (UTC) at which the schedule entry was deleted. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
desc |
String |
Indicates the schedule entry's description.
Schedule entries created through the CMS are not assigned a description. |
dur |
Integer |
Indicates the schedule entry's duration in milliseconds. |
end |
String |
Indicates the schedule entry's end time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
external_id |
String |
Indicates a schedule entry's custom ID. |
id |
String |
Identifies a schedule entry by its system-defined ID. |
lastmod |
String |
Indicates the timestamp (UTC) at which the schedule entry was last modified. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
offset |
Integer |
Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past. Example: An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000. |
owner |
String |
Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
Dictionary |
Identifies the playlist from which this schedule entry was created. |
|
start |
String |
Indicates the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
type |
String |
Indicates the type of schedule entry. Valid values are:
|
The source dictionary identifies the playlist from which this schedule entry was created.
Name |
Data Type |
Description |
---|---|---|
id |
String |
Indicates the system-defined ID for the playlist from which this schedule entry was created. |
type |
String |
Returns playlist. |
The @included list describes each asset played within a live channel as a result of a Live Slicer through the following properties:
Name |
Data Type |
Description |
---|---|---|
id |
String |
Reserved for future use. |
slicer_id |
String |
Indicates the ID for the Live Slicer that sliced the asset. A Live Slicer's ID is determined by the SlicerID setting within the Live Slicer's configuration file. |
channel |
String |
Indicates the system-defined ID for the live channel on which the asset was played. |
content_id |
String |
Indicates the asset's system-defined ID (i.e., asset ID). |
content_type |
slicer-asset |
Returns slicer-asset. |
created |
String |
Indicates the timestamp (UTC) at which the asset was created. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
desc |
String |
Indicates the asset's name as determined by the description setting in the Live Slicer's configuration file |
lastmod |
String |
Indicates the timestamp (UTC) at which the asset was last modified. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
dur |
Integer |
Indicates the number of milliseconds from the asset that were included in the live channel. Example: A Live Slicer starts slicing an asset an hour before it is scheduled start time. If the Live Slicer's schedule entry is 30 minutes and it does not contain ads, then this property returns 1800000. if the Live Slicer is stopped or starts slicing a new asset immediately after the scheduled entry ends, then the actual_dur property returns 5400000. |
actual_dur |
Integer |
Indicates the asset's duration in milliseconds. |
end |
String |
Indicates the timestamp (UTC) at which the Live Slicer stopping sending a feed that contains this asset. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
external_id |
String |
Indicates the asset's external ID. |
owner |
String |
Indicates the system-defined ID (i.e., user ID) assigned to the user that owns the asset. |
start |
String |
Indicates the timestamp (UTC) at which the Live Slicer started sending a feed that contains this asset. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
from_schedule |
Boolean |
Indicates whether the asset was included in the live channel as a result of a schedule entry. Valid values are:
|
Call the get_multiple_schedule_entries module (Python 3) to retrieve up to 500 entries scheduled within the next two hours. This module imports names from the api_auth module.
import requests, datetime, time from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. def convert_ts(utc_tstamp): """ Convert a UTC timestamp to ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ). :param utc_tstamp: The UTC timestamp to convert (expected milliseconds) """ iso_format = "%Y-%m-%dT%H:%M:%S.%fZ" try: _ts = float("{0:.3f}".format(utc_tstamp/1000.0)) return "{}{}".format(datetime.datetime.utcfromtimestamp(_ts).strftime(iso_format)[:-4], "Z") except Exception: print ("Invalid timestamp: {}".format(utc_tstamp)) raise class ScheduleEntry: def __init__(self): self.host = "https://services.uplynk.com" def run(self): self._get_multiple_schedule_entries() def _get_multiple_schedule_entries(self): start = int(time.time() * 1000.0) # Now end = start + (120 * 60 * 1000) # 120 minutes later start = convert_ts(start) end = convert_ts(end) url = "{}{}{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules?start=", start, "&end=", end) headers = {'Content-Type': 'application/json'} response = requests.get( url, params=APIParams(APICredentials()).get_params({}), headers=headers ) print(response.json()) ScheduleEntry().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules?start=2021-02-15T22:58:10.835Z&end=2021-02-16T00:58:10.835Z', '@type': 'TimeSeries', 'start': '2021-02-15T22:58:10.835Z', 'end': '2021-02-16T00:58:10.835Z', 'items': [{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12', '@type': 'Schedule', 'created': '2021-02-16T00:57:10.402Z', 'lastmod': '2021-02-16T00:57:10.402Z', 'id': '2158c7452b7841158972e019a5bd5f12', 'owner': 'ab533864a92b46a1a286cdd49b0a9bd3', 'content_id': 'ae071e89574248c2ab179fe73d436c3e', 'content_type': 'asset', 'desc': 'Sports Segment', 'dur': 2343598, 'external_id': '', 'start': '2021-02-16T00:57:10.402Z', 'end': '2021-02-16T01:36:14.000Z', 'type': 'Time', 'ad_breaks': [] } ] }
Retrieves a specific schedule entry.
Information describing a scheduled entry is retained for 30 days after its end time.
You may not use this endpoint to retrieve placeholder schedule entries.
Request syntax:
Request syntax for a deleted schedule entry:
Define the following variables when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Required |
Identifies a schedule entry by either its system-defined or external ID. Use the Get Multiple Schedule Entries endpoint to retrieve schedule entries and their IDs. |
By default, attempting to retrieve a deleted schedule entry returns a 404 Not Found. Pass include_deleted=1 to retrieve data for a deleted schedule entry. The deleted response property is included for deleted schedule entries.
Pass a digital signature based off of msg.
The response for a successful request contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to an endpoint that returns this schedule entry. You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-. |
@type |
String |
Returns Schedule. |
ad_breaks |
List of integers |
Indicates the duration for each ad break associated with the asset. |
content_id |
String |
content_type: asset Identifies an asset by its system-defined ID |
content_owner |
String |
content_type: slicer Only Identifies the user that owns the scheduled Live Slicer by its system-defined ID. This property is only returned for Live Slicers that belong to another user. |
content_type |
String |
Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
created |
String |
Indicates the timestamp (UTC) at which the schedule entry was created. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
deleted |
String |
include_deleted=1 Only Indicates the timestamp (UTC) at which the schedule entry was deleted. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
desc |
String |
Indicates the schedule entry's description.
Schedule entries created through the CMS are not assigned a description. |
dur |
Integer |
Indicates the schedule entry's duration in milliseconds. |
end |
String |
Indicates the schedule entry's end time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
external_id |
String |
Indicates a schedule entry's custom ID. |
id |
String |
Identifies a schedule entry by its system-defined ID. |
lastmod |
String |
Indicates the timestamp (UTC) at which the schedule entry was last modified. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
offset |
Integer |
Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past. Example: An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000. |
owner |
String |
Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
start |
String |
Indicates the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
type |
String |
Indicates the type of schedule entry. Valid values are:
|
Call the get_schedule_entry module (Python 3) to retrieve a specific schedule entry. This module imports names from the api_auth module.
import requests from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. schedule_id = '2158c7452b7841158972e019a5bd5f12' # Replace with the ID for the desired schedule entry. class ScheduleEntry: def __init__(self): self.host = "https://services.uplynk.com" def run(self): self._get_schedule_entry() def _get_schedule_entry(self): url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules/", schedule_id) headers = {'Content-Type': 'application/json'} response = requests.get( url, params=APIParams(APICredentials()).get_params({}), headers=headers ) print(response.json()) ScheduleEntry().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12', '@type': 'Schedule', 'created': '2021-02-16T00:57:10.402Z', 'lastmod': '2021-02-16T00:57:10.402Z', 'id': '2158c7452b7841158972e019a5bd5f12', 'owner': 'ab533864a92b46a1a286cdd49b0a9bd3', 'content_id': 'ae071e89574248c2ab179fe73d436c3e', 'content_type': 'asset', 'desc': 'Sports Segment', 'dur': 2343598, 'external_id': '', 'start': '2021-02-16T00:57:10.402Z', 'end': '2021-02-16T01:36:14.000Z', 'type': 'Time', 'ad_breaks': [] }
Updates a specific schedule entry.
You may only update schedule entries that occur in the future. Current or past schedule entries may not be modified.
Request syntax:
Define the following variables when submitting the above request:
VariableA variable represents a value that must be replaced. A variable consists of either a URL segment (e.g., "0001" in /0001/) or a query string value (e.g., "3" in mediaTypes=3). | Description |
---|---|
Required |
Identifies a live channel by its system-defined ID. |
Required |
Identifies a schedule entry by its system-defined ID. Use the Get Multiple Schedule Entries endpoint to retrieve schedule entries and their system-defined IDs. |
Request body:
Define a schedule entry through the following properties:
Name |
Data Type |
Description |
---|---|---|
ad_breaks |
List of integers |
Determines the duration for each ad break associated with the asset. Key information:
|
conflict_resolution |
String |
Determines how scheduling conflicts are handled. Valid values are:
Prevent previously scheduled entries from being overwritten by excluding this property from the request. Omitting this property causes our service to respond with a 409 Conflict when a scheduling conflict arises. Trimming an asset can affect the number of ads served. Specifically, we will not serve ads for an ad break positioned within a portion of the asset that is trimmed. |
content_id |
String |
content_type: asset Identifies an asset by its system-defined ID You may only schedule another user's Live Slicer if it is streaming to a library shared with your account. |
content_owner |
String |
content_type: slicer Only Identifies the user that owns the scheduled Live Slicer by its system-defined ID. |
content_type |
String |
Determines whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
desc |
String |
Defines the schedule entry's description. |
dur |
Integer |
Determines the schedule entry's duration in milliseconds. Key information:
|
external_id |
String |
Defines a schedule entry's custom ID. |
overwrite Deprecated |
String |
Determines how scheduling conflicts are handled. The conflict_resolution property takes precedence over this deprecated property. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
start |
String |
Determines the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
Key information:
|
Pass a digital signature based off of msg.
The response for a successful request contains the following properties:
Name |
Data Type |
Description |
---|---|---|
@id |
String |
Indicates the relative path to an endpoint that returns this schedule entry. You may not retrieve placeholder schedule entries by ID since they do not actually exist. Our system returns an invalid endpoint for placeholder schedule entries that starts with empty-. |
@type |
String |
Returns Schedule. |
ad_breaks |
List of integers |
Indicates the duration for each ad break associated with the asset. |
content_id |
String |
content_type: asset Identifies an asset by its system-defined ID |
content_owner |
String |
content_type: slicer Only Identifies the user that owns the scheduled Live Slicer by its system-defined ID. This property is only returned for Live Slicers that belong to another user. |
content_type |
String |
Indicates whether the schedule entry points to an asset, ad break, or Live Slicer, or previously scheduled content. Valid values are: ad | asset | slicer | replay_source
|
created |
String |
Indicates the timestamp (UTC) at which the schedule entry was created. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
deleted |
String |
include_deleted=1 Only Indicates the timestamp (UTC) at which the schedule entry was deleted. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
desc |
String |
Indicates the schedule entry's description.
Schedule entries created through the CMS are not assigned a description. |
dur |
Integer |
Indicates the schedule entry's duration in milliseconds. |
end |
String |
Indicates the schedule entry's end time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
external_id |
String |
Indicates a schedule entry's custom ID. |
id |
String |
Identifies a schedule entry by its system-defined ID. |
lastmod |
String |
Indicates the timestamp (UTC) at which the schedule entry was last modified. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
offset |
Integer |
Indicates playback offset in milliseconds. Playback offset occurs when an asset or ad break is scheduled to start in the past. Example: An offset value of 60000 is reported when an asset is scheduled for a minute in the past. For example, scheduling an asset for 11:00 AM when the current time is 11:01 AM generates an offset value of 60000. |
owner |
String |
Indicates the system-defined ID for the user that owns the live channel associated with this schedule entry. |
replaced_by |
String |
Indicates the system-defined ID for the schedule entry that overwrote the current schedule entry. |
replay_source | String |
content_type only Specifies the time frame of the content that should be played. Required values for replay_source as content_type: content_id, content_type, desc, dur, replay_source_start, replay_source_end. |
replay_source_end | String |
content_type: replay_source only Specifies the time (UTC) the content should stop playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
replay_source_start | String |
content_type: replay_source only Specifies the time (UTC) the content should begin playing. Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
start |
String |
Indicates the schedule entry's start time (UTC). Syntax (ISO 8601): YYYY-MM-DDThh:mm:ss.sssZ
|
type |
String |
Indicates the type of schedule entry. Valid values are:
|
Call the update_schedule_entry module (Python 3) to update a schedule entry. This module imports names from the api_auth module.
import json, requests, datetime, time from api_auth import APICredentials, APIParams channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel. schedule_id = '2158c7452b7841158972e019a5bd5f12' # Replace with the ID for the desired schedule entry. def convert_ts(utc_tstamp): """ Convert a UTC timestamp to ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ). :param utc_tstamp: The UTC timestamp to convert (expected milliseconds) """ iso_format = "%Y-%m-%dT%H:%M:%S.%fZ" try: _ts = float("{0:.3f}".format(utc_tstamp/1000.0)) return "{}{}".format(datetime.datetime.utcfromtimestamp(_ts).strftime(iso_format)[:-4], "Z") except Exception: print ("Invalid timestamp: {}".format(utc_tstamp)) raise class ScheduleEntry: def __init__(self): self.host = "https://services.uplynk.com" def run(self): """ Update a schedule entry. """ self._update_schedule_entry() def _update_schedule_entry(self): url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/schedules/", schedule_id) start = int((time.time() + 7200) * 1000.0) # 2 hours from now start = convert_ts(start) payload = { 'start': start } headers = {'Content-Type': 'application/json'} response = requests.patch( url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers ) print(response.json()) ScheduleEntry().run()
Response:
{ '@id': '/channels/Hak3zjnPLSW5o0j8GMpzRMsa/schedules/2158c7452b7841158972e019a5bd5f12', '@type': 'Schedule', 'created': '2021-02-16T00:57:10.402Z', 'lastmod': '2021-02-16T00:57:10.402Z', 'id': '2158c7452b7841158972e019a5bd5f12', 'owner': 'ab533864a92b46a1a286cdd49b0a9bd3', 'content_id': 'ae071e89574248c2ab179fe73d436c3e', 'content_type': 'asset', 'desc': 'Sports Segment', 'dur': 2343598, 'external_id': '', 'start': '2021-02-16T00:57:10.402Z', 'end': '2021-02-16T01:36:14.000Z', 'type': 'Time', 'ad_breaks': [] }