i want to convert 'youtube link text (from clipboard)'
to
'youtube title and embed html text'
and
copy to clipboard
With Applescript
for example,
-
I copy
https://www.youtube.com/watch?v=QBGaO89cBMI
into clipboard
- run a applescript
-
then the text (Title and EmbedHTML)
Radiohead - Lift<p><iframe width="640" height="360" src="https://www.youtube.com/embed/QBGaO89cBMI?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
copied into clipboard
Best Answer
This first AppleScript script performs based on the steps outlined in your question.
Assuming no error occurred, the Clipboard now contains the emebbed link information.
If by chance you're doing this in Safari, and are at the YouTube page and want to process, without having to first copy the target URL to the Clipboard and be faster then using
curl
, as in the first script to get the title (theVideoTitle
), then the following AppleScript script is another way to go.Assuming no error occurred, the Clipboard now contains the embed link information.
If you're using Google Chrome, then change the following lines in the second AppleScript script as follows:
Change:
To:
Also change
Safari's
in thedisplay dialog
commands to:Google Chrome's
Note: In the first AppleScript script, getting the value of the variable
theVideoID
from the value of the variabletheURL
on the Clipboard is done using ado shell script
command andsed
, however it can be done using thegetVideoID
handler used in the second AppleScript script, as in the following:Assuming no error occurred, the Clipboard now contains the emebbed link information.