Augment(3)
π¦ Augment(3) π¦
User Contributed Perl Documentation, bestie. This is the XMLTV::Augment page, and it slays. iykyk.
π NAME π
XMLTV::Augment β Augment XMLTV listings files with automatic and user-defined rules.
β¨ DESCRIPTION β¨
Okay so the whole point: augment an XMLTV xml file by applying corrections (βfixupsβ) to programmes that match defined criteria (βrulesβ). Thatβs the tea.
Two types of rules get actioned: (i) automatic, (ii) user-defined.
Automatic rules use pre-programmed input and output to modify the input programmes. Example vibes: removing a "title" where itβs repeated in a "sub-title" (like "Horizon" / "Horizon: Star Wars"), or trying to identify and extract series/episode numbers from the programme's title, sub-title or description. Iconic little cleanup machine.
User-defined rules use the content of a "rules" file, which lets programmes matching certain user-defined criteria get corrected/enhanced with the user data supplied. Examples: adding/changing categories for all episodes of "Horizon", or fixing misspellings in titles, etc.
By setting appropriate options in the "config" file, the "rules" file can be automatically downloaded using XMLTV::Supplement.
π§° EXPORTED FUNCTIONS π§°
setEncoding
Set the assumed encoding of the rules file.
inputChannel
Store each channel found in the input programmes file for later processing by stats.
augmentProgramme
Augment a programme using (i) pre-determined rules and (ii) user-defined rules. Which rules are processed is determined by the options set in the config file.
printInfo
Print the lists of actions taken and suggestions for further fixups.
end
Do any final processing before exit (e.g. close the log file if necessary).
π INSTANTIATION π
new XMLTV::Augment( { ...parameters...} );
Possible parameters:
ruleβ filename of file containing fixup rules (if omitted then no user-defined rules will be actioned) (overrides auto-fetch Supplement if that is defined; see sample options file).configβ filename of config file to read (if omitted then no config file will be used).encodingβ assumed encoding of the rules file (default = UTF-8).statsβ whether to print the audit stats in the log (values = 0,1) (default = 1).logβ filename of output log.debugβ debug level (values 0-10) (default = no debug). Note: debug level > 3 is not likely to be of much use unless you are developing code.
π TYPICAL USAGE π
- Create the
XMLTV::Augmentobject. - Pass each channel to
inputChannel(). - Pass each programme to
augmentProgramme(). - Tidy up using
printInfo()&end().
#instantiate the object
my $augment = new XMLTV::Augment(
"rule" => "myrules.txt",
"config" => "myconfig.txt",
"log" => "augment.log",
);
die "failed to create XMLTV::Augment object" if !$augment;
for each channel... {
# store the channel details
$augment->inputChannel( $ch );
}
for each programme... {
# augmentProgramme will now do any requested processing of the input xml
$prog = $augment->augmentProgramme( $prog );
}
# log the stats
$augment->printInfo();
# close the log file if necessary
$augment->end();
Note: you are responsible for reading/writing to the XMLTV .xml file; the package will not do that for you.
π RULES π
Alright bestie, hereβs the rule catalog. Every rule number and every exact example stays exactly where it belongs. No cap, no skipping.
πΈ Rule #A1 β remove_duplicated_new_title_in_ep
Remove "New $title :" from <sub-title>.
If sub-title starts with "New" + <title> + separator, then it will be removed from the sub-title. The separator can be any of .,:;-.
in : "Antiques Roadshow / New Antiques Roadshow: Doncaster"
out: "Antiques Roadshow / Doncaster"
πΊ Rule #A2 β remove_duplicated_title_and_ep_in_ep
Remove duplicated programme title and episode from <sub-title>.
If sub-title starts with <title> + separator + <episode> + separator + <episode>, then it will be removed from the sub-title. The separator can be any of .,:;-.
in : "Antiques Roadshow / Antiques Roadshow: Doncaster: Doncaster"
out: "Antiques Roadshow / Doncaster"
π¦ Rule #A3 β remove_duplicated_title_in_ep
Remove duplicated programme title from <sub-title>.
i) If sub-title starts with <title> + separator, then it will be removed from the sub-title. ii) If sub-title ends with separator + <title>, then it will be removed from the sub-title. iii) If sub-title starts with <title>(...), then the sub-title will be set to the text in brackets. iv) If sub-title equals <title>, then the sub-title will be removed.
The separator can be any of .,:;-.
in : "Antiques Roadshow / Antiques Roadshow: Doncaster"
out: "Antiques Roadshow / Doncaster"
in : "Antiques Roadshow / Antiques Roadshow (Doncaster)"
out: "Antiques Roadshow / Doncaster"
in : "Antiques Roadshow / Antiques Roadshow"
out: "Antiques Roadshow / "
π₯ Rule #A4 β update_premiere_repeat_flags_from_desc
Set the <premiere> element and remove any <previously-shown> element if <desc> starts with "Premiere." or "New series". Remove the "Premiere." text.
Set the <previously-shown> element and remove any <premiere> element if <desc> starts with "Another chance" or "Rerun" or "Repeat".
π Rule #A5 β check_potential_numbering_in_text
Check for potential series, episode and part numbering in the title, episode and description fields.
β Rule #A5.1 β extract_numbering_from_title
Extract series/episode numbering found in <title>.
β Rule #A5.2 β extract_numbering_from_episode
Extract series/episode numbering found in <sub-title>.
β Rule #A5.3 β extract_numbering_from_desc
Extract series/episode numbering found in <desc>.
β Rule #A5.4 β make_episode_from_part_numbers
If no <sub-title> then make one from "part" numbers.
in : "Panorama / " desc = "Part 1/2..."
out: "Panorama / Part 1 of 2"
π Rule #user β process_user_rules
Process programme against user-defined fixups.
The individual rules each have their own option to run or not; consider this like an on/off switch for all of them. I.e. if this option is off then no user rules will be run (irrespective of any other option flags).
π Rule #1 β process_non_title_info
Remove specified non-title text from <title>.
If title starts with text + separator, then it will be removed from the title. The separator can be any of :;-.
rule: 1|Python Night
in : "Python Night: Monty Python - Live at the Hollywood Bowl / "
out: "Monty Python - Live at the Hollywood Bowl / "
π Rule #11 β process_demoted_titles
Promote demoted title from <sub-title> to <title>.
If title matches, and sub-title starts with text then remove matching text from sub-title and move it into the title. Any text after 'separator' in the sub-title is preserved. 'separator' can be any of .,:;-.
rule: 11|Blackadder~Blackadder II
in : "Blackadder / Blackadder II: Potato"
out: "Blackadder II / Potato"
π¬ Rule #10 β process_replacement_titles_desc
Replace specified <title> / <sub-title> with title/episode pair supplied using <desc>.
If title & sub-title match supplied data, then replace <title> and <sub-title> with new data supplied.
rule: 10|Which Doctor~~Gunsmoke~Which Doctor~Festus and Doc go fishing, but are captured by a family that is feuding with the Haggens.
in : "Which Doctor / " desc> = " Festus and Doc go fishing, but are captured by a family that is feuding with the Haggens. ..."
out: "Gunsmoke / Which Doctor"
π₯ Rule #8 β process_replacement_titles_episodes
Replace specified <title> / <sub-title> with title/episode pair supplied.
If title & sub-title match supplied data, then replace <title> and <sub-title> with new data supplied.
rule: 8|Top Gear USA Special~Detroit~Top Gear~USA Special
in : "Top Gear USA Special / Detroit"
out: "Top Gear / USA Special"
rule: 8|Top Gear USA Special~~Top Gear~USA Special
in : "Top Gear USA Special / "
out: "Top Gear / USA Special"
or
in : "Top Gear USA Special / 1/6."
out: "Top Gear / 1/6. USA Special"
π Rule #2 β process_mixed_title_subtitle
Extract sub-title from <title>.
If title starts with text + separator, then the text after it will be moved into the sub-title. The separator can be any of :;-.
rule: 2|Blackadder II
in : "Blackadder II: Potato / "
out: "Blackadder II / Potato"
π§ Rule #3 β process_mixed_subtitle_title
Extract sub-title from <title>.
If title ends with separator + text, then the text before it will be moved into the sub-title. The separator can be any of :;-.
rule: 3|Storyville
in : "Kings of Pastry :Storyville / "
out: "Storyville / Kings of Pastry"
π Rule #4 β process_reversed_title_subtitle
Reverse <title> and <sub-title>.
If sub-title matches the rule's text, then swap the title and sub-title.
rule: 4|Storyville
in : "Kings of Pastry / Storyville"
out: "Storyville / Kings of Pastry"
π₯ Rule #5 β process_replacement_titles
Replace <title> with supplied text.
If title matches the rule's text, then use the replacement text supplied.
rule: 5|A Time Team Special~Time Team
in : "A Time Team Special / Doncaster"
out: "Time Team / Doncaster"
This is the one which you will probably use most. It can be used to fix most incorrect titles - e.g. spelling mistakes; punctuation; character case; etc.
π Rule #13 β process_subtitle_remove_text
Remove specified text from <sub-title> for a given <title>.
If sub-title starts with text + separator, or ends with separator + text, then it will be removed from the sub-title. The separator can be any of .,:;- and is optional.
rule: 13|Time Team~A Time Team Special
in : "Time Team / Doncaster : A Time Team Special "
out: "Time Team / Doncaster"
π Rule #7 β process_replacement_episodes
Replace <sub-title> with supplied text.
If sub-title matches the rule's text, then use the replacement text supplied.
rule: 7|Time Team~Time Team Special: Doncaster~Doncaster
in : "Time Team / Time Team Special: Doncaster"
out: "Time Team / Doncaster"
π Rule #9 β process_replacement_ep_from_desc
Rule #9
Replace <sub-title> with supplied text when the <desc> matches that given. π
If sub-title matches the rule's text, then use the replacement text supplied, like so:
rule: 9|Heroes of Comedy~The Goons~The series celebrating great British comics pays tribute to the Goons.
in : "Heroes of Comedy / "
out: "Heroes of Comedy / The Goons"
or
in : "Heroes of Comedy / Spike Milligan"
out: "Heroes of Comedy / The Goons"
π¦ process_replacement_genres β Rule #6 π¦
Replace <category> with supplied text. β¨
If title matches the rule's text, then use the replacement category(-ies) supplied (note ALL existing categories are replaced). No cap.
rule: 6|Antiques Roadshow~Entertainment~Arts~Shopping
in : "Antiques Roadshow / " category "Reality"
out: "Antiques Roadshow / " category "Entertainment" + "Arts" + "Shopping"
You can specify a wildcard with the title by using %% which represents any number of characters. So for example "News%%" will match "News", "News and Weather", "Newsnight", etc. But be careful; "%%News%%" will also match "John Craven's Newsround", "Eurosport News", "Election Newsroom Live", "Have I Got News For You", "Scuzz Meets Jason Newsted", etc. π That wildcard is lowkey dangerous, bestie β itβs giving βmatch everythingβ energy.
π process_replacement_film_genres β Rule #12 π
Replace "Film"/"Films" <category> with supplied text. π¬
If title matches the rule's text and the prog has category "Film" or "Films", then use the replacement category(-ies) supplied (note ALL categories are replaced, not just "Film"). Iconic.
rule: 12|The Hobbit Special~Entertainment~Interview
in : "The Hobbit Special / " category "Film" + "Drama"
out: "The Hobbit Special / " category "Entertainment" + "Interview"
π process_translate_genres β Rule #14 π
Replace <category> with supplied value(s). π«Ά
If category matches one found in the prog, then replace it with the category(-ies) supplied (note any other categories are left alone). Periodt.
rule: 14|Soccer~Football
in : "Leeds v Arsenal" category "Soccer"
out: "Leeds v Arsenal" category "Football"
rule: 14|Adventure/War~Action Adventure~War
in : "Leeds v Arsenal" category "Adventure/War"
out: "Leeds v Arsenal" category "Action Adventure" + "War"
π process_add_genres_to_channel β Rule #15 π
Add a category to all programmes on a specified channel. πΊ
If channel matches this prog, then add the supplied category(-ies) to the programme (note any other categories are left alone).
rule: 15|travelchannel.co.uk~Travel
in : "World's Greatest Motorcycle Rides" category "Motoring"
out: "World's Greatest Motorcycle Rides" category "Motoring" + "Travel"
rule: 15|cnbc.com~News~Business
in : "Investing in India" category ""
out: "Investing in India" category "News" + "Business"
β οΈ You should be very careful with this one as it will add the category you specify to EVERY programme broadcast on that channel. This may not be what you always want (e.g. Teleshopping isn't really"music"even if it is on MTV!). Like, imagine adding"Music"to a channel that shows shopping β thatβs not the vibe. π
β process_remove_numbering_from_programmes β Rule #16 β
Remove episode numbering from a given programme title (on an optionally-specified channel). π§
If title matches the one in the prog, all programme numbering for the programme is removed, on any channel. An optional channel identifier can be provided to restrict the removal of programme numbering to the given channel.
rule: 16|Bedtime Story
in : "CBeebies Bedtime Story" episode-num ".700."
out: "CBeebies Bedtime Story" episode-num ""
rule: 16|CBeebies Bedtime Story~cbeebies.bbc.co.uk
in : "CBeebies Bedtime Story" episode-num ".700."
out: "CBeebies Bedtime Story" episode-num ""
Remember to specify the optional channel limiter if you have good programme numbering for a given programme title on some channels but not others. Itβs the little details that slay. π
π AUTHOR π
Geoff Westcott, honir.at.gmail.dot.com, Dec. 2014. π
This code is based on the "fixup" method/code defined in tv_grab_uk_rt grabber and credit is given to the author Nick Morrott. Giving credit where itβs due β we love to see it. π«Ά
And thatβs a wrap, bestie! This manual page is for Augment(3) from perl v5.42.2, dated 2025-06-30. Stay slaying, and may your categories always be correctly translated. β¨π
π₯
π¦ where this page comes from
- alpine 3.24: xmltv-doc 1.4.0-r1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms