Update a Project
update a Project
To update a project.
PUT
https://api.dyntube.com/v1/projects/{id}
The content type of the HTTP request should be application/json. Please have a look at the sample JSON body below.
{
"pager": {
"page": 1,
"size": 12,
"hits": 12,
"total": 1300,
"pages": 109
},
"views": [
{
"id": "NZDSFhZ2",
"videoKey": "NN8GgcLjTsbUg",
"accountKey": "8t9ym1JSJuCZg",
"projectKey": "5lCohVbzSymGw",
"channelKey": "tEOqkbUhB6NOw",
"channelViewId": "NggYmvRvw",
"planType": 1,
"viewerId": "kQdFThzl6e0",
"viewId": "8LsRTyu2S",
"date": "2020-08-01T12:42:14.08+00:00",
"region": "use-s",
"started": true,
"ended": false,
"muted": false,
"duration": 150,
"watchTime": 0,
"browser": {
"family": "Firefox",
"major": 82,
"minor": 0
},
"device": {
"family": "Other",
"brand": "",
"model": "",
"type": "Desktop"
},
"os": {
"family": "Windows",
"major": 10,
"processor": "x64"
},
"geo": {
"ip": "121.121.60.0",
"city": "Kuala Lumpur",
"country": "MY",
"region": "Kuala Lumpur",
"continent": "AS"
},
"embed": {
"url": "https://www.dyntube.com/",
"domain": "www.dyntube.com",
"type": 1
},
"userKey": ""
}
]
}
Sample JSON Body
Here is a sample JSON request to update a project.
{
"id": "MgLVvAV7",
"key": "Qss0qX27ZQ",
"name": "Videos",
"description": "",
"region": "usw-s",
"planType": 1,
"options": {
"convertToHls": true,
"convertToMp4": false,
"convertToOneMp4": true,
"useOriginalMp4": false,
"hlsEncrypt": false,
"bitrate240p": 400,
"bitrate360p": 1200,
"bitrate540p": 1800,
"bitrate720p": 3750,
"bitrate1080p": 5625,
"bitrate1440p": 0,
"bitrate2160p": 0,
"saveOriginalVideos": false
},
"videoOptions": {
"autoplay": false,
"playerSkin": "solid",
"controlsColor": "",
"primaryColor": "",
"seekButtons": false,
"volumeControl": true,
"preload": "auto",
"fullscreenControl": true,
"controls": true,
"captionsOn": false,
"bigPlayControl": true,
"defaultQuality": "",
"qualityControl": true,
"speedControl": true,
"fastForward": true,
"volume": 1.0,
"loop": false,
"muted": false,
"landscapeFullscreen": false,
"modal": false,
"resumePlayback": false,
"hideLogo": false,
"cast": true,
"extraSecurity": false,
"stickyPlayer": false,
"pauseOnScroll": false,
"storeAuth": false,
"contextMenu": false
},
"status": 1,
"created": "2020-05-27T07:47:52.362+00:00",
"updated": "2020-05-27T07:47:52.362+00:00"
}
C# Sample
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;
namespace ProjectUpdate
{
class Program
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "your_bearer_token");
var id = "MgLVvAV7";
var url = "https://api.dyntube.com/v1/projects/" + id;
var data = new
{
name = "New Name",
description = "New Description",
options = new
{
convertToHls = true,
convertToMp4 = false,
convertToOneMp4 = true,
useOriginalMp4 = false,
hlsEncrypt = false,
bitrate240p = 400,
bitrate360p = 1200,
bitrate540p = 1800,
bitrate720p = 3750,
bitrate1080p = 5625,
bitrate1440p = 0,
bitrate2160p = 0,
saveOriginalVideos = false
},
videoOptions = new
{
autoplay = false,
playerSkin = "solid",
controlsColor = "",
primaryColor = "",
seekButtons = false,
volumeControl = true,
preload = "auto",
fullscreenControl = true,
controls = true,
captionsOn = false,
bigPlayControl = true,
defaultQuality = "",
qualityControl = true,
speedControl = true,
fastForward = true,
volume = 1.0,
loop = false,
muted = false,
landscapeFullscreen = false,
modal = false,
resumePlayback = false,
hideLogo = false,
cast = true,
extraSecurity = false,
stickyPlayer = false,
pauseOnScroll = false,
storeAuth = false,
contextMenu = false
}
};
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri(url),
Content = new StringContent(JsonSerializer.Serialize(data), System.Text.Encoding.UTF8, "application/json")
};
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Project updated successfully.");
Node.js Sample
const axios = require('axios');
async function updateProject(projectId, bearerToken, name, description, region, planType, options, videoOptions, status) {
const url = `https://api.dyntube.com/v1/projects/${projectId}`;
const payload = {
name,
description,
region,
planType,
options,
videoOptions,
status
};
try {
const response = await axios.put(url, payload, {
headers: {
Authorization: `Bearer ${bearerToken}`
}
});
console.log(`Project with ID ${projectId} updated successfully`);
console.log(response.data);
} catch (error) {
console.error(`Failed to update project with ID ${projectId}: ${error}`);
}
}
updateProject(
'MgLVvAV7',
'your_bearer_token',
'My Videos',
'',
'usw-s',
1,
{
convertToHls: true,
convertToMp4: false,
convertToOneMp4: true,
useOriginalMp4: false,
hlsEncrypt: false,
bitrate240p: 400,
bitrate360p: 1200,
bitrate540p: 1800,
bitrate720p: 3750,
bitrate1080p: 5625,
bitrate1440p: 0,
bitrate2160p: 0,
saveOriginalVideos: false
},
{
autoplay: false,
playerSkin: 'solid',
controlsColor: '',
primaryColor: '',
seekButtons: false,
volumeControl: true,
preload: 'auto',
fullscreenControl: true,
controls: true,
captionsOn: false,
bigPlayControl: true,
defaultQuality: '',
qualityControl: true,
speedControl: true,
fastForward: true,
volume: 1.0,
loop: false,
muted: false,
landscapeFullscreen: false,
modal: false,
resumePlayback: false,
hideLogo: false,
cast: true,
extraSecurity: false,
stickyPlayer: false,
pauseOnScroll: false,
storeAuth: false,
contextMenu: false
},
1
);
Python
import requests
import json
bearer_token = "your_bearer_token"
project_id = "your_project_id"
url = f"https://api.dyntube.com/v1/projects/{project_id}"
headers = {
"Authorization": f"Bearer {bearer_token}",
"Content-Type": "application/json"
}
data = {
"name": "New Project Name",
"description": "New Project Description",
"region": "usw-s",
"options": {
"convertToHls": True,
"convertToMp4": False,
"convertToOneMp4": True,
"useOriginalMp4": False,
"hlsEncrypt": False,
"bitrate240p": 400,
"bitrate360p": 1200,
"bitrate540p": 1800,
"bitrate720p": 3750,
"bitrate1080p": 5625,
"bitrate1440p": 0,
"bitrate2160p": 0,
"saveOriginalVideos": False
},
"videoOptions": {
"autoplay": False,
"playerSkin": "solid",
"controlsColor": "",
"primaryColor": "",
"seekButtons": False,
"volumeControl": True,
"preload": "auto",
"fullscreenControl": True,
"controls": True,
"captionsOn": False,
"bigPlayControl": True,
"defaultQuality": "",
"qualityControl": True,
"speedControl": True,
"fastForward": True,
"volume": 1.0,
"loop": False,
"muted": False,
"landscapeFullscreen": False,
"modal": False,
"resumePlayback": False,
"hideLogo": False,
"cast": True,
"extraSecurity": False,
"stickyPlayer": False,
"pauseOnScroll": False,
"storeAuth": False,
"contextMenu": False
}
}
response = requests.put(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print("Project updated successfully.")
else:
print(f"Error updating project. Status code: {response.status_code}")
PHP
<?php
$projectId = "your_project_id";
$bearerToken = "your_bearer_token";
$remoteServerUrl = "https://api.dyntube.com/v1/projects/$projectId";
// Create the request payload
$data = array(
'name' => 'New Project Name',
'description' => 'New Project Description',
'region' => 'use-s',
'planType' => 1,
'options' => array(
'convertToHls' => true,
'convertToMp4' => false,
'convertToOneMp4' => true,
'useOriginalMp4' => false,
'hlsEncrypt' => false,
'bitrate240p' => 400,
'bitrate360p' => 1200,
'bitrate540p' => 1800,
'bitrate720p' => 3750,
'bitrate1080p' => 5625,
'bitrate1440p' => 0,
'bitrate2160p' => 0,
'saveOriginalVideos' => false
),
'videoOptions' => array(
'autoplay' => false,
'playerSkin' => 'solid',
'controlsColor' => '',
'primaryColor' => '',
'seekButtons' => false,
'volumeControl' => true,
'preload' => 'auto',
'fullscreenControl' => true,
'controls' => true,
'captionsOn' => false,
'bigPlayControl' => true,
'defaultQuality' => '',
'qualityControl' => true,
'speedControl' => true,
'fastForward' => true,
'volume' => 1.0,
'loop' => false,
'muted' => false,
'landscapeFullscreen' => false,
'modal' => false,
'resumePlayback' => false,
'hideLogo' => false,
'cast' => true,
'extraSecurity' => false,
'stickyPlayer' => false,
'pauseOnScroll' => false,
'storeAuth' => false,
'contextMenu' => false
)
);
// Encode the data as JSON
$data_json = json_encode($data);
// Set the HTTP headers
$headers = array(
'Content-Type: application/json',
'Authorization: Bearer ' . $bearerToken
);
// Set up the cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $remoteServerUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute the request and get the response
$response = curl_exec($ch);
// Check the response status code
$http_status_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($http_status_code == 200) {
echo "Project updated successfully.\n";
} else {
echo "Project update failed with status code: " . $http_status_code . "\n";
}
// Close the cURL session
curl_close($ch);
Last updated