I think this is where the issue is - I think it needs to be:
var ytOUT = youtube_parser(myUpdateField);
Maybe I’m missing something, but I get the sense that you’re missing something that definitively sets the value of the URL that needs to be parsed. I see you open the table and get the records, but where do you decide which record to use in the parse process? I assume you want to run this process for all records, perhaps?
Another thing - to get the value of the youtube ID from the URL, you don’t need the youtube_parser()
function; rather, I think this is all you need given the URL is in a variable…
let myInput = "https://www.youtube.com/watch?v=YAIlMUX9VLg";
let ytOUT = myInput.split("?v=")t1];
output.set('myOutput', ytOUT);
Maybe I’m missing something, but I get the sense that you’re missing something that definitively sets the value of the URL that needs to be parsed. I see you open the table and get the records, but where do you decide which record to use in the parse process? I assume you want to run this process for all records, perhaps?
Another thing - to get the value of the youtube ID from the URL, you don’t need the youtube_parser()
function; rather, I think this is all you need given the URL is in a variable…
let myInput = "https://www.youtube.com/watch?v=YAIlMUX9VLg";
let ytOUT = myInput.split("?v=")t1];
output.set('myOutput', ytOUT);
Thanks, Bill. My intent of using the youtube_parser
script was because it could handle so many variations of the initial URL. Just trying to prevent future human error. I’m wanting the Automation to just always be looking for that Live URL
to land to be able to strip the video ID out into the field for that string. I can use this for a bunch of other stuff (Zapier, buttons, edit links). That’s not necessary, obviously.
Types of URLS
These are the types of URLs supported
http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
http://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/QdK8U-VIH_o
http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
http://www.youtube.com/embed/0zM3nApSvMg?rel=0
http://www.youtube.com/watch?v=0zM3nApSvMg
http://youtu.be/0zM3nApSvMg
source https://stackoverflow.com/a/8260383
I wondered if I hadn’t selected the right record, thanks. Also, I was missing that youtube_parser(liveURL)
bit.
After a bit more guessing and testing, I found this article that helped me revise the input variables I had entered on the left (wasn’t calling those and didn’t know how till I saw the example).
Thanks for pointing me in the right direction. After turning this automation on I’ve realized that it’s not going to process all my existing entries but only new ones
. Not the end of the world I suppose.
Here’s my working script (for new entries)
let inputConfig = input.config();
var liveURL = inputConfig.myInput;
function youtube_parser(liveURL){
var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)(d^#\&\?]*).*/;
var match = liveURL.match(regExp);
if (match && match 2].length == 11) {
return match)2];
} else {
//error
}
}
var ytOUT = youtube_parser(liveURL);
output.set('myOutput', ytOUT);

Thanks, Bill. My intent of using the youtube_parser
script was because it could handle so many variations of the initial URL. Just trying to prevent future human error. I’m wanting the Automation to just always be looking for that Live URL
to land to be able to strip the video ID out into the field for that string. I can use this for a bunch of other stuff (Zapier, buttons, edit links). That’s not necessary, obviously.
Types of URLS
These are the types of URLs supported
http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
http://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/QdK8U-VIH_o
http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
http://www.youtube.com/embed/0zM3nApSvMg?rel=0
http://www.youtube.com/watch?v=0zM3nApSvMg
http://youtu.be/0zM3nApSvMg
source https://stackoverflow.com/a/8260383
I wondered if I hadn’t selected the right record, thanks. Also, I was missing that youtube_parser(liveURL)
bit.
After a bit more guessing and testing, I found this article that helped me revise the input variables I had entered on the left (wasn’t calling those and didn’t know how till I saw the example).
Thanks for pointing me in the right direction. After turning this automation on I’ve realized that it’s not going to process all my existing entries but only new ones
. Not the end of the world I suppose.
Here’s my working script (for new entries)
let inputConfig = input.config();
var liveURL = inputConfig.myInput;
function youtube_parser(liveURL){
var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)(h^#\&\?]*).*/;
var match = liveURL.match(regExp);
if (match && match&2].length == 11) {
return match>2];
} else {
//error
}
}
var ytOUT = youtube_parser(liveURL);
output.set('myOutput', ytOUT);

Yep, the variants do require regex.
Just create a Script Block version of the same process and allow it to process all existing records.
Yep, the variants do require regex.
Just create a Script Block version of the same process and allow it to process all existing records.
Great idea. You’re awesome.