diff options
| author | Cody Robibero <cody@robibe.ro> | 2022-04-15 13:29:10 -0600 |
|---|---|---|
| committer | Joshua Boniface <joshua@boniface.me> | 2022-04-17 15:45:51 -0400 |
| commit | 8203e933d5e9b47726cd6f46e42d07e146b3ab59 (patch) | |
| tree | 81cd3485b3cd307ecfbfc562da388293f2c85bc0 /Emby.Server.Implementations | |
| parent | d6197139afaf8ae6ca8f214082e71e4037edaee7 (diff) | |
Merge pull request #7592 from 1337joe/live-tv-fixes
(cherry picked from commit cd93f49fa87d6e5b0bcc535f8f92b5709b0e3153)
Signed-off-by: Joshua Boniface <joshua@boniface.me>
Diffstat (limited to 'Emby.Server.Implementations')
| -rw-r--r-- | Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index d56c9bb66..f70e5b089 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -27,6 +27,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings { public class XmlTvListingsProvider : IListingsProvider { + private static readonly TimeSpan _maxCacheAge = TimeSpan.FromHours(1); + private readonly IServerConfigurationManager _config; private readonly IHttpClientFactory _httpClientFactory; private readonly ILogger<XmlTvListingsProvider> _logger; @@ -70,13 +72,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings return UnzipIfNeeded(info.Path, info.Path); } - string cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + "-" + info.Id + ".xml"; + string cacheFilename = info.Id + ".xml"; string cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename); - if (File.Exists(cacheFile)) + if (File.Exists(cacheFile) && File.GetLastWriteTimeUtc(cacheFile) >= DateTime.UtcNow.Subtract(_maxCacheAge)) { return UnzipIfNeeded(info.Path, cacheFile); } + File.Delete(cacheFile); _logger.LogInformation("Downloading xmltv listings from {Path}", info.Path); Directory.CreateDirectory(Path.GetDirectoryName(cacheFile)); |
