Monday, February 27, 2017
  • Index
  •  » Automator
  •  » Service How to use current page url in Safari as variable?

#1 2015-09-25 02:48:06 am

fearbabyriffs
Member
From: Las Vegas
Registered: 2009-11-24
Posts: 29
Website

Service How to use current page url in Safari as variable?

So I am trying to write a service in Automator & cannot figure out how to take the current selected page url of Safari or Chrome to variable within this on run.

I obviously set ytURL explicitly here, but want to use a variable set to the page url instead.

When set explicitly it does work from testing.

on run {input, parameters}
   
    set ytURL to "https://www.youtube.com/watch?v=Y-NB0GiPvh0"
    tell application "Terminal"
        activate
        do script with command ("youtube-dl --extract-audio --audio-format mp3 " & ytURL)
    end tell

    return input
end run

So I guess what automator action step should I have above this one?

Is it "Set variable"? and if so how would I do that?

ANSWER:
Okay this is how I did it:

1st Automator step was "Get current webpage from Safari"
2nd Automator step was "Run Applescript"

on run {input, parameters}
   
    set ytURL to input
    tell application "Terminal"
        activate
        do script with command ("youtube-dl --extract-audio --audio-format mp3 " & ytURL)
    end tell

    return input
end run

Last edited by fearbabyriffs (2015-09-27 05:59:03 am)

Offline

 
  • Index
  •  » Automator
  •  » Service How to use current page url in Safari as variable?

Board footer

Powered by FluxBB

[ Generated in 0.052 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)