Skip to content

Commit 68e496d

Browse files
committed
Fallback to the main api server in case can't get status from master
1 parent 23e0ea8 commit 68e496d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PHP library for interacting with the Qencode API.
1313
```json
1414
{
1515
"require": {
16-
"qencode/api-client": "1.09.*"
16+
"qencode/api-client": "1.10.*"
1717
}
1818
}
1919
```

src/Classes/TranscodingTask.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function start($transcodingProfiles, $uri = null, $transferMethod = null,
8686
'task_token' => $this->taskToken,
8787
'profiles' => is_array($transcodingProfiles) ? implode(',', $transcodingProfiles) : $transcodingProfiles
8888
);
89-
//echo 'stitchVideoItems: '.print_r($this->stitchVideoItems, true);
9089
$arrays = null;
9190
if (is_array($this->stitchVideoItems)) {
9291
$arrays = array('stitch' => $this->stitchVideoItems);
@@ -141,7 +140,6 @@ public function startCustom($task_params, $payload = null) {
141140
}
142141

143142
$query_json = preg_replace('/,\s*"[^"]+":null|"[^"]+":null,?/', '', $query_json);
144-
// echo $query_json."\n\n";
145143
$params = array(
146144
'task_token' => $this->taskToken,
147145
'query' => $query_json
@@ -161,9 +159,16 @@ public function startCustom($task_params, $payload = null) {
161159
*/
162160
public function getStatus() {
163161
$params = array('task_tokens[]' => $this->taskToken);
164-
//TODO: fallback to /v1/status
165-
$response = $this->api->post($this->statusUrl, $params);
166-
$this->lastStatus = $response['statuses'][$this->taskToken];
162+
163+
try {
164+
$response = $this->api->post($this->statusUrl, $params);
165+
} catch (Exception $e) {
166+
// If the post request fails, fallback to the default URL
167+
$this->statusUrl = 'https://api.qencode.com/v1/status';
168+
$response = $this->api->post($this->statusUrl, $params);
169+
}
170+
171+
$this->lastxStatus = $response['statuses'][$this->taskToken];
167172
if ($this->lastStatus == null) {
168173
throw new QencodeClientException('Task '. $this->taskToken. ' not found!');
169174
}

0 commit comments

Comments
 (0)