diff --git a/FoliCon/Models/Data/ListItem.cs b/FoliCon/Models/Data/ListItem.cs index d70bbb6..88c4623 100644 --- a/FoliCon/Models/Data/ListItem.cs +++ b/FoliCon/Models/Data/ListItem.cs @@ -12,6 +12,8 @@ public class ListItem : BindableBase private Uri _trailerLink; private string _id; private MediaType _mediaType = MediaType.Unknown; + + private ICollection _videos; private string _initialPoster; private bool _isInitialSet; @@ -79,7 +81,12 @@ public string TrailerKey get => _trailerKey; set => SetProperty(ref _trailerKey, value); } - + + public ICollection Videos + { + get => _videos; + set => SetProperty(ref _videos, value); + } public string Id { get => _id; diff --git a/FoliCon/Models/Data/MediaVideo.cs b/FoliCon/Models/Data/MediaVideo.cs new file mode 100644 index 0000000..6d0cd2b --- /dev/null +++ b/FoliCon/Models/Data/MediaVideo.cs @@ -0,0 +1,3 @@ +namespace FoliCon.Models.Data; + +public record MediaVideo(string Name, string Url); \ No newline at end of file diff --git a/FoliCon/Modules/Convertor/InvertedTextToVisibilityConverter.cs b/FoliCon/Modules/Convertor/InvertedTextToVisibilityConverter.cs index d8d580f..9aa01b0 100644 --- a/FoliCon/Modules/Convertor/InvertedTextToVisibilityConverter.cs +++ b/FoliCon/Modules/Convertor/InvertedTextToVisibilityConverter.cs @@ -6,7 +6,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { if (value is string text) { - return text == "Video not available!" ? Visibility.Visible : Visibility.Hidden; + return text is "" or "Video not available!" ? Visibility.Visible : Visibility.Hidden; } return Visibility.Hidden; diff --git a/FoliCon/Modules/Convertor/TextToVisibilityConverter.cs b/FoliCon/Modules/Convertor/TextToVisibilityConverter.cs index a09c52b..c9cf6e4 100644 --- a/FoliCon/Modules/Convertor/TextToVisibilityConverter.cs +++ b/FoliCon/Modules/Convertor/TextToVisibilityConverter.cs @@ -5,7 +5,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { if (value is string text) { - return text == "Video not available!" ? Visibility.Hidden : Visibility.Visible; + return text is "" or "Video not available!" ? Visibility.Hidden : Visibility.Visible; } return Visibility.Hidden; diff --git a/FoliCon/ViewModels/SearchResultViewModel.cs b/FoliCon/ViewModels/SearchResultViewModel.cs index 810471f..4c2552f 100644 --- a/FoliCon/ViewModels/SearchResultViewModel.cs +++ b/FoliCon/ViewModels/SearchResultViewModel.cs @@ -6,6 +6,8 @@ namespace FoliCon.ViewModels; public class SearchResultViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private const string YoutubeEmbedUrl = "https://www.youtube.com/embed/{0}"; + #region Variables private string _title = Lang.SearchResult; @@ -434,10 +436,9 @@ private async Task GetGameTrailer(string itemId) { return; } - - var key = r.First(v => v.Name == "Trailer"); - SetTrailer(key.VideoId); + SetVideos(r); } + private async Task GetMovieTrailer(string itemId) { @@ -447,15 +448,7 @@ private async Task GetMovieTrailer(string itemId) if (result != null) { - var trailer = ChooseTrailer(result.Results); - if (trailer != null) - { - SetTrailer(trailer.Key); - } - else - { - Logger.Warn("No trailer found for {Title}", ResultListViewData.SelectedItem.Title); - } + SetVideos(result.Results); } } catch (Exception ex) @@ -472,32 +465,51 @@ private async Task GetTvTrailer(string itemId) { return; } + SetVideos(result.Results); + } - var i = ChooseTrailer(result.Results); - - if (i != null) + private static Video ChooseTrailer(IReadOnlyCollection