-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding API methods for adding captioning files #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,18 +430,63 @@ private BrightcoveImage DoAddImage(BrightcoveImage image, FileUploadInfo fileUpl | |
return RunFilePost<BrightcoveResultContainer<BrightcoveImage>>(parms, fileUploadInfo).Result; | ||
} | ||
|
||
#endregion | ||
|
||
#region AddLogoOverlay | ||
|
||
/// <summary> | ||
/// Adds a logo overlay image to a video. | ||
/// </summary> | ||
/// <param name="logoOverlay">The metadata for the logo overlay you'd like to create (or update).</param> | ||
/// <param name="fileUploadInfo">Information for the file to be uploaded.</param> | ||
/// <param name="videoId">The ID of the video you want to assign a logo overlay to.</param> | ||
/// <returns>The newly created or updated BrightcoveLogoOverlay</returns> | ||
public BrightcoveLogoOverlay AddLogoOverlay(BrightcoveLogoOverlay logoOverlay, FileUploadInfo fileUploadInfo, long videoId) | ||
#endregion | ||
|
||
#region AddCaptioning | ||
public void AddCaptioning(string captionFileUrl, long videoId, string filename) | ||
{ | ||
string propName; | ||
object propValue; | ||
GetIdValuesForUpload(videoId, null, "video_id", "video_reference_id", out propName, out propValue); | ||
|
||
var captionSource = new CaptionSource { | ||
Complete = true, | ||
IsRemote = true, | ||
DisplayName = filename, | ||
Url = captionFileUrl | ||
}; | ||
|
||
BrightcoveParamCollection parms = CreateWriteParamCollection("add_captioning", | ||
methodParams => { | ||
methodParams.Add(propName, propValue); | ||
methodParams.Add("caption_source", captionSource); | ||
methodParams.Add("filename", filename); | ||
}); | ||
RunPost<BrightcoveResultContainer<long>>(parms); | ||
} | ||
|
||
public void AddCaptioning(FileUploadInfo captionFileUploadInfo, long videoId, string filename) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this one will rely on us uploading an actual file created from a |
||
{ | ||
string propName; | ||
object propValue; | ||
GetIdValuesForUpload(videoId, null, "video_id", "video_reference_id", out propName, out propValue); | ||
|
||
var captionSource = new CaptionSource { | ||
Complete = true, | ||
IsRemote = false, | ||
DisplayName = filename, | ||
}; | ||
|
||
BrightcoveParamCollection parms = CreateWriteParamCollection("add_captioning", | ||
methodParams => { | ||
methodParams.Add(propName, propValue); | ||
methodParams.Add("caption_source", captionSource); | ||
methodParams.Add("filename", filename); | ||
}); | ||
RunFilePost<BrightcoveResultContainer<long>>(parms, captionFileUploadInfo); | ||
} | ||
#endregion | ||
|
||
#region AddLogoOverlay | ||
|
||
/// <summary> | ||
/// Adds a logo overlay image to a video. | ||
/// </summary> | ||
/// <param name="logoOverlay">The metadata for the logo overlay you'd like to create (or update).</param> | ||
/// <param name="fileUploadInfo">Information for the file to be uploaded.</param> | ||
/// <param name="videoId">The ID of the video you want to assign a logo overlay to.</param> | ||
/// <returns>The newly created or updated BrightcoveLogoOverlay</returns> | ||
public BrightcoveLogoOverlay AddLogoOverlay(BrightcoveLogoOverlay logoOverlay, FileUploadInfo fileUploadInfo, long videoId) | ||
{ | ||
return DoAddLogoOverlay(logoOverlay, fileUploadInfo, videoId, null); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web.Script.Serialization; | ||
using BrightcoveMapiWrapper.Serialization; | ||
using BrightcoveMapiWrapper.Util; | ||
|
||
namespace BrightcoveMapiWrapper.Model.Items | ||
{ | ||
/// <summary> | ||
/// A source that provides captions for a video (metadata) | ||
/// </summary> | ||
public class CaptionSource : BrightcoveItem, IJavaScriptConvertable | ||
{ | ||
/// <summary> | ||
/// A Boolean indicating whether a CaptionSource is usable. | ||
/// </summary> | ||
public bool Complete { get; set; } | ||
|
||
/// <summary> | ||
/// The name of the caption source, which will be displayed in the Media module. | ||
/// </summary> | ||
public string DisplayName { get; set; } | ||
|
||
/// <summary> | ||
/// A number that uniquely identifies this CaptionSource object, | ||
/// assigned by Video Cloud when this object is created. | ||
/// </summary> | ||
public long? Id { get; set; } | ||
|
||
/// <summary> | ||
/// A Boolean indicating whether or not this CaptionSource is hosted on a remote server, | ||
/// as opposed to hosted by Brightcove. | ||
/// </summary> | ||
public bool IsRemote { get; set; } | ||
|
||
/// <summary> | ||
/// The complete path to the file. | ||
/// </summary> | ||
public string Url { get; set; } | ||
|
||
public IDictionary<string, object> Serialize(JavaScriptSerializer serializer) | ||
{ | ||
IDictionary<string, object> serialized = new Dictionary<string, object>(); | ||
|
||
serialized["complete"] = Complete; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This is ugly. Yes, it can be resolved with json.net and simple conversion settings, but it was done like this everywhere else, so I followed convention. |
||
serialized["displayName"] = DisplayName; | ||
serialized["id"] = Id ?? 0; | ||
serialized["isRemote"] = IsRemote; | ||
serialized["url"] = Url; | ||
|
||
return serialized; | ||
} | ||
|
||
public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer) | ||
{ | ||
foreach (string key in dictionary.Keys) | ||
{ | ||
switch (key) | ||
{ | ||
case "error": | ||
ApiUtil.ThrowIfError(dictionary, key, serializer); | ||
break; | ||
|
||
case "complete": | ||
Complete = Convert.ToBoolean(dictionary[key]); | ||
break; | ||
|
||
case "displayName": | ||
DisplayName = Convert.ToString(dictionary[key]); | ||
break; | ||
|
||
case "id": | ||
Id = Convert.ToInt64(dictionary[key]); | ||
break; | ||
|
||
case "isRemote": | ||
IsRemote = Convert.ToBoolean(dictionary[key]); | ||
break; | ||
|
||
case "url": | ||
Url = Convert.ToString(dictionary[key]); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,11 @@ public static class ApiKeys | |
/// <summary> | ||
/// Read token taken from Brightcove's media API sample @ http://docs.brightcove.com/en/media/samples/search_videos.html. | ||
/// </summary> | ||
public const string ReadToken = "ZY4Ls9Hq6LCBgleGDTaFRDLWWBC8uoXQun0xEEXtlDUHBDPZBCOzbw.."; | ||
public const string ReadToken = "AIe8Zmp7bAq8paSBoLt_-1_jII2yjQ1Yd1yAQxmFK10NcfVmhVhiPQ.."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kish9nine in order to test locally, you can change these values to use your own |
||
|
||
/// <summary> | ||
/// Write token taken from Brightcove's media API sample @ http://docs.brightcove.com/en/media/samples/update_video.html. | ||
/// </summary> | ||
public const string WriteToken = "ZY4Ls9Hq6LCBgleGDTaFRDLWWBC8uoXQHkhGuDebKvjFPjHb3iT-4g.."; | ||
public const string WriteToken = "AIe8Zmp7bAq8paSBoLt_-1_jII2yjQ1YSMqMTaL8MS2Ins8VYKbJKQ.."; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.IO; | ||
using BrightcoveMapiWrapper.Api.Connectors; | ||
using NUnit.Framework; | ||
|
||
namespace BrightcoveOS.NET_MAPI_Wrapper.Tests.IntegrationTests.VideoWrite | ||
{ | ||
[TestFixture] | ||
public class AddCaptioningTest : VideoWriteTestBase | ||
{ | ||
/// <summary> | ||
/// Sample DFXP found here: | ||
/// https://s3-us-west-2.amazonaws.com/public-rev/captions/Example.dfxp | ||
/// </summary> | ||
private readonly string FileToUpload = @"C:\Temp\Example.dfxp"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Change to use an embedded resource |
||
|
||
[Test] | ||
public void AddCaptioning_ExternalUrl_VideoId() | ||
{ | ||
_api.AddCaptioning( | ||
"https://s3-us-west-2.amazonaws.com/public-rev/captions/Example.dfxp", 4348957026001, | ||
"TestFileName.dfxp"); | ||
} | ||
|
||
[Test] | ||
public void AddCaptioning_FileUploadInfo_VideoId() | ||
{ | ||
using (FileStream fs = File.OpenRead(FileToUpload)) | ||
{ | ||
var captionFileUplaodInfo = new FileUploadInfo(fs, "TestFileName.dfxp"); | ||
_api.AddCaptioning(captionFileUplaodInfo, 4348957026001, "TestFileName.dfxp"); | ||
} | ||
} | ||
|
||
//TODO: AddCaptioning_ExternalUrl_VideoRefId | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure if you were using Video IDs, or VideoRefs. Just implemented VideoIds for simplicity, if you need refs we can do that tomorrow @kish9nine |
||
//TODO: AddCaptioning_FileUploadInfo_VideoRefId | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method will allow posting a subtitle file that resides on an external URL