HTML, JavaScript, Programming

Run Your Own Television Network with Channel Two

YouTube allows anyone to be the star in their own television show, but the true dream job of every little girl and boy has still been out of reach: Vice President of Program Scheduling. But today, that dream becomes reality.

Channel Two is a web application I’ve written that allows you to run your own TV network in a Web browser. You simply define your programming schedule and open a browser tab — it’s just that easy!

A screenshot of Channel Two broadcasting an episode of NewsRadio. It includes a chyron with the text "You're watching NewsRadio - Led Zeppelin Boxed Set." The browser chrome is visible, but Channel Two normally runs in full-screen mode.

What can Channel Two do?

  • It can play random home movies all day.
  • It can play a new episode of Seinfeld every night at 6pm.
  • It can pick a random G-rated or PG-rated movie to play every Saturday afternoon.
  • It can automatically insert commercial breaks into episodes of TV shows.
  • It can play Groundhog Day all day on February 2nd.
  • And it can do all of this for free (assuming that you already own this content and have digitized it).

Why would I use this?

Do you have a digital media library that you never watch anything from because it’s too cumbersome to sift through? Do you have home movies that you don’t ever see because it takes too long to pick one? Do you want a family-friendly TV channel available in your house where you control all of the content? Channel Two solves all of these problems.

How does it work?

Channel Two begins with the schedule file. It’s similar to a crontab file — every line defines the time to perform some task; in this case, the task is playing a specific video or a video selected from a directory.

Here’s an example Channel Two schedule:

shuffle=true
* * * * * /Media/Home Movies/
shuffle=false

0 7 * * * /Media/TV/Backyardigans/
30 7 * * * /Media/TV/Curious George/
0 12 * * * https://example.com/noon-affirmations.mp4

shuffle=true
0 14 * * * /Media/Movies/Rated-G/
0 14 * * * /Media/Movies/Rated-PG/
shuffle=false

0 17 * * * /Media/TV/Planet Earth/

ads=/Media/Ads/

0 20 * * * /Media/TV/Green Acres/
30 20 * * * /Media/TV/Gilligan's Island/
0 21 * * * /Media/TV/The Beverly Hillbillies/
30 21 * * * /Media/TV/Petticoat Junction/

0 20 * * 4 /Media/TV/The Office/

(If you’re not familiar with cron, read this for some background.)

In plain English, this file tells Channel Two to do the following:

  1. At 7am and 7:30am, play episodes of Backyardigans and Curious George. Each day, it will automatically play the next episode of each series in order.
  2. At noon, play the file from the URL https://example.com/noon-affirmations.mp4.
  3. At 2pm, play a random movie from the directories /Media/Movies/Rated-G/ and /Media/Movies/Rated-PG/
  4. At 5pm, play an episode of Planet Earth.
  5. Every night from 8-10pm, play a block of vintage programming: Green Acres, Gilligan’s Island, The Beverly Hillbillies, and Petticoat Junction…
  6. …except on Thursday nights at 8pm, play an episode of The Office. (A line at the bottom of the schedule takes priority over the lines above it.)
  7. Any time when there is nothing else scheduled, play a random home movie.

What happens when there’s nothing for Channel Two to play? If you don’t set backup programming with a line like * * * * * /Media/my-videos/ it’s possible that there will come a time when Channel Two has nothing to do. In this case, it will show a spiffy placeholder until it’s time to play something:

You can customize this by replacing the file assets/right-back.gif.

Capitalism

The lines shuffle=true and shuffle=false turn shuffle mode on and off, but what about the line ads=/Media/Ads/? That unlocks the true power of TV: commercials!

If you tell Channel Two which directory you’ve filled with ads, it will do two things:

  1. It will automatically detect ad breaks in TV shows and movies by watching for when the show fades to black. At this point, it will insert up to five commercials and then resume the show. (It also ensures that it hasn’t taken an ad break too recently and that there is enough time in the current programming slot to play ads without causing the show to overlap the next timeslot.)
  2. When a show or movie ends, it will play ads until the next half-hour mark (or until the next show begins).

Tip: You can find many many many TV commercials on certain Internet video sites, and tools exist to download them to your own computer. I can confirm that commercials from your youth can hold just as much nostalgia as actual TV shows and movies. ¡Yo quiero Taco Bell!

Once you have Channel Two open and running, it will play programming continuously forever (or until you close the browser tab, whichever comes first). To get the full effect and benefit of controlling your own TV station, I recommend either mirroring your computer screen to a television, or go all the way like I did and buy a digital RF modulator and permanently broadcast your media server’s screen on the channel of your choice so that all the TVs in your house can tune in.

I want to see it in action, but I don’t want to expend any effort.

You can view a demo version of Channel Two here on my website — it only plays three (public domain) videos, but it should give you an idea of how it works. The schedule.txt file for this installation looks like this, which ensures that the videos will always play back-to-back:

base=/home/cfinke/

* * * * * /media/His Girl Friday - Get Out.mp4
* * * * * /media/It's a Wonderful Life - Lasso the Moon.mp4
* * * * * /media/The General.mp4

Does Channel Two have any additional features?

It sure does. Channel Two displays a chyron at the beginning of each program announcing what’s playing.

Additionally, you can use the left and right arrow keys to move forward and backward respectively in the content list for the given timeslot. Don’t want to start a series at season 1 episode 1? Just press the right arrow until your preferred episode plays.

So you’ve decided to become an executive.

Now what?

  1. Download Channel Two from GitHub.
  2. Open the included schedule.txt and define your schedule.
  3. In the Channel Two folder, run the command php parse-schedule.php --schedule schedule.txt. This will generate a JavaScript file that Channel Two uses to manage programming.
  4. Open channel-two.html in your browser.
  5. Click the “Click to Start” image and enjoy your programming!

Comment below or email me at cfinke@gmail.com with any questions or feedback.

Standard

Leave a Reply

Your email address will not be published. Required fields are marked *