TV_SORT(1p)

πŸ“¦
version 1.4.0 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

🌸 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