Efty.Edge Posted April 8, 2013 Share Posted April 8, 2013 Hi, Here is my idea of a youtube video downloader workflow. I try to catch the url of the browser and send the url to the youtube-dl script created by Ricardo Garcia Gonzalez (http://rg3.github.io/youtube-dl/index.html). The syntax to download a youtube video in HQ is simple, just: youtube-dl <url> Everthing works fine except one thing. First I dropped the youtube-dl script into the workflow folder. Then i opened a Youtube Video and started my workflow. In the notification center the catched url is shown. But the youtube-dl script/programm didn't start. Please give me some advice. I'm really, really new to scripting ... Thanx in advance Efty #!/bin/bash # cases that handles fetching the URL them self case "$1" in *) # all other options need the URL, so lets fetch it THEURL=$(sh getURL.sh) # if no url then just exit if [ -z "$1" ] then echo "Unable to find a URL" exit else echo $THEURL youtube-dl + $THEURL fi esac Link to comment
jdfwarrior Posted April 9, 2013 Share Posted April 9, 2013 Hi, Here is my idea of a youtube video downloader workflow. I try to catch the url of the browser and send the url to the youtube-dl script created by Ricardo Garcia Gonzalez (http://rg3.github.io/youtube-dl/index.html). The syntax to download a youtube video in HQ is simple, just: youtube-dl <url> Everthing works fine except one thing. First I dropped the youtube-dl script into the workflow folder. Then i opened a Youtube Video and started my workflow. In the notification center the catched url is shown. But the youtube-dl script/programm didn't start. Please give me some advice. I'm really, really new to scripting ... Thanx in advance Efty #!/bin/bash # cases that handles fetching the URL them self case "$1" in *) # all other options need the URL, so lets fetch it THEURL=$(sh getURL.sh) # if no url then just exit if [ -z "$1" ] then echo "Unable to find a URL" exit else echo $THEURL youtube-dl + $THEURL fi esac Try this.. In the Run Script module, leave the language set to /bin/bash. var="{query}" if [ -z $var ]; then echo "No url provided" else youtube-dl "$var" fi This will run the script if a value is passed. You could always just set your keyword to require an argument and you won't have to check if its empty. This worked for me. Link to comment
Efty.Edge Posted April 10, 2013 Author Share Posted April 10, 2013 (edited) Hi David! Sorry for my late reply and thank you for your help. But i'm not able to get your script to work with mine. So developed following solution in applescript. #/usr/bin/osascript try tell application "Safari" to tell document 1 set theLink to (get URL) end tell end try try tell application "Terminal" do shell script "python youtube-dl -o ~/Downloads/movie.mp4 " & theLink end tell end try tell application "Terminal" to quit return "Download Finished... " This one works really fine, but i have a few questions you can maybe help me with. I would like to use an argument after the keyword to replace the filename 'movie.mp4' with a user defined one. How can i do it? Is it possible the execute the 'do shell script...' without a visible Terminal window? And at last. Is it possible to display a notification in the Notification Center like 'Download started...' at the start of the script which stays visible until the script is finished!? Actual it disappears after 5 sec. as normal. Thank you again. Efty Edited April 10, 2013 by Efty Edge Link to comment
Subject22 Posted April 10, 2013 Share Posted April 10, 2013 (edited) Is it possible the execute the 'do shell script...' without a visible Terminal window? David's infinitely more qualified than I am to answer your questions, so I'll take the easy one :-) The do shell script command normally does run without creating a Terminal window, the only reason it's doing it here is because you included it in a tell application "Terminal" block. Try this: #/usr/bin/osascript try tell application "Safari" to tell document 1 set theLink to (get URL) end tell end try try do shell script "python youtube-dl -o ~/Downloads/movie.mp4 " & theLink end try return "Download Finished... " For the record, if you are using AppleScript to tell Terminal to run a shell script, you can actually do it with do script rather than the full do shell script command :-) EDIT: I'm also not sure what the duplicate try blocks are meant to accomplish. Couldn't you achieve the same thing with just one? #/usr/bin/osascript try tell application "Safari" to tell document 1 set theLink to (get URL) end tell do shell script "python youtube-dl -o ~/Downloads/movie.mp4 " & theLink end try return "Download Finished... " Edited April 10, 2013 by Subject22 Link to comment
jdfwarrior Posted April 10, 2013 Share Posted April 10, 2013 Hi David! Sorry for my late reply and thank you for your help. But i'm not able to get your script to work with mine. So developed following solution in applescript. #/usr/bin/osascript try tell application "Safari" to tell document 1 set theLink to (get URL) end tell end try try tell application "Terminal" do shell script "python youtube-dl -o ~/Downloads/movie.mp4 " & theLink end tell end try tell application "Terminal" to quit return "Download Finished... " This one works really fine, but i have a few questions you can maybe help me with. I would like to use an argument after the keyword to replace the filename 'movie.mp4' with a user defined one. How can i do it? Is it possible the execute the 'do shell script...' without a visible Terminal window? And at last. Is it possible to display a notification in the Notification Center like 'Download started...' at the start of the script which stays visible until the script is finished!? Actual it disappears after 5 sec. as normal. Thank you again. Efty Try this: download I tried this with several videos and it worked perfectly for me. Give it a youtube link, it downloads the video, names the file the title of the video and saves it to your desktop Link to comment
Efty.Edge Posted April 11, 2013 Author Share Posted April 11, 2013 Hi Subject22 and David. Thanx for your help and your advice. I'm a scripting newbie, so i'm very glad and thankful for any help! David - your script works like charm, but i didn't really understand how it works. I promise, i've tried it an hour or two!!! At last i finished mine in Applescript ... Efty Link to comment
justcharlie Posted October 11, 2014 Share Posted October 11, 2014 Does this still work? I can't get it to work with the latest version of Alfred. It says download complete suspiciously fast and the file doesn't appear. Link to comment
rice.shawn Posted October 12, 2014 Share Posted October 12, 2014 You could just try using Luxinate: http://www.alfredforum.com/topic/3238-luxinate-download-video-and-audio-from-youtube-and-soundcloud/. Link to comment
deanishe Posted October 15, 2014 Share Posted October 15, 2014 Does this still work? I can't get it to work with the latest version of Alfred. It says download complete suspiciously fast and the file doesn't appear. Chances are you just need to update the youtube-dl script within the workflow. Looky here. Link to comment
justcharlie Posted December 6, 2014 Share Posted December 6, 2014 Chances are you just need to update the youtube-dl script within the workflow. Looky here. Thanks! Link to comment
petebocken Posted April 5, 2017 Share Posted April 5, 2017 I'm having the same issue that @justcharlie was having with http://cloud.dferg.us/q4Gt I've updated to the latest youtube-dl and also Python 2.7.13. Just pops up the OS X notification saying it's done but no file. youtube-dl works fine when run manually. On 10/11/2014 at 0:18 AM, justcharlie said: Does this still work? I can't get it to work with the latest version of Alfred. It says download complete suspiciously fast and the file doesn't appear. Link to comment
deanishe Posted April 5, 2017 Share Posted April 5, 2017 1 hour ago, petebocken said: I've updated to the latest youtube-dl The one installed on your system or the one included in the workflow? Link to comment
petebocken Posted April 5, 2017 Share Posted April 5, 2017 12 minutes ago, deanishe said: The one installed on your system or the one included in the workflow? The one installed on my system. I just now realized that the workflow has it's own version installed with it. I tried replacing the youtube-dl file in the workflow and that doesn't make a difference. I also tried editing the workflow script to point to mine at /usr/local/bin/youtube-dl and still no go. Although not sure I know the correct way to have it look outside of the workflow at the file system for that file besides just putting the full path to it. Link to comment
deanishe Posted April 5, 2017 Share Posted April 5, 2017 (edited) 1 hour ago, petebocken said: just putting the full path to it Bingo! Unfortunately, Alfred (and all other Mac apps) don't use your shell environment, which includes PATH. They don't look in /usr/local/bin. If you fix the path to point to your Homebrew verison of youtube-dl, the workflow should just keep on working. If it doesn't, I can post an AppleScript that does. Edited April 5, 2017 by deanishe Link to comment
petebocken Posted April 6, 2017 Share Posted April 6, 2017 3 hours ago, deanishe said: Bingo! Unfortunately, Alfred (and all other Mac apps) don't use your shell environment, which includes PATH. They don't look in /usr/local/bin. If you fix the path to point to your Homebrew verison of youtube-dl, the workflow should just keep on working. If it doesn't, I can post an AppleScript that does. Ya, not sure what to put in the path to find my local install of youtube-dl: ./youtube-dl -q -o "$uhome/Desktop/%(title)s.%(ext)s" "$url"; echo "Completed"; Link to comment
deanishe Posted April 6, 2017 Share Posted April 6, 2017 If you installed it with Homebrew or by following the official instructions, it's /usr/local/bin/youtube-dl, thus: /usr/local/bin/youtube-dl -q -o "$uhome/Desktop/%(title)s.%(ext)s" "$url"; echo "Completed"; Link to comment
petebocken Posted April 6, 2017 Share Posted April 6, 2017 5 hours ago, deanishe said: If you installed it with Homebrew or by following the official instructions, it's /usr/local/bin/youtube-dl, thus: /usr/local/bin/youtube-dl -q -o "$uhome/Desktop/%(title)s.%(ext)s" "$url"; echo "Completed"; Weird, swear I tried that before. Works now, thanks! Link to comment
petebocken Posted April 6, 2017 Share Posted April 6, 2017 Last piece is figuring out how to have it download the full quality (1080p or 4K). This works just fine when you run youtube-dl from the command line. It downloads the 4K video (if available) and the audio file and then ffmpeg muxes them together into one file. When you just use /usr/local/bin/youtube-dl -q -o "$uhome/Desktop/%(title)s.%(ext)s" "$url"; echo "Completed"; it downloads a single file with audio and video together but it seems to always choose 720p. If I use /usr/local/bin/youtube-dl -f bestvideo+bestaudio -q -o "$uhome/Desktop/%(title)s.%(ext)s" "$url"; echo "Completed"; It will download the 4K video and audio as separate files but never muxes them together. I also tried adding -f bestvideo+bestaudio --merge-output-format MP4 Link to comment
deanishe Posted April 6, 2017 Share Posted April 6, 2017 That's rather a question for the youtube-dl community, not the Alfred one. https://github.com/rg3/youtube-dl/blob/master/README.md#readme Link to comment
petebocken Posted April 6, 2017 Share Posted April 6, 2017 3 minutes ago, deanishe said: That's rather a question for the youtube-dl community, not the Alfred one. https://github.com/rg3/youtube-dl/blob/master/README.md#readme Well, considering that it works fine and expected from the command line directly, it is an issue with how Alfred talks to ffmpeg or rather how it doesn't at all it seems. Link to comment
petebocken Posted April 6, 2017 Share Posted April 6, 2017 Must be some permission issue. Since I am calling my own youtube-dl script, I would think it would be able to then find ffmpeg and execute. Link to comment
deanishe Posted April 6, 2017 Share Posted April 6, 2017 So you used exactly the same command in a shell and got a different result? Or you used a (even slightly) different command in the shell and got a different result? In either case, your question now requires knowledge of youtube-dl, not (just) Alfred. I certainly don't have it, David rarely posts anymore, and I don't know about anyone else. As such, I think your best bet for a fast solution is the youtube-dl site. Link to comment
petebocken Posted April 6, 2017 Share Posted April 6, 2017 1 minute ago, deanishe said: So you used exactly the same command in a shell and got a different result? Or you used a (even slightly) different command in the shell and got a different result? In either case, your question now requires knowledge of youtube-dl, not (just) Alfred. I certainly don't have it, David rarely posts anymore, and I don't know about anyone else. As such, I think your best bet for a fast solution is the youtube-dl site. Ya, figured we were getting into the weeds. Thanks @deanishe Link to comment
deanishe Posted April 6, 2017 Share Posted April 6, 2017 3 minutes ago, petebocken said: Must be some permission issue. Since I am calling my own youtube-dl script, I would think it would be able to then find ffmpeg and execute. Yeah, that could definitely be an issue. Presumably, ffmpeg is in /usr/local/bin or somewhere else Mac apps don't look by default. IIRC, youtube-dl has an option for passing the path to ffmpeg, but it's been a long time since I used it directly. Link to comment
deanishe Posted April 6, 2017 Share Posted April 6, 2017 3 hours ago, petebocken said: getting into the weeds Never heard that before. Had to look it up. Quite a useful expression. Thanks! I just dug out an old script that wraps youtube-dl. --ffmpeg-location /usr/local/bin/ffmpeg is likely the option you need. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now