import json
import requests
from api_auth import APICredentials, APIParams
  
class PublishingSchedule:
    def __init__(self):
        self.host = "https://services.uplynk.com"
  
    def run(self):
        self._create_publishing_schedule()
 
    def _create_publishing_schedule(self):
        url = "{}{}".format(self.host, "/api/v4/syndication-schedule")
 
        publishing_target_id = 'd30f655670cb426c98cd28afb6291bf4'
        content_type = 'c'
        content_id = '1df8d13992cd4222a7343b8fafd89cd7'
         
        payload = {
            'syndication_target_id': publishing_target_id,
            'video_quality': 'medium',
            'content_id': content_id,
            'content_type': content_type,
            'source_stream': 'https://content.uplynk.com/channel/1df8d13992cd4222a7343b8fafd89cd7.m3u8'
        }
 
        headers = {'Content-Type': 'application/json'}
 
        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers
        )
 
        print(response.json())
  
PublishingSchedule().run()