Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Release License Nuget (with prereleases) Nuget Coverage 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

using XmlTvSharp;
using XmlTvSharp.Models;

// Load the whole XMLTV document when you want channels and programmes in memory.
XmlTvDocument document = await XmlTvReader.ReadAsync("guide.xml");

foreach (XmlTvChannel channel in document.Channels)
{
    Console.WriteLine($"{channel.Id}: {channel.DisplayNames[0].Value}");
}

foreach (XmlTvProgramme programme in document.Programmes)
{
    Console.WriteLine($"{programme.Start.ToXmlTvString()} {programme.ChannelId}");
}

Writing

using XmlTvSharp;
using XmlTvSharp.Models;

var document = new XmlTvDocument();

// Build a minimal XMLTV document with one channel and one programme.
document.Channels.Add(new XmlTvChannel("channel-one", "Channel One"));
document.Programmes.Add(
    new XmlTvProgramme(
        XmlTvDateTime.Parse("20260605120000 +0000"),
        "channel-one",
        "News"));

await XmlTvWriter.WriteAsync(document, "guide.xml");

Forward-Only Reading

using XmlTvSharp;
using XmlTvSharp.Models;

using var reader = new XmlTvReader("guide.xml");

// Read root <tv> metadata once, then read top-level children forward-only.
XmlTvMetadata metadata = await reader.ReadMetadataAsync();

while (await reader.ReadElementAsync() is { } element)
{
    switch (element)
    {
        case XmlTvChannel channel:
            Console.WriteLine(channel.Id);
            break;

        case XmlTvProgramme programme:
            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.

Releases

Used by

Contributors

Languages