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

Daily Update – April 15, 2022

Good morning! Well, plans change. 😞

I was all packed for heading up to the Adirondacks, until I looked at the forecast which is calling for rain and wind by afternoon, followed by wet snow most of tomorrow, then cold and cloudy come Sunday with a strong wind. And red flag conditions and I like to burn things. Yeah, that’s not going to work.

Mostly sunny and 39 degrees in Delmar, NY. 😎 Calm wind.

So yeah, I packed all my clothes, food and camping gear last night, πŸ• and now I got to unpack them today. It’s a disappointing because it looks like such a nice day today.

I am a really bummed about not heading out of town, πŸ™ but sitting in a cold rain and snow, and cloudy days doesn’t sound like much. It will be raining in a few hours this afternoon in the Adirondacks with the wind expected to bring lake-effect showers off the lake and push them into the Adirondacks.

Instead, I am working on a new plan for today. I want to do some reading, πŸ“š sand and prime my truck from the winter rust damage, πŸš› and finish sorting the recycables ♻️ for a trip to the transfer station on Saturday. Some of that paper and plastic I was going to burn, I am going to do the green and legal thing and recycle. 🌲 I mean Earth Day is coming 🌎 and some of that plastic stuff can stink like burn barrel especially if it’s not burning well πŸ”₯ and it’s a cold and rainy day. Maybe some of it being recycled will end up as plastic board or paperboard, although with the escalating costs at the transfer station makes me cynical about that point.  But at least it has a chance of getting diverted from the landfill, and won’t necessarily all be turned into CO2. πŸ’¨ Plus I have a years worth of cans to recycle. πŸ₯«

I am thinking mid-to-later in the day I will walk out to Five Rivers. 🐸 The trails will probably be soggy but I can get in a lot of steps on Meads Road, then some of the paved or gravel roads at Five Rivers. SIt and listen to the spring peepers for a bit, probably see some deer and birds. I wonder if there will be as many red-winged black birds out that way — I haven’t been seeing as many locally, πŸ•Š although most mornings I’ve been hearing the mourning doves around and they are loud.