Browse Source

fix clipboard and logs (#1466)

* fix copy to clipboard in some cases

* improve subtitle language selection logging

* log playout item details
pull/1474/head
Jason Dove 2 years ago committed by GitHub
parent
commit
5291832e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 21
      ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs
  3. 13
      ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs
  4. 25
      ErsatzTV/Pages/_Host.cshtml

3
CHANGELOG.md

@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **This mode does NOT detect black and intelligently crop**
- The goal is to fill the canvas by over-scaling and cropping, instead of minimally scaling and padding
- Include `inputstream.ffmpegdirect` properties in channels.m3u when requested by Kodi
- Log playout item title and path when starting a stream
- This will help with media server libraries where the URL passed to ffmpeg doesn't indicate which file is streaming
### Fixed
- Fix playout bug that caused some schedule items with fixed start times to be pushed to the next day
@ -22,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -22,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Remove ffmpeg and ffprobe as required dependencies for scanning media server libraries
- Note that ffmpeg is still *always* required for playback to work
- Fix PGS subtitle pixel format with Intel VAAPI
- Fix some cases where `Copy` button would fail to copy to clipboard
### Changed
- Upgrade ffmpeg to 6.1, which is now *required* for all installs

21
ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using CliWrap;
using Dapper;
using ErsatzTV.Application.Playouts;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Domain.Filler;
@ -83,6 +84,10 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -83,6 +84,10 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
.ThenInclude(mi => (mi as Episode).MediaVersions)
.ThenInclude(mv => mv.Streams)
.Include(i => i.MediaItem)
.ThenInclude(mi => (mi as Episode).Season)
.ThenInclude(s => s.Show)
.ThenInclude(s => s.ShowMetadata)
.Include(i => i.MediaItem)
.ThenInclude(mi => (mi as Movie).MovieMetadata)
.ThenInclude(mm => mm.Subtitles)
.Include(i => i.MediaItem)
@ -142,6 +147,22 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -142,6 +147,22 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
foreach (PlayoutItemWithPath playoutItemWithPath in maybePlayoutItem.RightToSeq())
{
try
{
PlayoutItemViewModel viewModel = Mapper.ProjectToViewModel(playoutItemWithPath.PlayoutItem);
if (!string.IsNullOrWhiteSpace(viewModel.Title))
{
_logger.LogDebug(
"Found playout item {Title} with path {Path}",
viewModel.Title,
playoutItemWithPath.Path);
}
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Failed to get playout item title");
}
MediaVersion version = playoutItemWithPath.PlayoutItem.MediaItem.GetHeadVersion();
string videoPath = playoutItemWithPath.Path;

13
ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs

@ -138,6 +138,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector @@ -138,6 +138,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
return None;
}
var allCodes = new List<string>();
string language = (preferredSubtitleLanguage ?? string.Empty).ToLowerInvariant();
if (string.IsNullOrWhiteSpace(language))
{
@ -146,10 +147,14 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector @@ -146,10 +147,14 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
else
{
// filter to preferred language
List<string> allCodes = await _searchRepository.GetAllLanguageCodes(new List<string> { language });
allCodes = await _searchRepository.GetAllLanguageCodes(new List<string> { language });
if (allCodes.Count > 1)
{
_logger.LogDebug("Preferred subtitle language has multiple codes {Codes}", allCodes);
}
subtitles = subtitles
.Filter(
s => allCodes.Any(c => string.Equals(s.Language, c, StringComparison.OrdinalIgnoreCase)))
.Filter(s => allCodes.Any(c => string.Equals(s.Language, c, StringComparison.OrdinalIgnoreCase)))
.ToList();
}
@ -185,7 +190,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector @@ -185,7 +190,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
"Found no subtitles for channel {ChannelNumber} with mode {Mode} matching language {Language}",
channel.Number,
subtitleMode,
preferredSubtitleLanguage);
allCodes);
return None;
}

25
ErsatzTV/Pages/_Host.cshtml

@ -79,11 +79,26 @@ @@ -79,11 +79,26 @@
};
window.clipboardCopy = {
copyText: function (codeElement) {
navigator.clipboard.writeText(codeElement.textContent)
.catch(function (error) {
console.log(error);
});
copyText: async function (codeElement) {
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(codeElement.textContent);
} else {
const textArea = document.createElement("textarea");
textArea.value = codeElement.textContent;
textArea.style.position = "absolute";
textArea.style.left = "-999999px";
document.body.prepend(textArea);
textArea.select();
try {
document.execCommand('copy');
} catch (error) {
console.error(error);
} finally {
textArea.remove();
}
}
}
};
</script>

Loading…
Cancel
Save