spamtech
Posts: 7
Joined: Sun Sep 02, 2012 5:33 am

Local Youtube

Sun Sep 02, 2012 6:07 am

I thought i'd start a topic about what I'm up to because other people might be interested, might have suggestions or perhaps have already done this..!

I have my raspberry pi powered from the USB port of my Apple TimeCapsule (router/backup) and it also gets its internet connection from the LAN of the TimeCapsule. So that's all very handy!

So my project is about creating a local cache of Youtube videos so they're ready for me to watch instantly. My internet isn't all that fast (third world country) so streaming can be a bit of a pain and requires a lot of patience. So the idea is that the raspberry pi automatically downloads videos from youtube for me and then gives me a nice interface to watch them over my local network.

Here's what I've got so far:

Backend
For downloading youtube videos, i'm using youtube-dl

I started work on my own script which would manage the queue of videos with youtube-dl but then came across this script which already does it. I created a cron script to run this hourly (but to ensure it wont run if its still running from the previous hour)

So using the two things above, I can have videos automatically downloaded based on my youtube account subscription. It runs hourly looking for new videos.

Frontend

With nginx and php-fpm installed, I'm coding up a basic frontend that lists the videos and then embeds a HTML5 video player to watch them in the browser.

Any feedback, suggestions or ideas would be appreciated :)


tldr; My raspberrypi will automatically download any new videos from people I'm subscribed to on youtube and keep a local copy so I can watch them instantly over my local network at any time.

spamtech
Posts: 7
Joined: Sun Sep 02, 2012 5:33 am

Re: Local Youtube

Sun Sep 02, 2012 10:55 am

So a bit of an update. For improved reliability, queuing and download speed, I'm now going another route.

I'm using php to collect my subscription feed and pull out all the new videos. These video links are passed to phptube which then turns the direct download link.

I'm then feeding those download links into aria2 which is a super fast, super efficient downloader.

This is much cleaner than what I was doing before and much faster. It also has better opportunities for expansion in the future. Such as adding in different video sites, torrents and so on.

spamtech
Posts: 7
Joined: Sun Sep 02, 2012 5:33 am

Re: Local Youtube

Sun Sep 02, 2012 2:56 pm

I've updated the scripts to also download any youtube video on http://www.reddit.com/r/videos

So not only will my youtube subscriptions be downloaded automatically but I'll also get the latest 'trending' videos from reddit.

The great thing about this is that it will just check youtube and reddit every hour for new videos that I'll likely be watching anyway. When it comes to me actually watching, I can just stream instantly from the raspberry pi.

Not so much of a problem for those with 50mb virgin internet in the UK but quite useful for us with slower connections in the third world!

rasbeer
Posts: 242
Joined: Wed Mar 07, 2012 8:35 am

Re: Local Youtube

Sun Sep 02, 2012 3:46 pm

I don't seem to have the best internet access either, so I think this is a good idea. But recently when looking for an app to do something similar on Android, I discovered this is in violation of yt's terms and conditions, and they'd actually banned all apps for downloading youtube from their app store.

They're either more relaxed about apps for desktops or have less control over them...

spamtech
Posts: 7
Joined: Sun Sep 02, 2012 5:33 am

Re: Local Youtube

Mon Sep 03, 2012 3:11 am

Well since Youtube is owned by Google and Google own the android market place, they can easily say that they're not going to let any apps in that download youtube videos.

Obviously the raspberrypi doesn't have these same restrictions.

It's very hard for them to prevent people downloading the video files because at some point (i.e. when you're trying to watch in the browser) they have to give up the url of the video file.

With the advancements of HTML and Javascript, I think in the next year or two we might start to see complicated multisocket video streamers that will make this a bit harder. But they'll likely keep the existing format as a failsafe for those with older browsers for quite some time. So my raspberry pi should continue going for quite some time!

This pic shows the frontend so far. I still need to tweak it a bit but it does the job for now. The time is when the video was downloaded and not when it was put on youtube. I'm going to have it highlight which videos came from subscriptions and which came from reddit.

Image

felix123
Posts: 153
Joined: Tue May 15, 2012 6:06 am

Re: Local Youtube

Mon Sep 03, 2012 4:38 am

Cool, I don't have a need for this, but it's nice to see how the Raspberry is empowering people all round the world!

Return to “Graphics, sound and multimedia”