Skip to content

Instantly share code, notes, and snippets.

@x-magic
Created February 1, 2016 06:51
Show Gist options
  • Save x-magic/8fb8e30a51c0a04b23ba to your computer and use it in GitHub Desktop.
Save x-magic/8fb8e30a51c0a04b23ba to your computer and use it in GitHub Desktop.
Use Raspbian, youtube-dl and omxplayer to stream YouTube videos
#!/bin/bash
VARHL='\033[1;33m'
ECHOHL='\033[1;36m'
NC='\033[0m'
URL="https://www.youtube.com/watch?v=OPf0YbXqDm0"
echo -e "${ECHOHL}===== The YouTube URL about to play is: ${VARHL}$URL${NC}"
echo -e "${ECHOHL}===== youtube-dl will now list all possible format for you to choose...${NC}"
youtube-dl -F $URL
echo -e -n "${ECHOHL}===== Please enter the format code which you want to play: ${NC}"
read YTFMTCODE
echo -e "${ECHOHL}===== You choose format code ${VARHL}$YTFMTCODE${ECHOHL}. Now youtube-dl will parses video URL...${NC}"
VURL=`youtube-dl -f $YTFMTCODE $URL -g`
echo -e "${ECHOHL}===== Following URL will be used to play: ${NC}"
echo $VURL
echo -e "\n${ECHOHL}===== Do you know? You can use following command to play a YouTube video directly: ${NC}"
echo -e " omxplayer \$(youtube-dl -q ${VARHL}$URL${NC} -f ${VARHL}$YTFMTCODE${NC})\n"
echo -e -n "${ECHOHL}===== Press any key to play above URL with omxplayer...${NC}"
read -sn 1
omxplayer $VURL > /dev/null 2>&1
echo -e "\n\n${ECHOHL}===== Thank you and good bye!${NC}"
@x-magic
Copy link
Author

x-magic commented Feb 1, 2016

Kind of messy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment