From e23258a6387cd75d835e03b3a2418e2ce044f635 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Thu, 5 May 2022 15:06:10 +0200 Subject: [PATCH] 1.0-dev17 (Subscription page created) --- .../PlaylistSearchSuccessedEventArgs.cs | 2 +- .../VideoSearchSuccessedEventArgs.cs | 2 +- .../Exceptions/MediaNotFoundException.cs | 4 - VDownload.Core/Interfaces/IPlaylistService.cs | 31 --- VDownload.Core/Interfaces/IVideoService.cs | 47 ----- VDownload.Core/Services/Config.cs | 2 +- VDownload.Core/Services/Source.cs | 54 ----- .../Services/Sources/Twitch/Channel.cs | 18 +- .../Services/Sources/Twitch/Clip.cs | 9 +- .../Services/Sources/Twitch/Helpers/Auth.cs | 22 +- .../Services/Sources/Twitch/Helpers/Client.cs | 8 +- VDownload.Core/Services/Sources/Twitch/Vod.cs | 9 +- VDownload.Core/Services/TaskId.cs | 2 +- .../Services/TimeSpanCustomFormat.cs | 2 +- VDownload.Core/Structs/BaseStream.cs | 1 + VDownload.Core/Structs/Metadata.cs | 1 + VDownload.Core/Structs/TaskData.cs | 2 +- VDownload.Core/VDownload.Core.csproj | 10 +- VDownload/Resources/Colors.xaml | 4 + VDownload/Strings/en-US/Resources.resw | 52 +++-- VDownload/VDownload.csproj | 24 ++- .../Controls/HomeAddingVideoOptions.xaml.cs | 4 +- .../HomeOptionsBarPlaylistSearch.xaml.cs | 16 +- .../HomeOptionsBarVideoSearch.xaml.cs | 15 +- .../HomeSerialAddingVideoPanel.xaml.cs | 6 +- .../Views/Home/Controls/HomeTaskPanel.xaml.cs | 2 +- VDownload/Views/Home/HomeMain.xaml.cs | 2 +- .../Home/HomePlaylistAddingPanel.xaml.cs | 8 +- .../Views/Home/HomeVideoAddingPanel.xaml.cs | 6 +- VDownload/Views/MainPage.xaml.cs | 4 +- VDownload/Views/Sources/SourcesMain.xaml | 36 ---- VDownload/Views/Sources/SourcesMain.xaml.cs | 199 ------------------ .../Subscriptions/SubscriptionsMain.xaml | 18 -- .../Subscriptions/SubscriptionsMain.xaml.cs | 25 --- 34 files changed, 121 insertions(+), 526 deletions(-) delete mode 100644 VDownload.Core/Interfaces/IPlaylistService.cs delete mode 100644 VDownload.Core/Interfaces/IVideoService.cs delete mode 100644 VDownload.Core/Services/Source.cs delete mode 100644 VDownload/Views/Sources/SourcesMain.xaml delete mode 100644 VDownload/Views/Sources/SourcesMain.xaml.cs delete mode 100644 VDownload/Views/Subscriptions/SubscriptionsMain.xaml delete mode 100644 VDownload/Views/Subscriptions/SubscriptionsMain.xaml.cs diff --git a/VDownload.Core/EventArgs/PlaylistSearchSuccessedEventArgs.cs b/VDownload.Core/EventArgs/PlaylistSearchSuccessedEventArgs.cs index 7e7c3ad..8fb7175 100644 --- a/VDownload.Core/EventArgs/PlaylistSearchSuccessedEventArgs.cs +++ b/VDownload.Core/EventArgs/PlaylistSearchSuccessedEventArgs.cs @@ -4,6 +4,6 @@ namespace VDownload.Core.EventArgs { public class PlaylistSearchSuccessedEventArgs : System.EventArgs { - public IPlaylistService PlaylistService { get; set; } + public IPlaylist PlaylistService { get; set; } } } diff --git a/VDownload.Core/EventArgs/VideoSearchSuccessedEventArgs.cs b/VDownload.Core/EventArgs/VideoSearchSuccessedEventArgs.cs index 1a9d81f..bd1bb9a 100644 --- a/VDownload.Core/EventArgs/VideoSearchSuccessedEventArgs.cs +++ b/VDownload.Core/EventArgs/VideoSearchSuccessedEventArgs.cs @@ -4,6 +4,6 @@ namespace VDownload.Core.EventArgs { public class VideoSearchSuccessedEventArgs : System.EventArgs { - public IVideoService VideoService { get; set; } + public IVideo Video { get; set; } } } diff --git a/VDownload.Core/Exceptions/MediaNotFoundException.cs b/VDownload.Core/Exceptions/MediaNotFoundException.cs index 466a69b..fe93561 100644 --- a/VDownload.Core/Exceptions/MediaNotFoundException.cs +++ b/VDownload.Core/Exceptions/MediaNotFoundException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace VDownload.Core.Exceptions { diff --git a/VDownload.Core/Interfaces/IPlaylistService.cs b/VDownload.Core/Interfaces/IPlaylistService.cs deleted file mode 100644 index 5793aaa..0000000 --- a/VDownload.Core/Interfaces/IPlaylistService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace VDownload.Core.Interfaces -{ - public interface IPlaylistService - { - #region PROPERTIES - - // PLAYLIST PROPERTIES - string ID { get; } - Uri PlaylistUrl { get; } - string Name { get; } - IVideoService[] Videos { get; } - - #endregion - - - - #region METHODS - - // GET PLAYLIST METADATA - Task GetMetadataAsync(CancellationToken cancellationToken = default); - - // GET VIDEOS FROM PLAYLIST - Task GetVideosAsync(int numberOfVideos, CancellationToken cancellationToken = default); - - #endregion - } -} diff --git a/VDownload.Core/Interfaces/IVideoService.cs b/VDownload.Core/Interfaces/IVideoService.cs deleted file mode 100644 index 7ad0db4..0000000 --- a/VDownload.Core/Interfaces/IVideoService.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.ComponentModel; -using System.Threading; -using System.Threading.Tasks; -using VDownload.Core.Enums; -using VDownload.Core.Structs; -using Windows.Storage; - -namespace VDownload.Core.Interfaces -{ - public interface IVideoService - { - #region PROPERTIES - - // VIDEO PROPERTIES - string ID { get; } - Uri VideoUrl { get; } - Metadata Metadata { get; } - BaseStream[] BaseStreams { get; } - - #endregion - - - - #region METHODS - - // GET VIDEO METADATA - Task GetMetadataAsync(CancellationToken cancellationToken = default); - - // GET VIDEO STREAMS - Task GetStreamsAsync(CancellationToken cancellationToken = default); - - // DOWNLOAD VIDEO - Task DownloadAndTranscodeAsync(StorageFolder downloadingFolder, BaseStream baseStream, MediaFileExtension extension, MediaType mediaType, TimeSpan trimStart, TimeSpan trimEnd, CancellationToken cancellationToken = default); - - #endregion - - - - #region EVENT HANDLERS - - event EventHandler DownloadingProgressChanged; - event EventHandler ProcessingProgressChanged; - - #endregion - } -} diff --git a/VDownload.Core/Services/Config.cs b/VDownload.Core/Services/Config.cs index 23201d3..ab1fb61 100644 --- a/VDownload.Core/Services/Config.cs +++ b/VDownload.Core/Services/Config.cs @@ -6,7 +6,7 @@ using Windows.Storage; namespace VDownload.Core.Services { - public class Config + public static class Config { #region CONSTANTS diff --git a/VDownload.Core/Services/Source.cs b/VDownload.Core/Services/Source.cs deleted file mode 100644 index 4c3f217..0000000 --- a/VDownload.Core/Services/Source.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Text.RegularExpressions; -using VDownload.Core.Enums; - -namespace VDownload.Core.Services -{ - public class Source - { - #region CONSTANTS - - // VIDEO SOURCES REGULAR EXPRESSIONS - private static readonly (Regex Regex, VideoSource Type)[] VideoSources = new (Regex Regex, VideoSource Type)[] - { - (new Regex(@"^https://www.twitch.tv/videos/(?\d+)"), VideoSource.TwitchVod), - (new Regex(@"^https://www.twitch.tv/\S+/clip/(?[^?]+)"), VideoSource.TwitchClip), - (new Regex(@"^https://clips.twitch.tv/(?[^?]+)"), VideoSource.TwitchClip), - }; - - // PLAYLIST SOURCES REGULAR EXPRESSIONS - private static readonly (Regex Regex, PlaylistSource Type)[] PlaylistSources = new (Regex Regex, PlaylistSource Type)[] - { - (new Regex(@"^https://www.twitch.tv/(?[^?/]+)"), PlaylistSource.TwitchChannel), - }; - - #endregion - - - - #region METHODS - - // GET VIDEO SOURCE - public static (VideoSource Type, string ID) GetVideoSource(string url) - { - foreach ((Regex Regex, VideoSource Type) Source in VideoSources) - { - Match sourceMatch = Source.Regex.Match(url); - if (sourceMatch.Success) return (Source.Type, sourceMatch.Groups["id"].Value); - } - return (VideoSource.Null, null); - } - - // GET PLAYLIST SOURCE - public static (PlaylistSource Type, string ID) GetPlaylistSource(string url) - { - foreach ((Regex Regex, PlaylistSource Type) Source in PlaylistSources) - { - Match sourceMatch = Source.Regex.Match(url); - if (sourceMatch.Success) return (Source.Type, sourceMatch.Groups["id"].Value); - } - return (PlaylistSource.Null, null); - } - - #endregion - } -} diff --git a/VDownload.Core/Services/Sources/Twitch/Channel.cs b/VDownload.Core/Services/Sources/Twitch/Channel.cs index 5a7aa28..95a2f0d 100644 --- a/VDownload.Core/Services/Sources/Twitch/Channel.cs +++ b/VDownload.Core/Services/Sources/Twitch/Channel.cs @@ -7,19 +7,22 @@ using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; +using VDownload.Core.Enums; using VDownload.Core.Exceptions; using VDownload.Core.Interfaces; using VDownload.Core.Services.Sources.Twitch.Helpers; namespace VDownload.Core.Services.Sources.Twitch { - public class Channel : IPlaylistService + [Serializable] + public class Channel : IPlaylist { #region CONSTRUCTORS public Channel(string id) { ID = id; + Source = PlaylistSource.TwitchChannel; } #endregion @@ -29,9 +32,11 @@ namespace VDownload.Core.Services.Sources.Twitch #region PROPERTIES public string ID { get; private set; } - public Uri PlaylistUrl { get; private set; } + public PlaylistSource Source { get; private set; } + public Uri Url { get; private set; } public string Name { get; private set; } - public IVideoService[] Videos { get; private set; } + public IVideo[] Videos { get; private set; } + private string UniqueUserID { get; set; } #endregion @@ -55,14 +60,15 @@ namespace VDownload.Core.Services.Sources.Twitch } // Create unified playlist url - PlaylistUrl = new Uri($"https://twitch.tv/{ID}"); + Url = new Uri($"https://twitch.tv/{ID}"); // Set parameters - if (!ID.All(char.IsDigit)) ID = (string)response["id"]; + UniqueUserID = (string)response["id"]; Name = (string)response["display_name"]; } // GET CHANNEL VIDEOS + public async Task GetVideosAsync(CancellationToken cancellationToken = default) => await GetVideosAsync(0, cancellationToken); public async Task GetVideosAsync(int numberOfVideos, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); @@ -89,7 +95,7 @@ namespace VDownload.Core.Services.Sources.Twitch JToken response = null; using (WebClient client = await Client.Helix()) { - client.QueryString.Add("user_id", ID); + client.QueryString.Add("user_id", UniqueUserID); client.QueryString.Add("first", count.ToString()); client.QueryString.Add("after", pagination); response = JObject.Parse(await client.DownloadStringTaskAsync("https://api.twitch.tv/helix/videos")); diff --git a/VDownload.Core/Services/Sources/Twitch/Clip.cs b/VDownload.Core/Services/Sources/Twitch/Clip.cs index e8db616..9539074 100644 --- a/VDownload.Core/Services/Sources/Twitch/Clip.cs +++ b/VDownload.Core/Services/Sources/Twitch/Clip.cs @@ -18,13 +18,15 @@ using Windows.Storage; namespace VDownload.Core.Services.Sources.Twitch { - public class Clip : IVideoService + [Serializable] + public class Clip : IVideo { #region CONSTRUCTORS public Clip(string id) { ID = id; + Source = VideoSource.TwitchClip; } #endregion @@ -33,8 +35,9 @@ namespace VDownload.Core.Services.Sources.Twitch #region PROPERTIES + public VideoSource Source { get; private set; } public string ID { get; private set; } - public Uri VideoUrl { get; private set; } + public Uri Url { get; private set; } public Metadata Metadata { get; private set; } public BaseStream[] BaseStreams { get; private set; } @@ -60,7 +63,7 @@ namespace VDownload.Core.Services.Sources.Twitch } // Create unified video url - VideoUrl = new Uri($"https://clips.twitch.tv/{ID}"); + Url = new Uri($"https://clips.twitch.tv/{ID}"); // Set metadata Metadata = new Metadata() diff --git a/VDownload.Core/Services/Sources/Twitch/Helpers/Auth.cs b/VDownload.Core/Services/Sources/Twitch/Helpers/Auth.cs index e545d4e..1ea85fa 100644 --- a/VDownload.Core/Services/Sources/Twitch/Helpers/Auth.cs +++ b/VDownload.Core/Services/Sources/Twitch/Helpers/Auth.cs @@ -8,17 +8,12 @@ using Windows.Storage; namespace VDownload.Core.Services.Sources.Twitch.Helpers { - public class Auth + public static class Auth { #region CONSTANTS - // CLIENT ID public readonly static string ClientID = "yukkqkwp61wsv3u1pya17crpyaa98y"; - - // GQL API CLIENT ID public readonly static string GQLApiClientID = "kimne78kx3ncx6brgo4mv6wki5h1ko"; - - // REDIRECT URL public readonly static Uri RedirectUrl = new Uri("https://www.vd.com"); // AUTHORIZATION URL @@ -35,16 +30,13 @@ namespace VDownload.Core.Services.Sources.Twitch.Helpers #region METHODS - // READ ACCESS TOKEN public static async Task ReadAccessTokenAsync() { try { - // Get file StorageFolder authDataFolder = await ApplicationData.Current.LocalCacheFolder.GetFolderAsync("AuthData"); StorageFile authDataFile = await authDataFolder.GetFileAsync("Twitch.auth"); - // Return data return await FileIO.ReadTextAsync(authDataFile); } catch (FileNotFoundException) @@ -53,42 +45,33 @@ namespace VDownload.Core.Services.Sources.Twitch.Helpers } } - // SAVE ACCESS TOKEN public static async Task SaveAccessTokenAsync(string accessToken) { - // Get file StorageFolder authDataFolder = await ApplicationData.Current.LocalCacheFolder.CreateFolderAsync("AuthData", CreationCollisionOption.OpenIfExists); StorageFile authDataFile = await authDataFolder.CreateFileAsync("Twitch.auth", CreationCollisionOption.ReplaceExisting); - // Save data await FileIO.WriteTextAsync(authDataFile, accessToken); } - // DELETE ACCESS TOKEN public static async Task DeleteAccessTokenAsync() { try { - // Get file StorageFolder authDataFolder = await ApplicationData.Current.LocalCacheFolder.GetFolderAsync("AuthData"); StorageFile authDataFile = await authDataFolder.GetFileAsync("Twitch.auth"); - // Delete file await authDataFile.DeleteAsync(); } catch (FileNotFoundException) { } } - // VALIDATE ACCESS TOKEN public static async Task<(bool IsValid, string Login, DateTime? ExpirationDate)> ValidateAccessTokenAsync(string accessToken) { - // Create client WebClient client = new WebClient { Encoding = Encoding.UTF8 }; client.Headers.Add("Authorization", $"Bearer {accessToken}"); try { - // Check access token JObject response = JObject.Parse(await client.DownloadStringTaskAsync("https://id.twitch.tv/oauth2/validate")); string login = response["login"].ToString(); @@ -108,13 +91,10 @@ namespace VDownload.Core.Services.Sources.Twitch.Helpers } } - // REVOKE ACCESS TOKEN public static async Task RevokeAccessTokenAsync(string accessToken) { - // Create client WebClient client = new WebClient { Encoding = Encoding.UTF8 }; - // Revoke access token await client.UploadStringTaskAsync(new Uri("https://id.twitch.tv/oauth2/revoke"), $"client_id={ClientID}&token={accessToken}"); } diff --git a/VDownload.Core/Services/Sources/Twitch/Helpers/Client.cs b/VDownload.Core/Services/Sources/Twitch/Helpers/Client.cs index 4bd2e99..e93e5bd 100644 --- a/VDownload.Core/Services/Sources/Twitch/Helpers/Client.cs +++ b/VDownload.Core/Services/Sources/Twitch/Helpers/Client.cs @@ -4,34 +4,28 @@ using VDownload.Core.Exceptions; namespace VDownload.Core.Services.Sources.Twitch.Helpers { - internal class Client + internal static class Client { internal static async Task Helix() { - // Get access token string accessToken = await Auth.ReadAccessTokenAsync(); if (accessToken == null) throw new TwitchAccessTokenNotFoundException(); - // Check access token var twitchAccessTokenValidation = await Auth.ValidateAccessTokenAsync(accessToken); if (!twitchAccessTokenValidation.IsValid) throw new TwitchAccessTokenNotValidException(); - // Create client WebClient client = new WebClient(); client.Headers.Add("Authorization", $"Bearer {accessToken}"); client.Headers.Add("Client-Id", Auth.ClientID); - // Return client return client; } internal static WebClient GQL() { - // Create client WebClient client = new WebClient(); client.Headers.Add("Client-Id", Auth.GQLApiClientID); - // Return client return client; } } diff --git a/VDownload.Core/Services/Sources/Twitch/Vod.cs b/VDownload.Core/Services/Sources/Twitch/Vod.cs index 965734d..347e1ca 100644 --- a/VDownload.Core/Services/Sources/Twitch/Vod.cs +++ b/VDownload.Core/Services/Sources/Twitch/Vod.cs @@ -17,13 +17,15 @@ using Windows.Storage; namespace VDownload.Core.Services.Sources.Twitch { - public class Vod : IVideoService + [Serializable] + public class Vod : IVideo { #region CONSTRUCTORS public Vod(string id) { ID = id; + Source = VideoSource.TwitchVod; } #endregion @@ -32,8 +34,9 @@ namespace VDownload.Core.Services.Sources.Twitch #region PROPERTIES + public VideoSource Source { get; private set; } public string ID { get; private set; } - public Uri VideoUrl { get; private set; } + public Uri Url { get; private set; } public Metadata Metadata { get; private set; } public BaseStream[] BaseStreams { get; private set; } @@ -72,7 +75,7 @@ namespace VDownload.Core.Services.Sources.Twitch internal void GetMetadataAsync(JToken response) { // Create unified video url - VideoUrl = new Uri($"https://www.twitch.tv/videos/{ID}"); + Url = new Uri($"https://www.twitch.tv/videos/{ID}"); // Set metadata Metadata = new Metadata() diff --git a/VDownload.Core/Services/TaskId.cs b/VDownload.Core/Services/TaskId.cs index 6707ffa..38e0267 100644 --- a/VDownload.Core/Services/TaskId.cs +++ b/VDownload.Core/Services/TaskId.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace VDownload.Core.Services { - public class TaskId + public static class TaskId { #region CONSTANTS diff --git a/VDownload.Core/Services/TimeSpanCustomFormat.cs b/VDownload.Core/Services/TimeSpanCustomFormat.cs index dfdda2b..85dad19 100644 --- a/VDownload.Core/Services/TimeSpanCustomFormat.cs +++ b/VDownload.Core/Services/TimeSpanCustomFormat.cs @@ -4,7 +4,7 @@ using System.Linq; namespace VDownload.Core.Services { - public class TimeSpanCustomFormat + public static class TimeSpanCustomFormat { // (TH:)MM:SS public static string ToOptTHBaseMMSS(TimeSpan timeSpan, params TimeSpan[] formatBase) diff --git a/VDownload.Core/Structs/BaseStream.cs b/VDownload.Core/Structs/BaseStream.cs index d728710..879811d 100644 --- a/VDownload.Core/Structs/BaseStream.cs +++ b/VDownload.Core/Structs/BaseStream.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; namespace VDownload.Core.Structs { + [Serializable] public struct BaseStream { public Uri Url { get; set; } diff --git a/VDownload.Core/Structs/Metadata.cs b/VDownload.Core/Structs/Metadata.cs index 071c0e5..bc81de4 100644 --- a/VDownload.Core/Structs/Metadata.cs +++ b/VDownload.Core/Structs/Metadata.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; namespace VDownload.Core.Structs { + [Serializable] public struct Metadata { public string Title { get; set; } diff --git a/VDownload.Core/Structs/TaskData.cs b/VDownload.Core/Structs/TaskData.cs index 6598122..a3da46d 100644 --- a/VDownload.Core/Structs/TaskData.cs +++ b/VDownload.Core/Structs/TaskData.cs @@ -7,7 +7,7 @@ namespace VDownload.Core.Structs { public struct TaskData { - public IVideoService VideoService { get; set; } + public IVideo VideoService { get; set; } public TaskOptions TaskOptions { get; set; } } } diff --git a/VDownload.Core/VDownload.Core.csproj b/VDownload.Core/VDownload.Core.csproj index ed1813b..b3afa2d 100644 --- a/VDownload.Core/VDownload.Core.csproj +++ b/VDownload.Core/VDownload.Core.csproj @@ -124,6 +124,7 @@ + @@ -133,18 +134,21 @@ + - - + + + + - + diff --git a/VDownload/Resources/Colors.xaml b/VDownload/Resources/Colors.xaml index 0fac051..8243534 100644 --- a/VDownload/Resources/Colors.xaml +++ b/VDownload/Resources/Colors.xaml @@ -7,12 +7,16 @@ + + + + diff --git a/VDownload/Strings/en-US/Resources.resw b/VDownload/Strings/en-US/Resources.resw index cab8f20..aab47f9 100644 --- a/VDownload/Strings/en-US/Resources.resw +++ b/VDownload/Strings/en-US/Resources.resw @@ -406,18 +406,6 @@ The number in the numberbox indicades how many videos will be got from playlist. Video downloading ended unsuccessfully - - Sources - - - Loading... - - - Log out - - - Sign in - Unable to connect to Twitch servers. Check your internet connection. @@ -427,21 +415,51 @@ The number in the numberbox indicades how many videos will be got from playlist. Login to Twitch failed - + + Sources + + Loading... - + Twitch - + + Your Twitch access token has expired. Please sign in. + + Unable to connect to Twitch servers. Check your internet connection. - + Logged in as - + Not logged in. Twitch authentication is required to download videos. + + Loading... + + + Log out + + + Sign in + + + Add + + + Playlist URL + + + Subscriptions + + + Loading... + + + Syncing... + Internet connection error diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index 3abd77d..c2e64f1 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -158,14 +158,17 @@ MainPage.xaml - - SourcesMain.xaml + + MainPage.xaml SettingsMain.xaml - - SubscriptionsMain.xaml + + SubscriptionPanel.xaml + + + MainPage.xaml @@ -342,7 +345,7 @@ MSBuild:Compile Designer - + Designer MSBuild:Compile @@ -350,7 +353,11 @@ Designer MSBuild:Compile - + + Designer + MSBuild:Compile + + Designer MSBuild:Compile @@ -369,7 +376,7 @@ 7.1.2 - 2.8.0-prerelease.220118001 + 2.8.0-prerelease.220413001 @@ -384,6 +391,9 @@ + + + 14.0 diff --git a/VDownload/Views/Home/Controls/HomeAddingVideoOptions.xaml.cs b/VDownload/Views/Home/Controls/HomeAddingVideoOptions.xaml.cs index 5a212cb..d7e4566 100644 --- a/VDownload/Views/Home/Controls/HomeAddingVideoOptions.xaml.cs +++ b/VDownload/Views/Home/Controls/HomeAddingVideoOptions.xaml.cs @@ -30,7 +30,7 @@ namespace VDownload.Views.Home.Controls { #region CONSTRUCTORS - public HomeAddingVideoOptions(IVideoService videoService) + public HomeAddingVideoOptions(IVideo videoService) { this.InitializeComponent(); @@ -112,7 +112,7 @@ namespace VDownload.Views.Home.Controls #region PROPERTIES // VIDEO SERVICE - private IVideoService VideoService { get; set; } + private IVideo VideoService { get; set; } // TASK OPTIONS public MediaType MediaType { get; private set; } diff --git a/VDownload/Views/Home/Controls/HomeOptionsBarPlaylistSearch.xaml.cs b/VDownload/Views/Home/Controls/HomeOptionsBarPlaylistSearch.xaml.cs index 69ae127..897eb43 100644 --- a/VDownload/Views/Home/Controls/HomeOptionsBarPlaylistSearch.xaml.cs +++ b/VDownload/Views/Home/Controls/HomeOptionsBarPlaylistSearch.xaml.cs @@ -8,6 +8,7 @@ using VDownload.Core.EventArgs; using VDownload.Core.Exceptions; using VDownload.Core.Interfaces; using VDownload.Core.Services; +using VDownload.Core.Services.Sources; using Windows.ApplicationModel.Resources; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -52,7 +53,7 @@ namespace VDownload.Views.Home - #region EVENT HANDLERS + #region EVENT HANDLERS VOIDS // NUMBERBOX FOCUS LOST private void HomeOptionsBarPlaylistSearchControlMaxVideosNumberBox_LostFocus(object sender, RoutedEventArgs e) @@ -73,22 +74,13 @@ namespace VDownload.Views.Home HomeOptionsBarPlaylistSearchControlStatusControl.Content = HomeOptionsBarPlaylistSearchStatusProgressRing; // Parse url - (PlaylistSource Type, string ID) source = Source.GetPlaylistSource(HomeOptionsBarPlaylistSearchControlUrlTextBox.Text); - - // Check url - if (source.Type == PlaylistSource.Null) + IPlaylist playlistService = Source.GetPlaylist(HomeOptionsBarPlaylistSearchControlUrlTextBox.Text); + if (playlistService == null) { HomeOptionsBarPlaylistSearchControlStatusControl.Content = HomeOptionsBarPlaylistSearchStatusErrorImage; } else { - // Select video service - IPlaylistService playlistService = null; - switch (source.Type) - { - case PlaylistSource.TwitchChannel: playlistService = new Core.Services.Sources.Twitch.Channel(source.ID); break; - } - // Get metadata and streams try { diff --git a/VDownload/Views/Home/Controls/HomeOptionsBarVideoSearch.xaml.cs b/VDownload/Views/Home/Controls/HomeOptionsBarVideoSearch.xaml.cs index c1508fb..f4caa3a 100644 --- a/VDownload/Views/Home/Controls/HomeOptionsBarVideoSearch.xaml.cs +++ b/VDownload/Views/Home/Controls/HomeOptionsBarVideoSearch.xaml.cs @@ -7,6 +7,7 @@ using VDownload.Core.EventArgs; using VDownload.Core.Exceptions; using VDownload.Core.Interfaces; using VDownload.Core.Services; +using VDownload.Core.Services.Sources; using Windows.ApplicationModel.Resources; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -63,23 +64,15 @@ namespace VDownload.Views.Home HomeOptionBarVideoSearchControlStatusControl.Content = HomeOptionsBarVideoSearchStatusProgressRing; // Parse url - (VideoSource Type, string ID) source = Source.GetVideoSource(HomeOptionsBarVideoSearchControlUrlTextBox.Text); + IVideo videoService = Source.GetVideo(HomeOptionsBarVideoSearchControlUrlTextBox.Text); // Check url - if (source.Type == VideoSource.Null) + if (videoService == null) { HomeOptionBarVideoSearchControlStatusControl.Content = HomeOptionsBarVideoSearchStatusErrorImage; } else { - // Select video service - IVideoService videoService = null; - switch (source.Type) - { - case VideoSource.TwitchVod: videoService = new Core.Services.Sources.Twitch.Vod(source.ID); break; - case VideoSource.TwitchClip: videoService = new Core.Services.Sources.Twitch.Clip(source.ID); break; - } - // Get metadata and streams try { @@ -141,7 +134,7 @@ namespace VDownload.Views.Home HomeOptionBarVideoSearchControlStatusControl.Content = null; // Invoke search successed event - VideoSearchSuccessed?.Invoke(this, new VideoSearchSuccessedEventArgs { VideoService = videoService }); + VideoSearchSuccessed?.Invoke(this, new VideoSearchSuccessedEventArgs { Video = videoService }); } } diff --git a/VDownload/Views/Home/Controls/HomeSerialAddingVideoPanel.xaml.cs b/VDownload/Views/Home/Controls/HomeSerialAddingVideoPanel.xaml.cs index dd281d1..e03abb3 100644 --- a/VDownload/Views/Home/Controls/HomeSerialAddingVideoPanel.xaml.cs +++ b/VDownload/Views/Home/Controls/HomeSerialAddingVideoPanel.xaml.cs @@ -23,7 +23,7 @@ namespace VDownload.Views.Home.Controls #region CONSTRUCTORS - public HomeSerialAddingVideoPanel(IVideoService videoService) + public HomeSerialAddingVideoPanel(IVideo videoService) { this.InitializeComponent(); @@ -50,7 +50,7 @@ namespace VDownload.Views.Home.Controls #region PROPERTIES // BASE VIDEO DATA - public IVideoService VideoService { get; set; } + public IVideo VideoService { get; set; } // VIDEO DATA private ImageSource ThumbnailImage { get; set; } @@ -81,7 +81,7 @@ namespace VDownload.Views.Home.Controls private async void HomeSerialAddingVideoPanelSourceButton_Click(object sender, RoutedEventArgs e) { // Launch the website - await Windows.System.Launcher.LaunchUriAsync(VideoService.VideoUrl); + await Windows.System.Launcher.LaunchUriAsync(VideoService.Url); } // DELETE BUTTON CLICKED diff --git a/VDownload/Views/Home/Controls/HomeTaskPanel.xaml.cs b/VDownload/Views/Home/Controls/HomeTaskPanel.xaml.cs index 0636474..dbb147f 100644 --- a/VDownload/Views/Home/Controls/HomeTaskPanel.xaml.cs +++ b/VDownload/Views/Home/Controls/HomeTaskPanel.xaml.cs @@ -286,7 +286,7 @@ namespace VDownload.Views.Home.Controls private async void HomeTaskPanelSourceButton_Click(object sender, RoutedEventArgs e) { // Launch the website - await Windows.System.Launcher.LaunchUriAsync(Data.VideoService.VideoUrl); + await Windows.System.Launcher.LaunchUriAsync(Data.VideoService.Url); } // START STOP BUTTON CLICKED diff --git a/VDownload/Views/Home/HomeMain.xaml.cs b/VDownload/Views/Home/HomeMain.xaml.cs index 51e1759..4d8f613 100644 --- a/VDownload/Views/Home/HomeMain.xaml.cs +++ b/VDownload/Views/Home/HomeMain.xaml.cs @@ -104,7 +104,7 @@ namespace VDownload.Views.Home HomeTasksListRow.Height = new GridLength(0); // Open adding panel - HomeVideoAddingPanel addingPanel = new HomeVideoAddingPanel(e.VideoService); + HomeVideoAddingPanel addingPanel = new HomeVideoAddingPanel(e.Video); addingPanel.TasksAddingRequested += HomeTasksAddingRequest; HomeAddingPanel.Content = addingPanel; } diff --git a/VDownload/Views/Home/HomePlaylistAddingPanel.xaml.cs b/VDownload/Views/Home/HomePlaylistAddingPanel.xaml.cs index dfa0710..0eeeb33 100644 --- a/VDownload/Views/Home/HomePlaylistAddingPanel.xaml.cs +++ b/VDownload/Views/Home/HomePlaylistAddingPanel.xaml.cs @@ -26,7 +26,7 @@ namespace VDownload.Views.Home { #region CONSTRUCTORS - public HomePlaylistAddingPanel(IPlaylistService playlistService) + public HomePlaylistAddingPanel(IPlaylist playlistService) { this.InitializeComponent(); @@ -41,7 +41,7 @@ namespace VDownload.Views.Home #region PROPERTIES // BASE PLAYLIST DATA - private IPlaylistService PlaylistService { get; set; } + private IPlaylist PlaylistService { get; set; } // PLAYLIST DATA private IconElement SourceImage { get; set; } @@ -84,7 +84,7 @@ namespace VDownload.Views.Home MaxDate = PlaylistService.Videos[0].Metadata.Date; MinDuration = PlaylistService.Videos[0].Metadata.Duration; MaxDuration = PlaylistService.Videos[0].Metadata.Duration; - foreach (IVideoService video in PlaylistService.Videos) + foreach (IVideo video in PlaylistService.Videos) { // Set mins and maxes if (video.Metadata.Views < MinViews) MinViews = video.Metadata.Views; @@ -375,7 +375,7 @@ namespace VDownload.Views.Home private async void HomePlaylistAddingPanelSourceButton_Click(object sender, RoutedEventArgs e) { // Launch the website - await Windows.System.Launcher.LaunchUriAsync(PlaylistService.PlaylistUrl); + await Windows.System.Launcher.LaunchUriAsync(PlaylistService.Url); } // ADD BUTTON CLICKED diff --git a/VDownload/Views/Home/HomeVideoAddingPanel.xaml.cs b/VDownload/Views/Home/HomeVideoAddingPanel.xaml.cs index ae1f407..2675ee2 100644 --- a/VDownload/Views/Home/HomeVideoAddingPanel.xaml.cs +++ b/VDownload/Views/Home/HomeVideoAddingPanel.xaml.cs @@ -34,7 +34,7 @@ namespace VDownload.Views.Home #region CONSTRUCTORS - public HomeVideoAddingPanel(IVideoService videoService) + public HomeVideoAddingPanel(IVideo videoService) { this.InitializeComponent(); @@ -61,7 +61,7 @@ namespace VDownload.Views.Home #region PROPERTIES // BASE VIDEO DATA - private IVideoService VideoService { get; set; } + private IVideo VideoService { get; set; } // VIDEO DATA private ImageSource ThumbnailImage { get; set; } @@ -91,7 +91,7 @@ namespace VDownload.Views.Home public async void HomeVideoAddingPanelSourceButton_Click(object sender, RoutedEventArgs e) { // Launch the website - await Windows.System.Launcher.LaunchUriAsync(VideoService.VideoUrl); + await Windows.System.Launcher.LaunchUriAsync(VideoService.Url); } // ADD BUTTON CLICKED diff --git a/VDownload/Views/MainPage.xaml.cs b/VDownload/Views/MainPage.xaml.cs index a748f69..506fb96 100644 --- a/VDownload/Views/MainPage.xaml.cs +++ b/VDownload/Views/MainPage.xaml.cs @@ -34,9 +34,9 @@ namespace VDownload.Views private readonly Dictionary Pages = new Dictionary() { {"home", typeof(Home.HomeMain)}, - {"subscriptions", typeof(Subscriptions.SubscriptionsMain)}, + {"subscriptions", typeof(Subscriptions.MainPage)}, {"about", typeof(About.AboutMain)}, - {"sources", typeof(Sources.SourcesMain)}, + {"sources", typeof(Sources.MainPage)}, {"settings", typeof(Settings.SettingsMain)}, }; diff --git a/VDownload/Views/Sources/SourcesMain.xaml b/VDownload/Views/Sources/SourcesMain.xaml deleted file mode 100644 index dce72ae..0000000 --- a/VDownload/Views/Sources/SourcesMain.xaml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -