Parse Youtube URL's - Output to Javascript Code

User-to-User discussion about the PhraseExpress macro programming.
Post Reply
jlimon
Posts: 2
Joined: 27 Aug 19, 23:06

Parse Youtube URL's - Output to Javascript Code

Post by jlimon » 27 Aug 19, 23:36

Hello,

I am trying to design a macro/automation that will take a list of YouTube URL's, extract the video ID's and paste it into some Javascript code to help with a video gallery project I'm working on.

So far i'm able to make this work with a single URL by doing the following:
  • Form Input Single-Line Input with URL validation
  • Process output, Extract string with RegEx (([A-Za-z0-9_\-]{11}))
  • Apply header/footer to result with JS code

Code: Select all

{
	'category': 'categoryF'
	'url': 'https://www.youtube.com/embed/***RESULT***'
	'width': '250'
	'height': '150'
}
Header =

Code: Select all

{
	'category': 'categoryF'
	'url': 'https://www.youtube.com/embed/
Footer =

Code: Select all

'
	'width': '250'
	'height': '150'
}
When attempting to do multiple URL's the output is:

Code: Select all

{
	'category': 'categoryF'
	'url': 'https://www.youtube.com/embed/***RESULT1***,***RESULT2***'
	'width': '250'
	'height': '150'
}
What I would like is:

Code: Select all

{
	'category': 'categoryF'
	'url': 'https://www.youtube.com/embed/***RESULT1***'
	'width': '250'
	'height': '150'
}
{
	'category': 'categoryF'
	'url': 'https://www.youtube.com/embed/***RESULT2***'
	'width': '250'
	'height': '150'
}
What I need to do is iterate through a list of youtube URLs and have it create an individual code JS code block for each one.

An example of the video gallery can be seen here:
https://codepen.io/angeal185/pen/peqmXe

Any help with this would be appreciated.

jlimon
Posts: 2
Joined: 27 Aug 19, 23:06

Post by jlimon » 28 Aug 19, 00:02

I was able to fashion a solution from this post here: https://www.bartelsmedia.com/forum/view ... 46&t=17378

Using the iterative copy/paste method here:

Code: Select all

(* 20190513 • Outputs the currently first line of the clipboard content
   Delete empty lines from the clipboard (RegEx)
*){#setclipboard {#trim {#regexrep -text {#insertclipboard} -expr ^\h*\R -repexpr }}{#asc 13}}(* 
  Output line 1 of the current clipboard content
*)»{#trim {#substr {#insertclipboard} -from 1 -count {#calc {#pos {#insertclipboard} -substr {#asc 13}}-1 -round 0}}}«(* 
  Remove line 1 from clipboard content
*){#setclipboard {#substr {#insertclipboard} -from {#calc {#pos {#insertclipboard} -substr {#asc 13}}+1 -round 0} -count }}
Thanks for your time guys! I'm glad I was able to figure this one out with an existing solution.

Post Reply