| Crates.io | xmltv |
| lib.rs | xmltv |
| version | 1.0.1 |
| created_at | 2023-02-17 17:44:28.813428+00 |
| updated_at | 2025-08-11 19:06:23.294826+00 |
| description | XMLTV for electronic program guide (EPG) parser and generator using serde. |
| homepage | |
| repository | https://codeberg.org/slundi/xmltv |
| max_upload_size | |
| id | 787689 |
| size | 1,734,852 |
XMLTV for electronic program guide (EPG) parser and generator using serde.
<new/> to be a boolean in order to avoid boilerplateuse std::str::FromStr;
use quick_xml::de::from_str;
use quick_xml::se::to_string_with_root;
use xmltv::*;
fn main() {
let xml = "<tv>\
<programme channel=\"1\" start=\"2021-10-09 12:00:00 +0200\" stop=\"2021-10-09 13:00:00 +0200\">\
<title>Les feux de l'amour é</title>\
</programme>\
<programme channel=\"2\" start=\"2021-10-09 12:20:00 +0200\" stop=\"2021-10-09 12:35:00 +0200\">\
<title lang=\"fr-FR\">Le journal</title>\
</programme>\
<programme channel=\"3\" start=\"2021-10-09 13:00:00 +0200\" stop=\"2021-10-09 13:40:00 +0200\">\
<title>Le journal</title>\
</programme>\
</tv>";
// deserialize into the root object (Tv)
let item: Tv = from_str(xml).unwrap();
// serialize into string
let _out = to_string_with_root("tv", &tv).unwrap();
}
To serialize big files, you can look into tests/from_files.rs::test_programmes_from_files.
It reads programmes one by one without loading everything in RAM.
Install it with cargo install xmltv or with the binaries.
-c <CHANNEL LIST> or --channels=<CHANNEL LIST>: channels you want to keep, ie: -c tf1,m6,Arte. You can also check them with the TUI using -c ?--cleanse <ITEM LIST>: items you want to remove form the XMLTV file. I made this option because, in XMLTV file there are a lot of data and we don't need all of them and we may want to reduce the size of the file. Available items are:
credits: remove all credits. If you want to remove some of them, use:
directorsactorswritersadaptersproducerscomposerseditorspresenterscommentatorsguestscategoriesnewcountrieskeywordssub-titleslanguagesvideosaudiossubtitleslast-chancesdescriptionsdatesorigin-languageslengthpremierespreviously-shownsratingsstar-ratingsreviewsimagesepisode-numsiconsurls-d NUMBER or --days NUMBER: number of days in the EPG to keep-o <FILE> or --output <FILE>: new XMLTV file you want to generate otherwise it is printed in the console.-d <number>. -d 3 means from today and the nex 3 days--no-description,
all credits --no-credits or partial one (--no-directors, --no-actors, --no-guests, ...), --no-categories,
--no-keywords, --no-countries, ... You can also remove unwanted time slot(s) (like between 0:00-6:00 and/or
23:30-23:59) or unwanted day(s) --days 1,2,3,5,6,7 (here no thursday, first day is monday).-l <FILE> or --load <FILE>) from a configuration file to avoid a command with too many arguments or just to follow
favorite programmes.XMLTV DTD is here: https://github.com/XMLTV/xmltv/blob/master/xmltv.dtd