Skip to content

Instantly share code, notes, and snippets.

@thiemo
Forked from deanishe/youtube-to-quicktime.sh
Created August 27, 2017 11:11
Show Gist options
  • Save thiemo/18083982c1367d7b8df0ea3c4ac91273 to your computer and use it in GitHub Desktop.
Save thiemo/18083982c1367d7b8df0ea3c4ac91273 to your computer and use it in GitHub Desktop.
Open Current YouTube Video in QuickTime Player (or whatever)
#!/bin/bash -e
# Instead of watching YouTube videos in your browser, stream them in
# QuickTime Player (or VLC/MPlayer etc.)
#
# youtube-dl supports hundreds of websites, so it will probably work
# for a lot of video sites.
# See https://rg3.github.io/youtube-dl/
# Get URL of current tab in browser
# Google Chrome
webpage_url=$(osascript -e 'tell application "Google Chrome" to return URL of active tab of front window')
# Safari
# webpage_url=$(osascript -e 'tell application "Safari" to return URL of front document')
stream_url=$(/usr/local/bin/youtube-dl -g "${webpage_url}")
# Open the stream URL in QuickTime Player. Change to your preferred application.
open -a "QuickTime Player" "${stream_url}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment