def get(self, uri): params = (""" {"query": { "source": "%s", "format": [ {"output": "metadata", "metadata_version": "4.1.5"} ] } } """ % uri) self.custom_start(params) while True: status = self.status() # print status # print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5) if self.error: raise QencodeTaskException(self.message) url = None if len(status['videos']) > 0: url = status['videos'][0]['url'] elif len(status['audios']) > 0: url = status['audios'][0]['url'] if url is None: raise QencodeTaskException( 'No metadata URL found in status response') data = urllib2.urlopen(url).read() return data
def start_encode(): clientq = qencode.client(API_KEY) if clientq.error: raise QencodeClientException(clientq.message) print('The client created. Expire date: %s' % clientq.expire) task = clientq.create_task() if task.error: raise QencodeTaskException(task.message) fileUrl = task.upload_url + '/' + task.task_token res = tus_uploader.upload(file_path=file_path, url=fileUrl, log_func=log_upload, chunk_size=200000) params.source = res.url task.custom_start(params) if task.error: raise QencodeTaskException(task.message) print('Start encode. Task: %s' % task.task_token) while True: status = task.status() # print status print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5)
def start_encode(): """ Create client object :param api_key: string. required :param api_url: string. not required :param api_version: int. not required. default 'v1' :return: task object """ client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire task = client.create_task() if task.error: raise QencodeTaskException(task.message) task.custom_start(params) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.status() # print status print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5)
def start_encode(): """ Create client object :param api_key: string. required :param api_url: string. not required :param api_version: int. not required. default 'v1' :return: task object """ client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire task = client.create_task() task.start_time = 0.0 task.duration = 10.0 if task.error: raise QencodeTaskException(task.message) task.start(TRANSCODING_PROFILEID, VIDEO_URL) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token # using callback methods task.progress_changed(progress_changed_handler) task.task_completed(task_completed_handler, task.task_token)
def start_encode(): """ Create client object :param api_key: string. required :param api_url: string. not required :param api_version: int. not required. default 'v1' :return: task object """ client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire task = client.create_task() if task.error: raise QencodeTaskException(task.message) #get upload url from endpoint returned with /v1/create_task and task_token value uploadUrl = task.upload_url + '/' + task.task_token #do upload and get uploaded file URI uploadedFile = tus_uploader.upload(file_path=file_path, url=uploadUrl, log_func=log_upload, chunk_size=2000000) params = query % uploadedFile.url task.custom_start(params) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.status() # print status print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5)
def start_encode(): """ Create client object :param api_key: string. required :param api_url: string. not required :param api_version: int. not required. default 'v1' :return: task object """ client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire task = client.create_task() if task.error: raise QencodeTaskException(task.message) encryption_parameters, payload = cenc_drm(DRM_USERNAME, DRW_PASSWORD) #encryption_parameters, payload = fps_drm(DRM_USERNAME, DRW_PASSWORD) query = QUERY.replace('{cenc_drm}', json.dumps(encryption_parameters)) task.custom_start(query) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.extend_status() # print status print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5)
def start_encode(): """ Create client object :param api_key: string. required :param api_url: string. not required :param api_version: int. not required. default 'v1' :return: task object """ client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire task = client.create_task() task.start_time = 0.0 task.duration = 10.0 if task.error: raise QencodeTaskException(task.message) task.start(TRANSCODING_PROFILEID, VIDEO_URL) #or stitch #task.start(TRANSCODING_PROFILEID, STITCH) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.status() print json.dumps(status, indent=2, sort_keys=True) # print status if status['error'] or status['status'] == 'completed': break time.sleep(5)
def start_encode(): # this creates signed request to BuyDRM cpix_request = create_cpix_user_request(key_ids, media_id, USER_PVT_KEY_PATH, USER_PUB_CERT_PATH, use_playready=True, use_widevine=True) client = qencode.client(API_KEY) if client.error: raise QencodeClientException(client.message) print 'The client created. Expire date: %s' % client.expire task = client.create_task() if task.error: raise QencodeTaskException(task.message) query = QUERY.replace('{cpix_request}', base64.b64encode(cpix_request)) task.custom_start(query) if task.error: raise QencodeTaskException(task.message) print 'Start encode. Task: %s' % task.task_token while True: status = task.status() # print status print json.dumps(status, indent=2, sort_keys=True) if status['error'] or status['status'] == 'completed': break time.sleep(5)