Last active
February 26, 2017 00:20
-
-
Save MrCirdo/e44fbf8172b39fb7c9a88ab6c27f3323 to your computer and use it in GitHub Desktop.
Download video (audio) from Youtube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--set urlVideo to text returned of (display dialog "Entrer l'url de la vidéo : " default answer "") | |
set urlVideo to "" | |
tell application "Safari" | |
set urlVideo to URL of front document | |
end tell | |
if urlVideo is "" then | |
set urlVideo to text returned of (display dialog "Entrer l'url de la vidéo: " default answer "") | |
end if | |
repeat while urlVideo does not contain "https://www.youtube.com/watch" | |
set urlVideo to text returned of (display dialog "Entrer l'url de la vidéo: " default answer "") | |
end repeat | |
tell application "System Events" | |
tell process "Safari" | |
open location "http://www.youtube-mp3.org" | |
delay 1 | |
key code 48 | |
keystroke "a" using {command down} | |
key code 51 | |
delay 1 | |
keystroke urlVideo | |
key code 36 | |
end tell | |
end tell | |
delay 2 | |
tell application "Safari" | |
set theScript to "var allChoice = document.querySelectorAll('#content #inner #progress_info.success #dl_link a'); var url = ''; for (var i = 0; i < allChoice.length; i++){if (allChoice[i].getAttribute('href').indexOf('create') != -1){url = allChoice[i].getAttribute('href');}} window.open(url);" | |
do JavaScript theScript in first document | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment