The Free Software Media System - Server Backend & API
Merge remote-tracking branch 'upstream/master' into epg-fixes
Shadowghostb717754ed872
diff --cc src/Jellyfin.LiveTv/Listings/XmlTvListingsProvider.csindex 0b73c6776f,318c3a2d36..ec2e6cfcc9--- a/src/Jellyfin.LiveTv/Listings/XmlTvListingsProvider.cs+++ b/src/Jellyfin.LiveTv/Listings/XmlTvListingsProvider.cs@@@ -76,42 -74,28 +74,42 @@@ namespace Jellyfin.LiveTv.Listing}else{- Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));+ Directory.CreateDirectory(cacheDir);}- if (info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase))+ try{- _logger.LogInformation("Downloading xmltv listings from {Path}", info.Path);+ if (info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase))+ {+ _logger.LogInformation("Downloading xmltv listings from {Path}", info.Path);- using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(info.Path, cancellationToken).ConfigureAwait(false);- var redirectedUrl = response.RequestMessage?.RequestUri?.ToString() ?? info.Path;- var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);- await using (stream.ConfigureAwait(false))+ using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(info.Path, cancellationToken).ConfigureAwait(false);+ var redirectedUrl = response.RequestMessage?.RequestUri?.ToString() ?? info.Path;+ var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);+ await using (stream.ConfigureAwait(false))+ {+ return await UnzipIfNeededAndCopy(redirectedUrl, stream, cacheFile, cancellationToken).ConfigureAwait(false);+ }+ }+ else{- return await UnzipIfNeededAndCopy(redirectedUrl, stream, cacheFile, cancellationToken).ConfigureAwait(false);+ var stream = AsyncFile.OpenRead(info.Path);+ await using (stream.ConfigureAwait(false))+ {+ return await UnzipIfNeededAndCopy(info.Path, stream, cacheFile, cancellationToken).ConfigureAwait(false);+ }}}- else+ catch (Exception ex){- var stream = AsyncFile.OpenRead(info.Path);- await using (stream.ConfigureAwait(false))+ _logger.LogError(ex, "Error downloading or processing XMLTV file from {Path}", info.Path);++ if (File.Exists(cacheFile)){- return await UnzipIfNeededAndCopy(info.Path, stream, cacheFile, cancellationToken).ConfigureAwait(false);+ File.Delete(cacheFile);}++ throw;}}