{"id":16260690,"url":"https://github.com/eddami/xmltvsharp","last_synced_at":"2025-04-11T08:09:42.852Z","repository":{"id":198252607,"uuid":"700507053","full_name":"eddami/XmlTvSharp","owner":"eddami","description":"A high-performance, asynchronous XMLTV parser for TV program data.","archived":false,"fork":false,"pushed_at":"2024-01-24T01:44:44.000Z","size":47,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T05:36:00.343Z","etag":null,"topics":["epg","xmltv","xmltv-epg","xmltv-format"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eddami.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-04T18:10:33.000Z","updated_at":"2024-08-26T08:23:15.000Z","dependencies_parsed_at":"2024-01-24T02:46:00.896Z","dependency_job_id":null,"html_url":"https://github.com/eddami/XmlTvSharp","commit_stats":null,"previous_names":["eddami/xmltvsharp"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddami%2FXmlTvSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddami%2FXmlTvSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddami%2FXmlTvSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddami%2FXmlTvSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddami","download_url":"https://codeload.github.com/eddami/XmlTvSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248360320,"owners_count":21090678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["epg","xmltv","xmltv-epg","xmltv-format"],"created_at":"2024-10-10T16:20:47.656Z","updated_at":"2025-04-11T08:09:42.821Z","avatar_url":"https://github.com/eddami.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://github.com/eddami/XmlTvSharp/actions/workflows/build.yml/badge.svg)](https://github.com/eddami/XmlTvSharp/actions/workflows/build.yml)\n[![Release](https://github.com/eddami/XmlTvSharp/actions/workflows/release.yml/badge.svg)](https://github.com/eddami/XmlTvSharp/actions/workflows/release.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eddami/XmlTvSharp/blob/main/LICENSE)\n[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/XmlTvSharp)](https://www.nuget.org/packages/XmlTvSharp)\n[![Nuget](https://img.shields.io/nuget/dt/XmlTvSharp)](https://www.nuget.org/packages/XmlTvSharp)\n[![Coverage Status](https://coveralls.io/repos/github/eddami/XmlTvSharp/badge.svg?branch=main)](https://coveralls.io/github/eddami/XmlTvSharp?branch=main)\n\n# XmlTvSharp\n\nA high-performance, asynchronous XMLTV parser for TV program data.\n\n## Installation\n\nYou can install this library via NuGet Package Manager:\n\n```bash\nInstall-Package XmlTvSharp\n```\n\n## Benchmark\n\nWe tested the library using an XMLTV file featuring 19,804 channels and 1,979,805 programmes.\n\n```\nAMD Ryzen 5 3600, 1 CPU, 12 logical and 6 physical cores\n.NET SDK 7.0.109\n[Host]     : .NET 7.0.9 (7.0.923.32301), X64 RyuJIT AVX2\nDefaultJob : .NET 7.0.9 (7.0.923.32301), X64 RyuJIT AVX2\n\n\n|       Method |    Mean |   Error |  StdDev |\n|------------- |--------:|--------:|--------:|\n| ReadAllAsync | 20.65 s | 0.293 s | 0.229 s |\n```\n\n## Usage\n\n### Reading All XMLTV Elements\n\n```csharp\n// Specify the path to the XML file containing TV program information\nvar xmlFilePath = \"path/to/your/xmltv/file.xml\";\n\n// Cancellation token\nvar cancellationToken = new CancellationToken();\n\n// Customize the parsing behaviour\nvar settings = new XmlTvReaderSettings();\n\n// Read all TV channels and programmes asynchronously\nvar result = await XmlTvReader.ReadAllAsync(xmlFilePath, settings, cancellationToken);\n\n// Access the parsed TV channels and programmes\nvar channels = result.Channels;\nvar programmes = result.Programmes;\n```\n\n### Reading XMLTV Elements Sequentially\n\n```csharp\n// Specify the path to the XML file containing TV program information\nvar xmlFilePath = \"path/to/your/xmltv/file.xml\";\n\n// Cancellation token\nvar cancellationToken = new CancellationToken();\n\n// Customize the parsing behaviour\nvar settings = new XmlTvReaderSettings();\n\nusing var reader = new XmlTvReader(xmlFilePath, settings);\n\nIXmlTvElement element;\n// Read XMLTV elements sequentially asynchronously\nwhile ((element = await reader.ReadAsync(cancellationToken)) != null)\n{\n    if (element is XmlTvChannel channel)\n    {\n        // Process the parsed channel element\n    }\n    else if (element is XmlTvProgramme programme)\n    {\n        // Process the parsed programme element\n    }\n}\n```\n\n### XmlTvReaderSettings\n\nXmlTvReaderSettings allows customization of the parsing behavior. Here are the default values:\n\n```csharp\nvar settings = new XmlTvReaderSettings\n{\n    FilterByChannelId = null,\n    FilterByProgrammeChannelId = null,\n    FilterByProgrammeTime = null,\n    DefaultLanguage = \"en\",\n    TimeZone = TimeZoneInfo.Utc,\n    IgnoreChannels = false,\n    IgnoreProgrammes = false,\n    IncludeOuterXml = false\n};\n```\n\n- `FilterByChannelId`: A function to filter all elements by their channel IDs.\n- `FilterByProgrammeChannelId`: A function to filter programme elements by their channel IDs.\n\n**Note:** When both `FilterByChannelId` and `FilterByProgrammeChannelId` are set, `FilterByProgrammeChannelId` takes\nprecedence over `FilterByChannelId` for filtering programme elements by their channel IDs.\n\n- `FilterByProgrammeTime`: A function to filter programmes by their start and stop times.\n- `DefaultLanguage`: Default language to use if language information is not available in the XML data.\n- `TimeZone`: Time zone to convert programme start and stop times. Default is UTC.\n- `IgnoreChannels`: Set to true to ignore channel elements during parsing.\n- `IgnoreProgrammes`: Set to true to ignore programme elements during parsing.\n- `IncludeOuterXml`: Set to true to include the outer XML of elements during parsing.\n\n**Warning:** Setting `IncludeOuterXml` to `true` will cause the parser to allocate an extra `XmlReader` instance,\npotentially impacting performance.\n\n**Example Usage:**\n\n```csharp\nvar settings = new XmlTvReaderSettings\n{\n    FilterByChannelId = channelId =\u003e channelId.StartsWith(\"custom_\"),\n    FilterByProgrammeChannelId = channelId =\u003e channelId.StartsWith(\"custom_programme_\"),\n    FilterByProgrammeTime = (startTime, endTime) =\u003e startTime.DayOfWeek == DayOfWeek.Monday \u0026\u0026 endTime.Hour \u003c 18,\n    DefaultLanguage = \"fr\", // Set default language to French\n    TimeZone = TimeZoneInfo.FindSystemTimeZoneById(\"Eastern Standard Time\"), // Set time zone to EST\n    IgnoreChannels = false, // Do not ignore channel elements\n    IgnoreProgrammes = true, // Ignore programme elements during parsing\n    IncludeOuterXml = true // Include outer XML of elements during parsing\n};\n```\n\n## Contributing\n\nWe welcome your contributions to this project. If you find a bug, have a feature request, or want to contribute in any\nother way, please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License - see\nthe [LICENSE](https://github.com/eddami/XmlTvSharp/blob/main/LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddami%2Fxmltvsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddami%2Fxmltvsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddami%2Fxmltvsharp/lists"}