TV_SORT(1p)
πΈ TV_SORT π
okay bestie, gather round, because we're talking about tv_sort, a little Perl script from the User Contributed Perl Documentation collection, and honestly? it's giving β¨file-hygiene iconβ¨.
β¨ NAME β¨
tv_sort β sort XMLTV listings files by date, and add stop times. no cap. π
π¦ SYNOPSIS π¦
tv_sort [--help] [--by-channel] [--output FILE] [FILE...]
that's the whole vibe. that's the shape of it. π
π DESCRIPTION π
so here's the tea π: tv_sort reads XMLTV data and writes out the exact same data, except sorted in date order. same data, better order. glow-up but make it chronological.
and here's the part that's lowkey iconic: where the stop times of programmes are missing, it guesses them π β using the start time of the next programme on the same channel. like, "hey, the next thing starts here, so you probably ended right before that, babe." β¨
but bestieβ¦ for the last programme of a channel, no stop time can be added. there's nothing after it to peek at. it's the final girl. π
tv_sort also does some sanity checks while it's at it, like making sure no two programmes on the same channel overlap. we love a program that does a vibe check on your data. π«Ά
here are the options, one by one, no skipping, periodt:
--output FILEβ write to FILE instead of standard output. π--by-channelβ sort first by channel id, then by date within each channel. it's channel-first, times-second energy. π--duplicate-errorβ if the input contains the same programme more than once, consider this as an error. the default is to silently ignore duplicate entries. so without this flag, dupes get the silent treatment; with it, they get βcaughtβ. π₯
now, the sorting logic itself, because it's more specific than you'd think:
- the time sorting is by start time, then by stop time.
- without
--by-channel: if start times and stop times are equal, two programmes are sorted by internal channel id. - with
--by-channel: channel id is compared first, and then times.
and here's the big-picture way to think about it π§ β you can think of tv_sort as converting XMLTV data into a canonical form, which is super useful for diffing two files. like, run it on both, and any diff you see is a real diff, not just "these were listed in a different order." chef's kiss. π
π EXAMPLES π
at a typical Unix shell or Windows command prompt:
tv_sort <in.xml >out.xml
tv_sort in.xml --output out.xml
these are different ways of saying the same thing. same outcome, two fits. πβ¨
π AUTHOR π
Ed Avis, ed@membled.com π¦
and that's the whole page, bestie! this one came from perl v5.40.1, dated 2025-04-19, so if you're reading this in the future β hi, hope you're slaying ππΈ
π¦ where this page comes from
- debian trixie: xmltv-util 1.4.0-1 Β· GPL-2.0-only
- ubuntu resolute: xmltv-util 1.4.0-1 Β· GPL-2.0-only
- ubuntu stonking: xmltv-util 1.4.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms