Tuesday, April 22, 2014

Tuesday: Fine, I'll just write a DVR for youtube

Youtube apparently is now forcing all videos to be html5, which is annoying, as it tends to load kind of crappy for me.  This is probably partially due to me getting perpetual shitty download speeds.  I will admit that the html5 isn't as broken as it was previously (where switching from video N in a playlist to video N+1 at the end of video N would cause full screen to turn off), it's still annoying.  Given that I was previously able to watch the 720p versions without trouble, then things got worse and I had to drop down to the 480p, and last night I kept having to force it back up from 240 or 360, this is annoying and getting increasingly so.

The obvious (to me) solution is to preload the videos in my watch later playlist, and download them in the background all day long.  This turns out to not be a terribly hard thing to do:

  1. Use youtube-dl to download the files.  I may need to write my own playlist parser, as I would want to remove the videos from the yt side playlist once I have a local copy.  This also allows me to limit the bandwidth used, so I can be sure that I'm not flooding out my regular internet usage.
  2. Push file locations, the channel names, the upload date, and some other status variables into a database table.
  3. Construct a channel quality rating that ranks the videos in the database.
    1. My quick thought here is to do something where a video gets a +fraction, based on how much is watched.  That way, a shitty video I skip after five seconds puts a down weight on that channel, but a video I watch all the way through pushes up the channel weight.
    2. Next, there probably needs to be a time weight.  Today's things should weight higher than yesterday, yesterday higher than last week, but this probably needs to turn around so that a video from a month ago is ranked higher than two weeks ago.  This should help prevent videos from sitting around forever.
    3. Something to denote a sequential series of videos, so that part 1 is always watched before part 2.  Probably something title/keyword based.
    4. Some other keyword based rating.  "Pikachu" probably should rank higher than "trains."
  4. Using the various weights, construct a playlist to watch.
  5. Pass the playlist into a perl-wrapper for mplayer, using the -slave option to mplayer, where the perl catches and passes keyboard controls to mplayer, and makes database changes as well.
Really, this is basically writing a database schema, and then writing a couple of short perl scripts that basically have to do database queries and call other programs.  Maybe I can get this done this weekend.

I saw this cool car on the way home tonight, and was able to get my phone out and take the picture while waiting for a light.  It's a shame the only other person in Honolulu who pulls up to the car in front of them was behind it.  There's a Pikachu sticker under the license plate that you can just see the tail of.

No comments:

Post a Comment