I've been threatening for quite some time to post my TV playlist workflow. I'll put up my music video builders as well just because for some reason they're different.
TL;DR: Here's the primary TV script.
Warning
This was banged out over a few nights of non-sober hacking. It's not "good", but it's "good enough" until I can dig in and fix all the inconsistencies. You can get the idea.
The Executive Summary
I believe the correct way to watch TV is to throw the TV on, pick a "channel" and not have to think too super hard about what you want to see beyond choosing where to start watching. With Netflix and Amazon and stuff you're paying some number of dollars per month for access to content, but the way they present it is that you have to find a thing you want to see, then dig into that and play an episode of a TV show. This is let's say inefficient for anything other than single-show binging. Which is why single-show binging got huge when everyone dropped cable for Netflix and Amazon. When you have 400 or 500 TV series to choose from, do you really want to dig into "Season 6, Episode 12" of Cheers, and then choose to hit "Season 5, Episode 9" of King of the Hill, or would you rather hit "Sitcoms" and let the computer do the work?
The Methodology
I prefer the TNT method of "you throw on TNT and now you're watching a block of Friends" or you put on Nick at Nite and you might get Mary Tyler Moore followed by Speed Racer and a Drew Carey Show. So that's what I've built.
I have full runs of many many TV shows, I build daily playlists, around 120 at the moment, for various Genres, as well as several dozen shows to run as "blocks". I mix in commercials, though I need lots more commercials and I need to tailor them a little better so I'm not getting Underoos ads between episodes of The Wire.
So the menus are sort of:
- TV Shows
- Blocks - Individual 50 episode playlists for ~100 series or so. So we're watching a block of Star Trek, or Seinfeld or whatever.
- BritBox - Comedies, Cozy Mysteries and Doctor Who, pretty much
- Sitcoms
- Nick at Nite - All stuff from Nick at Nite, TV Land etc
- Buddies - Buddy Cop / Detective type shows. Cagney & Lacey, Columbo, Barnaby Jones, Starsky and Hutch, Burn Notice, all that stuff.
- Saturday Morning Cartoons
- Superheroes - The Live Action shows mainly from the 70s. Hulk, Wonder Woman, Six Million Dollar Man, Bionic Woman, that sort of thing.
- Variety Shows - Laugh In, Kids in the Hall, SNL, blah blah blah, SCTV...
- MTV
- 120 Minutes
- Yo! MTV Raps
- Arcade / Pizzaria - This is like the ubiquitous music from my youth pretty much
I create playlists of specific lengths because media players really don't deal too well with massive playlists. Though Kodi does better than most. My "MTV" playlist is around 12000 songs if I just let it rip and Kodi handles it just fine. But the main reason for creating playlists and not just say, go into a folder and hit "Shuffle" is that I get to choose my entry point and find a run of TV shows that I want to watch, or skip the first few music videos to start with something "good".
The Workflow
These playlists are the simplest possible .m3u files. Just basically lists of absoluterelative paths to individual files with no metadata or context. This requires all the files to be named appropriately such that they're all uniform and informative. "Show Name -SeasonEpisode - Episode Name".ext.
The Simpsons - S03E07 - Treehouse of Horror II.avi
Kodi does not automatically add metadata for .m3u playlists in the way Jellyfin/Emby does for theirs. It's on my to-do list to scrape the series name and episode title from Kodi's database and add it in before inserting the file path.
To create these M3Us I have a few cron jobs on my home server, the steps are pretty simple:
- Build a master filelist of my TV Shows directory.
- For each genre + blocks, scan the filelist for shows listed in my /cfg/$playlist.txt file
- Scan against a master "exclusions" list so I don't include like .nfo files, subtitles, text files, ISOs, "dvd extras" etc.
- Insert commercials according to a cfg file for each playlist. (Number of episodes before a commercial break, number of commercials per break)
To build the playlist itself, I scrape all this into an array and randomize it:
vids=()
sed "s/^/\/Volumes\/Filestore\/Common\/TV Shows\//" $cfgdir/$vfil.txt > $cfgdir/$vfil.txt.bob
mapfile -t vids
That works out to, using Nick at Nite as our example:
- Create the vids array as an empty set
- Strip the base filesystem path from all ....../cfg/nickatnite.txt and create nickatnite.txt.bob. This doesn't make sense to me as "nickatnite.txt" doesn't have all that path info anyway.
- Populate the "vids" array by grepping for all the shows in nickatnite.txt.bob within the overall file list. Remove anything in the global exclusion list, then do a random sort on all that and shove it into "vids". I suppose I could limit this to only the top 50 or however many files right here....
From there I just iterate through the vids() array in increments of however many shows between commercials. Then I insert the commercials from a similarly populated array and resume iterating through episodes until I hit the total number of episodes I want.
I do testing to see if a show is part 1 of 2, or part 2 of 2. If so it will grab the other part and place it appropriately in the playlist so you're not stuck with a single episode and have to dig for the other one like some kind of animal. Currently I only handle those two cases for two reasons. Empirically there aren't that many things with more than 2 parts in the entire corpus of Shit I Own. Those that are tend to be things like Rocky & Bullwinkle which stretch out a story arc over half a season, or vintage Doctor Who. Rocky & Bullwinkle really doesn't matter, you get the jist. If I really care about watching a whole arc in a 50 year old Doctor Who, I'll just go watch it. It's not like I can't browse for files. But I don't need 5 hours of shows popping up in the middle of my list.
I just don't want to have to dig for Time's Arrow part 1 just because Part 2 was fed into the SciFi playlist. I'm usually watching TV as I go to sleep so two hours is plenty.
Fun fact, I don't count these episodes in the total, so you end up with like a few extra episodes in the playlist if there are multipart ones. Also, if the file I pull is Part 1 of 2, then Part 2 goes in at the end of the bus. So you'll get "part 1", "Some other show", "part 2". Again, on my Todo.
Anticipating some Qs:
- "Why don't you just"
- Use "shuffle mode"?
Really good question. I'm being polite and I really shouldn't be. Anyway because with Shuffle Mode on a folder of TV shows, I don't get to choose my entry point. I can't for instance skip the first 12 episodes and enter at one I haven't seen in a while.
- Use Kodi or Jellyfin's playlists?
One, because this is 100% automated with new playlists every day and I never have to think about it. And it's platform agnostic. I can pull an M3U into VLC or whatever and play it there. I'm not naive enough to believe that Kodi or Jellyfin or whatever is going to be around in 20 years. You know what will be around? Something that can play a bog standard M3U on my TV.
- Ew absolute paths
There are reasons for this. One time I owned a Mac. By default that Mac put CIFS mounts into /Volumes/ along with other mounted filesystems. I haven't used a Mac in like a decade, but I standardized on that, and now every machine I have uses the /Volumes/... paradigm for our main file storage.. This can get awkward when I use something like a phone or an Amazon Fire Stick. All of this can be switched at a moment's notice to relative paths from wherever the playlist file is though no problem.
Also I am now generating both so I can "upgrade" to a Flatpak Kodi since their apt repo isn't going to work anymore.
- Ew bash
Get bent. I'm not a developer, clearly, but I know how to get pretty much anything I want to get done, done. Bash doesn't make a habit of introducing breaking changes and it works every goddamn where.