Skip to content

Repository files navigation

BuildReleaseLicenseNuget (with prereleases)NugetCoverage Status

XmlTvSharp

A high-performance XMLTV reader and writer for .NET.

Features

  • Read and write XMLTV documents.
  • Forward-only access to top-level channels and programmes.
  • Preserve XMLTV date/time values with XmlTvDateTime.
  • Use the standard XMLTV profile or supported compatibility profiles such as Jellyfin.
  • Targets .NET 8 and .NET Standard 2.0.

Installation

dotnet add package XmlTvSharp

Reading

usingXmlTvSharp;usingXmlTvSharp.Models;// Load the whole XMLTV document when you want channels and programmes in memory.XmlTvDocumentdocument=awaitXmlTvReader.ReadAsync("guide.xml");foreach(XmlTvChannelchannelindocument.Channels){Console.WriteLine($"{channel.Id}: {channel.DisplayNames[0].Value}");}foreach(XmlTvProgrammeprogrammeindocument.Programmes){Console.WriteLine($"{programme.Start.ToXmlTvString()}{programme.ChannelId}");}

Writing

usingXmlTvSharp;usingXmlTvSharp.Models;vardocument=newXmlTvDocument();// Build a minimal XMLTV document with one channel and one programme.document.Channels.Add(newXmlTvChannel("channel-one","Channel One"));document.Programmes.Add(newXmlTvProgramme(XmlTvDateTime.Parse("20260605120000 +0000"),"channel-one","News"));awaitXmlTvWriter.WriteAsync(document,"guide.xml");

Forward-Only Reading

usingXmlTvSharp;usingXmlTvSharp.Models;usingvarreader=newXmlTvReader("guide.xml");// Read root <tv> metadata once, then read top-level children forward-only.XmlTvMetadatametadata=awaitreader.ReadMetadataAsync();while(awaitreader.ReadElementAsync()is{}element){switch(element){caseXmlTvChannelchannel:Console.WriteLine(channel.Id);break;caseXmlTvProgrammeprogramme:Console.WriteLine(programme.ChannelId);break;}}

Additional APIs

  • XmlTvReader and XmlTvWriter provide forward-only read and write APIs.
  • XmlTvReadFilter includes channel and programme branches by ID.
  • XmlTvReaderOptions and XmlTvWriterOptions configure compatibility profiles and XML output.

License

This project is licensed under the MIT License. See LICENSE.

About

A high-performance XMLTV reader and writer for .NET.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages