playlist search - video list
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Models;
|
||||
using VDownload.Services.Data.Settings;
|
||||
using VDownload.Services.UI.StoragePicker;
|
||||
|
||||
namespace VDownload.Core.ViewModels.Home.Helpers
|
||||
{
|
||||
public partial class VideoViewModel : ObservableObject
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly ISettingsService _settingsService;
|
||||
protected readonly IStoragePickerService _storagePickerService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
[ObservableProperty]
|
||||
protected Uri _thumbnailUrl;
|
||||
|
||||
[ObservableProperty]
|
||||
protected string _title;
|
||||
|
||||
[ObservableProperty]
|
||||
protected string _author;
|
||||
|
||||
[ObservableProperty]
|
||||
protected DateTime _publishDate;
|
||||
|
||||
[ObservableProperty]
|
||||
protected TimeSpan _duration;
|
||||
|
||||
[ObservableProperty]
|
||||
protected long _views;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
protected ObservableCollection<VideoStream> _streams;
|
||||
|
||||
[ObservableProperty]
|
||||
protected VideoStream _selectedStream;
|
||||
|
||||
[ObservableProperty]
|
||||
protected MediaType _mediaType;
|
||||
|
||||
[ObservableProperty]
|
||||
protected TimeSpan _trimStart;
|
||||
|
||||
[ObservableProperty]
|
||||
protected TimeSpan _trimEnd;
|
||||
|
||||
[ObservableProperty]
|
||||
protected string _directoryPath;
|
||||
|
||||
[ObservableProperty]
|
||||
protected string _filename;
|
||||
|
||||
[ObservableProperty]
|
||||
protected VideoExtension _videoExtension;
|
||||
|
||||
[ObservableProperty]
|
||||
protected AudioExtension _audioExtension;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public VideoViewModel(Video video, ISettingsService settingsService, IStoragePickerService storagePickerService)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
_storagePickerService = storagePickerService;
|
||||
|
||||
ThumbnailUrl = video.ThumbnailUrl;
|
||||
Title = video.Title;
|
||||
Author = video.Author;
|
||||
PublishDate = video.PublishDate;
|
||||
Duration = video.Duration;
|
||||
Views = video.Views;
|
||||
|
||||
Streams = [.. video.Streams];
|
||||
SelectedStream = Streams[0];
|
||||
MediaType = _settingsService.Data.Common.Tasks.DefaultMediaType;
|
||||
TrimStart = TimeSpan.Zero;
|
||||
TrimEnd = Duration;
|
||||
DirectoryPath = _settingsService.Data.Common.Tasks.DefaultOutputDirectory;
|
||||
Filename = Title.Length > 50 ? Title.Substring(0, 50) : Title;
|
||||
VideoExtension = _settingsService.Data.Common.Tasks.DefaultVideoExtension;
|
||||
AudioExtension = _settingsService.Data.Common.Tasks.DefaultAudioExtension;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region COMMANDS
|
||||
|
||||
[RelayCommand]
|
||||
public async Task Browse()
|
||||
{
|
||||
string? newDirectory = await _storagePickerService.OpenDirectory();
|
||||
if (newDirectory is not null)
|
||||
{
|
||||
this.DirectoryPath = newDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Core.Tasks;
|
||||
using VDownload.Core.ViewModels.Home.Helpers;
|
||||
using VDownload.Models;
|
||||
using VDownload.Services.Data.Settings;
|
||||
using VDownload.Services.UI.StoragePicker;
|
||||
using VDownload.Sources.Twitch.Configuration.Models;
|
||||
|
||||
namespace VDownload.Core.ViewModels.Home
|
||||
@@ -14,7 +19,10 @@ namespace VDownload.Core.ViewModels.Home
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly IDownloadTaskManager _tasksManager;
|
||||
|
||||
protected readonly ISettingsService _settingsService;
|
||||
protected readonly IStoragePickerService _storagePickerService;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -22,7 +30,7 @@ namespace VDownload.Core.ViewModels.Home
|
||||
|
||||
#region FIELDS
|
||||
|
||||
|
||||
protected Playlist _playlist;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -33,14 +41,22 @@ namespace VDownload.Core.ViewModels.Home
|
||||
[ObservableProperty]
|
||||
protected string _name;
|
||||
|
||||
[ObservableProperty]
|
||||
protected ObservableCollection<VideoViewModel> _videos;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public HomePlaylistViewModel()
|
||||
{
|
||||
public HomePlaylistViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService)
|
||||
{
|
||||
_tasksManager = tasksManager;
|
||||
_settingsService = settingsService;
|
||||
_storagePickerService = storagePickerService;
|
||||
|
||||
_videos = new ObservableCollection<VideoViewModel>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -51,7 +67,15 @@ namespace VDownload.Core.ViewModels.Home
|
||||
|
||||
public async Task LoadPlaylist(Playlist playlist)
|
||||
{
|
||||
Name = playlist.Name;
|
||||
_playlist = playlist;
|
||||
|
||||
Videos.Clear();
|
||||
|
||||
Name = _playlist.Name;
|
||||
foreach (Video video in playlist)
|
||||
{
|
||||
Videos.Add(new VideoViewModel(video, _settingsService, _storagePickerService));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user