Help Splitting a URL (Video Upload)

HI

Im having trouble splitting a string to extract the URL from it.

I can do the image URL no issues using this

let rightSidephotopublicurlLink = "https://static.wixstatic.com/media/" + src.split("/")[3]; // Converts the WIX URL to a public URL

i created this URL from the above code.

//https://static.wixstatic.com/media/ff1990_75a5ad0af8c248c79db07b2f495b4b98~mv2.jpg

Originally the full URL looked like this till the code ran which is a WIX URL

//image://v1/ff1990_75a5ad0af8c248c79db07b2f495b4b98~mv2.jpg/1440_1440/ff1990_75a5ad0af8c248c79db07b2f495b4b98~mv2.jpg

As you can see it split the URL by the 3rd most / sign

My challenge is how i extract the video URL from this WIX URL

//wix:video://v1/ff1990_425db9b2f1024560840049a0ebbbccfc/VID-20210114-WA0009.mp4#posterUri=ff1990_425db9b2f1024560840049a0ebbbccfcf001.jpg&posterWidth=480&posterHeight=848

i need the red portion only and forget the rest and not sure how to do it

I need it to look like this when done

https://video.wixstatic.com/video/ff1990_425db9b2f1024560840049a0ebbbccfc/VID-20210114-WA0009.mp4

Cheers

Dan

let splitter = src.split("/");
let url = `https://video.wixstatic.com/video/${splitter[3]}/${splitter[4].split("#")[0]}`;

HI @J.D

thanks for this.

when i placed your code it looks like this greyed out

my code always has issues with the identifier what's the difference with and "

To my suprise the code ran ok like this and i get the expected URL in the collection !

However when i open the URL in a web page it says forbidden any idea why that is?

Cheers

Dan

@krays23 Hi the can be used with ${variable} inside.
As for the “forbidden” you probably used a wrong src (that does not exist).

Hey @J.D.

I still cant get the URL to work says forbidden the SRC is there??

Could take a look see where im going wrong here?

Thanks

 // Video Upload Button Function
 export function videoUploadbutton_change(event) {
      $w("#videoErrortext").hide();
      $w("#submitCheckinbutton").disable()
      $w("#videoUploadbutton").fileType = "Video"; // File type selector
      console.log("Video upload text length =" + " " + $w("#videoUploadbutton").value.length + " " + "(Video selected)");
      $w("#videoUploadbutton").buttonLabel = "Uploading Please Wait...." //+ $w("#videoUploadbutton").value[0].name; "If you want to add something more to it"
      $w("#videoUploadbutton").startUpload() // "Tells Wix to start the upload and hold it as object before submission"
 .then( (uploadedFile) => {
      $w("#videoUploadbutton").style.backgroundColor = "#FA9869"
      $w("#videoClient").show()
 .then( ( ) => {
      console.log("Video client shown");
 });
      $w("#videoExample").hide("fade",fadeOption)
 .then( ( ) => {
      console.log("Video example photo faded");
 });
 //$w("#videoClient").fitMode = "fit" 
      $w("#videoUploadbutton").buttonLabel = "Upload successful"; // "Button label once upload in complete"
      $w("#submitCheckinbutton").enable();
      $w("#videoClient").src = uploadedFile.url; // "Gets a Wix URL from .src file, doesnt appear to be a normal public URL"     
 //$w("#myCheckinsdataset").setFieldValue("rightSideImageUrl", uploadedFile.url) // This way creates a image in collection but as a WIX URL but you see an image
 let src = $w("#videoClient").src;
 let splitter = src.split("/");
 let videoPublicurlLink = `https://video.wixstatic.com/video/${splitter[3]}/${splitter[4].split("#")[0]}`;
      $w("#myCheckinsdataset").setFieldValue("videoUrl", videoPublicurlLink); // This will upload the converted public URL to a URL field in collection.
      $w('#videoURL').text = videoPublicurlLink;console.log(uploadedFile.url);
      console.log(videoPublicurlLink); // Just a checker so we can see whats happening in the log.
 })
 .catch( (uploadError) => {
      $w("#videoUploadbutton").buttonLabel = "File upload error";
      $w("#videoErrortext").show();
      $w('#videoErrortext').text = uploadError.errorDescription
      console.log("File upload error: " + uploadError.errorCode);
      console.log(uploadError.errorDescription);
 });
 }