Skip to content

Add support for replacing Vimeo video (Issue #55) #66

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
53c6234
A suggested fix to remove ambiguity conflict with a JSON library like…
michaelboccara Dec 23, 2018
9cc33f5
WIP: add support for replacing existing video. But I get an error mes…
michaelboccara Dec 23, 2018
34ef5e5
WIP: add support for replacing existing video. But I get an error mes…
michaelboccara Dec 23, 2018
e03cebf
Revert "WIP: add support for replacing existing video. But I get an e…
michaelstv Jan 3, 2019
96d5ca2
Merge remote-tracking branch 'vimeo/master'
michaelstv Jan 3, 2019
da11331
In previous commit, didn't pass the token in since it is setting the …
michaelstv Jan 3, 2019
7ee7c77
More robust test for empty JSON fields
michaelstv Jan 3, 2019
8870370
Pass in just the file name and not the full_path. The file_name is us…
michaelstv Jan 3, 2019
7631d62
rename parameter, forgotten from previous commit
michaelstv Jan 3, 2019
7e5ec36
Fix a regex to detect the video id correctly from the vimeo URI. The …
michaelboccara Jan 4, 2019
52e7dc8
Replace recorded video name
michaelboccara Jan 4, 2019
d387968
Merge remote-tracking branch 'origin/master' into feature/fix_issue_55
michaelboccara Jan 6, 2019
0c26d9a
Internal accessibility is not enough for VimeoVideo.GetVideoName
michaelboccara Jan 6, 2019
4631a5f
Handler for upload errors
michaelboccara Jan 6, 2019
5466a78
Merge branch 'feature/upload_errors' into feature/fix_issue_55
michaelboccara Jan 6, 2019
2c0e3aa
Replace recorded video id based on video name
michaelboccara Jan 6, 2019
4421291
When replacing videos, if doing it based on the video's name, we need…
michaelboccara Feb 10, 2019
5baba13
More fixed in video replacement feature
michaelstv Feb 11, 2019
b42d1d9
Merge branch 'master' into feature/fix_issue_55
michaelboccara Feb 15, 2019
2cf3052
Better handling of upload errors (after it happened to me upon reachi…
michaelstv Feb 17, 2019
5845393
1- A new option to set explicit vimeo video id when replacing vimeo v…
michaelstv Feb 25, 2019
cf54e51
Better handling of vimeo video id passed as input
michaelstv Feb 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Assets/Vimeo/Scripts/Config/PlayerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class PlayerSettings : VimeoSettings
public Depthkit.Depthkit_Clip depthKitClip;
#endif
public StreamingResolution selectedResolution = StreamingResolution.x2160p_4K;
public string vimeoVideoId;
public bool muteAudio = false;
public bool autoPlay = true;
public int startTime = 0;
Expand Down
46 changes: 46 additions & 0 deletions Assets/Vimeo/Scripts/Config/RecorderSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public class RecorderSettings : VimeoSettings

public RenderTexture renderTextureTarget;

[TextArea(2, 5)]
public string description;

public bool replaceExisting = false;
public VimeoApi.PrivacyModeDisplay privacyMode = VimeoApi.PrivacyModeDisplay.Anyone;
public VimeoApi.CommentMode commentMode = VimeoApi.CommentMode.Anyone;
public bool enableDownloads = true;
Expand Down Expand Up @@ -127,6 +131,48 @@ public string ReplaceSpecialChars(string input)

return input;
}

public void SetVimeoIdFromName()
{
if (!string.IsNullOrEmpty(videoName))
{
for (int i = 0; i < vimeoVideos.Count; i++)
{
var video = vimeoVideos[i];
if (video.GetVideoName() == videoName)
{
currentVideo = video;
vimeoVideoId = video.id.ToString();
description = video.description;
break;
}
}
}
}

public void SetVimeoVideoFromId()
{
if (!string.IsNullOrEmpty(vimeoVideoId))
{
for (int i = 0; i < vimeoVideos.Count; i++)
{
var video = vimeoVideos[i];
if (video.id.ToString() == vimeoVideoId)
{
currentVideo = video;
if (string.IsNullOrEmpty(videoName))
{
videoName = video.GetVideoName();
}
if (string.IsNullOrEmpty(description))
{
description = video.description;
}
break;
}
}
}
}
}

public class AspectRatioHelper
Expand Down
3 changes: 3 additions & 0 deletions Assets/Vimeo/Scripts/Config/VimeoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class VimeoSettings : MonoBehaviour
public bool signInError = false;
private const string VIMEO_TOKEN_PREFIX = "vimeo-token-";

// Played or Overwritten video
public string vimeoVideoId;

public int GetCurrentFolderIndex()
{
if (currentFolder != null) {
Expand Down
40 changes: 27 additions & 13 deletions Assets/Vimeo/Scripts/Config/VimeoVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public VimeoVideo(string _name, string _uri = null)
name = _name;
uri = _uri;
if (_uri != null) {
string[] matches = Regex.Split(_uri, "/([0-9]+)$");
string[] matches = Regex.Split(_uri, "/([0-9]+)");
if (matches.Length > 1) {
id = int.Parse(matches[1]);
}
Expand All @@ -42,38 +42,38 @@ public VimeoVideo(string _name, string _uri = null)

public VimeoVideo(JSONNode video)
{
if (video["name"] != null) {
if (!JSONNode.IsNullNode(video["name"])) {
name = video["name"].Value;
}

if (video["uri"] != null) {
if (!JSONNode.IsNullNode(video["uri"])) {
uri = video["uri"].Value;
}

if (video["description"] != null) {
description = video["description"].Value;
if (!JSONNode.IsNullNode(video["description"])) {
description = UnescapeNewLines(video["description"].Value);
}

if (video["duration"] != null) {
if (!JSONNode.IsNullNode(video["duration"])) {
duration = int.Parse(video["duration"].Value);
}

if (video["width"] != null) {
if (!JSONNode.IsNullNode(video["width"])) {
width = int.Parse(video["width"].Value);
}

if (video["height"] != null) {
if (!JSONNode.IsNullNode(video["height"])) {
height = int.Parse(video["height"].Value);
}

if (video["spatial"] != null && !video["spatial"].IsNull) {
if (!JSONNode.IsNullNode(video["spatial"])) {
is3D = true;
projection = video["spatial"]["projection"].Value;
stereoFormat = video["spatial"]["stereo_format"].Value;
}

if (uri != null) {
string[] matches = Regex.Split(uri, "/([0-9]+)$");
string[] matches = Regex.Split(uri, "/([0-9]+)");
if (matches.Length > 1) {
id = int.Parse(matches[1]);
name = name + " (" + id + ")";
Expand Down Expand Up @@ -111,6 +111,20 @@ public VimeoVideo(JSONNode video)
}
}

private static string UnescapeNewLines(string text)
{
return text.Replace("\\n", "\n");
}

public string GetVideoName()
{
string videoIdParenthesisSuffix = " (" + id + ")";
if (name.EndsWith(videoIdParenthesisSuffix)) {
return name.Substring(0, name.Length - videoIdParenthesisSuffix.Length);
}
return name;
}

public int CompareTo(VimeoVideo other)
{
if (other == null) {
Expand Down
Loading