How I Watch Youtube Videos without Having Internet at Home
How I Watch Youtube Videos without Having Internet at Home
People ask how I can watch Youtube videos at home while riding the exercise bike, without having the Internet at home. I use the youtube-dl python script which can download Youtube videos from the internet while at the library or another public wi-fi, along with some custom scripts I built and posted below.
Then I browse the Youtube pages of the channels I follow and other suggested videos. From there, I right click on the video, and put the link to the video into the clipboard. From there, I click on an icon in my toolbar that executes a script that “saves” the video URL. Here is the script:
#!/bin/sh xclip -o >> ~/vd1.txt VIDEO1="$(xclip -o)" echo "\n" >> ~/vd1.txt TITLE=$(youtube-dl -e ${VIDEO1}) notify-send -i "/usr/share/icons/gnome/32x32/mimetypes/video-x-generic.png" 'Youtube Added ...' "${TITLE}" xclip -i /dev/null
Once I’ve made my list up to download the youtube-videos, and are ready to consume oodles of bandwidth on the free public wifi at the library or other locations, I run my script that downloads the videos.
#!/bin/bash mkdir -p /home/andy/Videos/Home.Watching/ mkdir -p /home/andy/Videos/Home.Listening/ FILE=/home/andy/vd${1}.txt if [ -f $FILE ]; then for WORD in `cat $FILE`; do if [ ${#WORD} -gt 5 ]; then TITLE=$(youtube-dl -e ${WORD}) notify-send -i "/usr/share/icons/gnome/32x32/mimetypes/video-x-generic.png" -t 25000 -u normal 'Started Download' "${TITLE}" cd /home/andy/Videos/Home.Watching/ youtube-dl --mark-watched $WORD convert-home-watching-to-listening & # script shown below notify-send -i "/usr/share/icons/gnome/32x32/mimetypes/video-x-generic.png" -t 10000 -u normal 'Downloaded' "${TITLE}" fi done NEWFILE=$(basename $FILE).done.txt mv $FILE /home/andy/$NEWFILE done ls -t /home/andy/Videos/Home.Watching/*/*|xargs -d '\n' vlc &
Nice, but there is one more part. I like to be able to listen to videos on my phone while at camp, hiking, or walking, so I also have a script to convert them over to MP3 format using ffmpeg. I also automatically delete any MP3 files that don’t match videos on my system, as I figure if I deleted the videos, I probably don’t need them.
#!/bin/bash MOVIES=/home/andy/Videos/Home.Watching LISTEN=/home/andy/Videos/Home.Listening # first delete any MP3s # that don't have a matching # movie file for f in $LISTEN/* do FILE=${f##*/} BASE=${FILE%%.*} if ! ls $MOVIES/"$BASE"* 1> /dev/null 2>&1 then rm "$f" fi done touch $LISTEN/.nomedia # so these files don't appear with my music files # then do the conversion of # the Movies to MP3s for f in $MOVIES/* do FILE=${f##*/} BASE=${FILE%%.*} #echo $BASE if [[ ! -f $LISTEN/"$BASE".mp3 ]] then ffmpeg -i "$f" $LISTEN/"$BASE".mp3 fi done
Lastly, I use jmtpfs and rsync to sync the files over to my phone. The ten second delay, if the folder is not mounted, is so I see that things weren’t mounted, because the phone is unplugged.
#!/bin/bash jmtpfs -l mkdir -p ~/phone/ jmtpfs ~/phone/ if [ -d "/home/andy/phone/SD card/Home.Listening" ] then rsync -v --progress /home/andy/Videos/Home.Listening/* "/home/andy/phone/SD card/Home.Listening" cd fusermount -u ~/phone/ else sleep 10 fi