diff --git a/VDownload.Core/EventArgs/PlaylistAddEventArgs.cs b/VDownload.Core/EventArgs/PlaylistAddEventArgs.cs new file mode 100644 index 0000000..cbe6648 --- /dev/null +++ b/VDownload.Core/EventArgs/PlaylistAddEventArgs.cs @@ -0,0 +1,23 @@ +using System; +using VDownload.Core.Enums; +using VDownload.Core.Interfaces; +using VDownload.Core.Objects; +using Windows.Storage; + +namespace VDownload.Core.EventArgs +{ + public class PlaylistAddEventArgs : System.EventArgs + { + public ( + IVideoService VideoService, + MediaType MediaType, + IBaseStream Stream, + TimeSpan TrimStart, + TimeSpan TrimEnd, + string Filename, + MediaFileExtension Extension, + StorageFolder Location, + double Schedule + )[] Videos { get; set; } + } +} diff --git a/VDownload.Core/Interfaces/IPlaylistService.cs b/VDownload.Core/Interfaces/IPlaylistService.cs index 57bfe7b..5793aaa 100644 --- a/VDownload.Core/Interfaces/IPlaylistService.cs +++ b/VDownload.Core/Interfaces/IPlaylistService.cs @@ -1,4 +1,5 @@ -using System.Threading; +using System; +using System.Threading; using System.Threading.Tasks; namespace VDownload.Core.Interfaces @@ -9,7 +10,9 @@ namespace VDownload.Core.Interfaces // PLAYLIST PROPERTIES string ID { get; } + Uri PlaylistUrl { get; } string Name { get; } + IVideoService[] Videos { get; } #endregion diff --git a/VDownload.Core/Services/Sources/Twitch/Channel.cs b/VDownload.Core/Services/Sources/Twitch/Channel.cs index 0c85327..4b39606 100644 --- a/VDownload.Core/Services/Sources/Twitch/Channel.cs +++ b/VDownload.Core/Services/Sources/Twitch/Channel.cs @@ -28,8 +28,9 @@ namespace VDownload.Core.Services.Sources.Twitch #region PROPERTIES public string ID { get; private set; } + public Uri PlaylistUrl { get; private set; } public string Name { get; private set; } - public Vod[] Videos { get; private set; } + public IVideoService[] Videos { get; private set; } #endregion @@ -60,6 +61,9 @@ namespace VDownload.Core.Services.Sources.Twitch cancellationToken.ThrowIfCancellationRequested(); JToken response = JObject.Parse(await client.DownloadStringTaskAsync("https://api.twitch.tv/helix/users"))["data"][0]; + // Create unified playlist url + PlaylistUrl = new Uri($"https://twitch.tv/{ID}"); + // Set parameters if (!ID.All(char.IsDigit)) ID = (string)response["id"]; Name = (string)response["display_name"]; @@ -79,6 +83,9 @@ namespace VDownload.Core.Services.Sources.Twitch // Set array of videos List videos = new List(); + // Get all + bool getAll = numberOfVideos == 0; + // Get videos int count; JToken[] videosData; @@ -96,7 +103,7 @@ namespace VDownload.Core.Services.Sources.Twitch client.Headers.Add("Client-Id", Auth.ClientID); // Set number of videos to get in this iteration - count = numberOfVideos < 100 ? numberOfVideos : 100; + count = numberOfVideos < 100 && !getAll ? numberOfVideos : 100; // Get response client.QueryString.Add("user_id", ID); @@ -119,7 +126,7 @@ namespace VDownload.Core.Services.Sources.Twitch numberOfVideos--; } } - while (numberOfVideos > 0 && count == videosData.Length); + while ((getAll || numberOfVideos > 0) && count == videosData.Length); // Wait for all getStreams tasks await Task.WhenAll(getStreamsTasks); diff --git a/VDownload.Core/VDownload.Core.csproj b/VDownload.Core/VDownload.Core.csproj index 2604852..650fe5e 100644 --- a/VDownload.Core/VDownload.Core.csproj +++ b/VDownload.Core/VDownload.Core.csproj @@ -128,6 +128,7 @@ + diff --git a/VDownload/Assets/Icons/ApplyToAllOptionsDark.svg b/VDownload/Assets/Icons/ApplyToAllOptionsDark.svg new file mode 100644 index 0000000..3ffc448 --- /dev/null +++ b/VDownload/Assets/Icons/ApplyToAllOptionsDark.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/VDownload/Assets/Icons/ApplyToAllOptionsLight.svg b/VDownload/Assets/Icons/ApplyToAllOptionsLight.svg new file mode 100644 index 0000000..cad632c --- /dev/null +++ b/VDownload/Assets/Icons/ApplyToAllOptionsLight.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/VDownload/Assets/Icons/FilterDark.svg b/VDownload/Assets/Icons/FilterDark.svg new file mode 100644 index 0000000..86669a0 --- /dev/null +++ b/VDownload/Assets/Icons/FilterDark.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/VDownload/Assets/Icons/FilterLight.svg b/VDownload/Assets/Icons/FilterLight.svg new file mode 100644 index 0000000..420051c --- /dev/null +++ b/VDownload/Assets/Icons/FilterLight.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/VDownload/Controls/SettingControl.xaml b/VDownload/Controls/SettingControl.xaml index 4d52910..654408b 100644 --- a/VDownload/Controls/SettingControl.xaml +++ b/VDownload/Controls/SettingControl.xaml @@ -27,12 +27,10 @@ - + - - @@ -40,7 +38,7 @@ - + @@ -50,6 +48,6 @@ - + diff --git a/VDownload/Resources/Colors.xaml b/VDownload/Resources/Colors.xaml index 3303643..0fac051 100644 --- a/VDownload/Resources/Colors.xaml +++ b/VDownload/Resources/Colors.xaml @@ -5,10 +5,14 @@ + + - + + + diff --git a/VDownload/Resources/Icons.xaml b/VDownload/Resources/Icons.xaml index a18f053..9e237bd 100644 --- a/VDownload/Resources/Icons.xaml +++ b/VDownload/Resources/Icons.xaml @@ -22,6 +22,8 @@ + + @@ -43,6 +45,8 @@ + + diff --git a/VDownload/Strings/en-US/Resources.resw b/VDownload/Strings/en-US/Resources.resw index 589ac44..3d36421 100644 --- a/VDownload/Strings/en-US/Resources.resw +++ b/VDownload/Strings/en-US/Resources.resw @@ -211,6 +211,93 @@ The number in the numberbox indicades how many videos will be got from playlist. There is a problem with linked Twitch account. Check Twitch login status in Sources page. + + Apply + + + Browse + + + Location + + + Number of minutes to start the task (after clicking downloading button). + + + Schedule + + + Apply to all options + + + Author + + + Enter regular expression + + + Date + + + Duration + + + Apply + + + Hidden + + + Filter + + + Restore + + + Removed + + + Title + + + Enter regular expression + + + Views + + + Downloading options + + + File options + + + File + + + Browse + + + Location + + + Media type + + + Quality + + + Number of minutes to start the task (after clicking downloading button). + + + Schedule + + + Task options + + + Trim + Cancelled diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index 9206e34..d288260 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -137,6 +137,12 @@ HomeMain.xaml + + HomePlaylistAddingPanel.xaml + + + HomePlaylistAddingPanelVideoPanel.xaml + HomeTasksListPlaceholder.xaml @@ -165,6 +171,8 @@ + + @@ -174,6 +182,8 @@ + + @@ -301,6 +311,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/VDownload/Views/Home/HomeMain.xaml.cs b/VDownload/Views/Home/HomeMain.xaml.cs index 8e0b1e4..56ba3b6 100644 --- a/VDownload/Views/Home/HomeMain.xaml.cs +++ b/VDownload/Views/Home/HomeMain.xaml.cs @@ -45,7 +45,7 @@ namespace VDownload.Views.Home private readonly HomeTasksListPlaceholder HomeTasksListPlaceholder = new HomeTasksListPlaceholder(); // HOME VIDEOS LIST - private static ContentControl HomeTasksListPlaceCurrent = null; + private static ContentControl HomeTasksListPlaceCurrent { get; set; } private static StackPanel HomeTasksList = null; public static List TaskPanelsList = new List(); @@ -56,7 +56,7 @@ namespace VDownload.Views.Home #region EVENT HANDLERS VOIDS // ON NAVIGATED TO - protected override async void OnNavigatedTo(NavigationEventArgs e) + protected override void OnNavigatedTo(NavigationEventArgs e) { HomeTasksListPlaceCurrent = HomeTasksListPlace; if (HomeTasksList != null) HomeTasksList.Children.Clear(); @@ -64,11 +64,11 @@ namespace VDownload.Views.Home if (TaskPanelsList.Count > 0) { foreach (HomeTaskPanel homeVideoPanel in TaskPanelsList) HomeTasksList.Children.Add(homeVideoPanel); - HomeTasksListPlace.Content = HomeTasksList; + HomeTasksListPlaceCurrent.Content = HomeTasksList; } else { - HomeTasksListPlace.Content = HomeTasksListPlaceholder; + HomeTasksListPlaceCurrent.Content = HomeTasksListPlaceholder; } } @@ -87,9 +87,9 @@ namespace VDownload.Views.Home // ADD VIDEO SEARCH BUTTON CLICKED private async void HomeOptionsBarAddVideoControl_SearchButtonClicked(object sender, VideoSearchEventArgs e) { + // Set UI HomeOptionBarAndAddingPanelRow.Height = GridLength.Auto; HomeTasksListRow.Height = new GridLength(1, GridUnitType.Star); - HomeAddingPanel.Content = null; // Cancel previous operations @@ -172,19 +172,21 @@ namespace VDownload.Views.Home // Set searching status control to done (null) HomeOptionsBarSearchingStatusControl.Content = null; - + // Set UI HomeOptionBarAndAddingPanelRow.Height = new GridLength(1, GridUnitType.Star); HomeTasksListRow.Height = new GridLength(0); + HomeVideoAddingPanel addingPanel = new HomeVideoAddingPanel(videoService); addingPanel.VideoAddRequest += HomeVideoAddingPanel_VideoAddRequest; HomeAddingPanel.Content = addingPanel; } } + // ADD VIDEO REQUEST FROM VIDEO ADDING PANEL private void HomeVideoAddingPanel_VideoAddRequest(object sender, VideoAddEventArgs e) { // Replace placeholder - HomeTasksListPlace.Content = HomeTasksList; + HomeTasksListPlaceCurrent.Content = HomeTasksList; // Uncheck video button HomeOptionsBarAddVideoButton.IsChecked = false; @@ -197,7 +199,7 @@ namespace VDownload.Views.Home // Remove task from tasks lists TaskPanelsList.Remove(taskPanel); HomeTasksList.Children.Remove(taskPanel); - if (TaskPanelsList.Count <= 0) HomeTasksListPlace.Content = HomeTasksListPlaceholder; + if (TaskPanelsList.Count <= 0) HomeTasksListPlaceCurrent.Content = HomeTasksListPlaceholder; }; // Add task to tasks lists @@ -221,8 +223,14 @@ namespace VDownload.Views.Home // ADD PLAYLIST SEARCH BUTTON CLICKED private async void HomeOptionsBarAddPlaylistControl_SearchButtonClicked(object sender, PlaylistSearchEventArgs e) { + // Set UI + HomeOptionBarAndAddingPanelRow.Height = GridLength.Auto; + HomeTasksListRow.Height = new GridLength(1, GridUnitType.Star); + HomeAddingPanel.Content = null; + // Cancel previous operations SearchingCancellationToken.Cancel(); + SearchingCancellationToken = new CancellationTokenSource(); // Set SearchingStatusControl HomeOptionsBarSearchingStatusControl.Content = HomeOptionsBarSearchingStatusProgressRing; @@ -295,6 +303,45 @@ namespace VDownload.Views.Home } else throw; } + + // Set searching status control to done (null) + HomeOptionsBarSearchingStatusControl.Content = null; + + // Set UI + HomeOptionBarAndAddingPanelRow.Height = new GridLength(1, GridUnitType.Star); + HomeTasksListRow.Height = new GridLength(0); + + HomePlaylistAddingPanel addingPanel = new HomePlaylistAddingPanel(playlistService); + addingPanel.PlaylistAddRequest += HomeVideoAddingPanel_PlayListAddRequest; + HomeAddingPanel.Content = addingPanel; + } + } + + // ADD PLAYLIST REQUEST FROM PLAYLIST ADDING PANEL + private void HomeVideoAddingPanel_PlayListAddRequest(object sender, PlaylistAddEventArgs e) + { + // Replace placeholder + HomeTasksListPlaceCurrent.Content = HomeTasksList; + + // Uncheck video button + HomeOptionsBarAddPlaylistButton.IsChecked = false; + + // Create video tasks + foreach (var video in e.Videos) + { + HomeTaskPanel taskPanel = new HomeTaskPanel(video.VideoService, video.MediaType, video.Stream, video.TrimStart, video.TrimEnd, video.Filename, video.Extension, video.Location, video.Schedule); + + taskPanel.TaskRemovingRequested += (s, a) => + { + // Remove task from tasks lists + TaskPanelsList.Remove(taskPanel); + HomeTasksList.Children.Remove(taskPanel); + if (TaskPanelsList.Count <= 0) HomeTasksListPlaceCurrent.Content = HomeTasksListPlaceholder; + }; + + // Add task to tasks lists + HomeTasksList.Children.Add(taskPanel); + TaskPanelsList.Add(taskPanel); } } @@ -340,7 +387,10 @@ namespace VDownload.Views.Home foreach (HomeTaskPanel videoPanel in idleTasks) { await Task.Delay(50); + + #pragma warning disable CS4014 videoPanel.Start(delay); + #pragma warning restore CS4014 } } } diff --git a/VDownload/Views/Home/HomePlaylistAddingPanel.xaml b/VDownload/Views/Home/HomePlaylistAddingPanel.xaml new file mode 100644 index 0000000..98d009d --- /dev/null +++ b/VDownload/Views/Home/HomePlaylistAddingPanel.xaml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +