1.0-dev3-feature1 (Playlists adding added)
This commit is contained in:
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
9
VDownload/Objects/Enums/PlaylistSource.cs
Normal file
9
VDownload/Objects/Enums/PlaylistSource.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace VDownload.Objects.Enums
|
||||
{
|
||||
public enum PlaylistSource
|
||||
{
|
||||
TwitchChannel,
|
||||
LocalFile,
|
||||
Null,
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,15 @@ using VDownload.Objects.Enums;
|
||||
// System
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using Windows.Storage;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace VDownload.Services
|
||||
{
|
||||
internal class Source
|
||||
{
|
||||
// VIDEO SOURCE
|
||||
public static (VideoSource, string) GetVideoSourceData(Uri url)
|
||||
{
|
||||
// Twitch VOD
|
||||
@@ -39,5 +43,27 @@ namespace VDownload.Services
|
||||
return (VideoSource.Null, "");
|
||||
}
|
||||
}
|
||||
|
||||
// PLAYLIST SOURCE
|
||||
public static (PlaylistSource, string) GetPlaylistSourceData(Uri url)
|
||||
{
|
||||
// Local file
|
||||
if (url.IsFile)
|
||||
{
|
||||
return (PlaylistSource.LocalFile, url.AbsolutePath);
|
||||
}
|
||||
|
||||
// Twitch Channel
|
||||
else if (url.Host == "www.twitch.tv" && url.Segments.Length == 2)
|
||||
{
|
||||
return (PlaylistSource.TwitchChannel, url.Segments[url.Segments.Length - 1]);
|
||||
}
|
||||
|
||||
// Unknown
|
||||
else
|
||||
{
|
||||
return (PlaylistSource.Null, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
785
VDownload/Sources/PObject.cs
Normal file
785
VDownload/Sources/PObject.cs
Normal file
@@ -0,0 +1,785 @@
|
||||
using Microsoft.Toolkit.Uwp.UI;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Objects.Enums;
|
||||
using VDownload.Services;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace VDownload.Sources
|
||||
{
|
||||
public class PObject
|
||||
{
|
||||
#region INIT
|
||||
|
||||
// PLAYLIST DATA
|
||||
public PlaylistSource SourceType { get; private set; }
|
||||
public string ID { get; private set; }
|
||||
public Dictionary<VObject, TextBlock> VObjects { get; private set; }
|
||||
public StackPanel PlaylistPanel { get; set; }
|
||||
private List<VObject> DeletedVObjects = new List<VObject>();
|
||||
private Grid DeletedVideosPanel { get; set; }
|
||||
|
||||
// CONSTRUCTOR
|
||||
public PObject(Uri url)
|
||||
{
|
||||
VObjects = new Dictionary<VObject, TextBlock>();
|
||||
(SourceType, ID) = Source.GetPlaylistSourceData(url);
|
||||
if (SourceType == PlaylistSource.Null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region MAIN
|
||||
|
||||
// GET VIDEOS
|
||||
public async Task GetVideos()
|
||||
{
|
||||
switch (SourceType)
|
||||
{
|
||||
case PlaylistSource.TwitchChannel:
|
||||
// TODO
|
||||
break;
|
||||
case PlaylistSource.Null:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
// ADD VIDEOS TO LIST
|
||||
public async Task InitPlaylistPanel(StackPanel parent)
|
||||
{
|
||||
// Attach to panel object to PObject
|
||||
PlaylistPanel = parent;
|
||||
|
||||
// Add videos to panel
|
||||
foreach (VObject video in VObjects.Keys.ToArray())
|
||||
{
|
||||
await HandleVideoOnList(video);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region VIDEO PANEL
|
||||
|
||||
// VIDEO PANEL HANDLER
|
||||
private async Task HandleVideoOnList(VObject Video)
|
||||
{
|
||||
// Video panel
|
||||
Expander videoPanel = new Expander
|
||||
{
|
||||
Margin = new Thickness(0, 5, 0, 5),
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
HorizontalContentAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Header
|
||||
#region HEADER
|
||||
|
||||
Grid header = new Grid
|
||||
{
|
||||
Margin = new Thickness(0, 15, 0, 15),
|
||||
};
|
||||
header.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
header.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(15) });
|
||||
header.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
header.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(15) });
|
||||
header.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
videoPanel.Header = header;
|
||||
|
||||
// Thumbnail
|
||||
Image thumbnailImage = new Image
|
||||
{
|
||||
Source = new BitmapImage { UriSource = Video.Thumbnail },
|
||||
Width = 120,
|
||||
};
|
||||
Grid.SetColumn(thumbnailImage, 0);
|
||||
header.Children.Add(thumbnailImage);
|
||||
|
||||
|
||||
|
||||
// Metadata grid
|
||||
Grid metadataGrid = new Grid();
|
||||
metadataGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
metadataGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
|
||||
metadataGrid.RowDefinitions.Add(new RowDefinition());
|
||||
Grid.SetColumn(metadataGrid, 2);
|
||||
header.Children.Add(metadataGrid);
|
||||
|
||||
// Title & Source icon grid
|
||||
Grid titleSourceGrid = new Grid();
|
||||
titleSourceGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
titleSourceGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10) });
|
||||
titleSourceGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
Grid.SetRow(titleSourceGrid, 0);
|
||||
metadataGrid.Children.Add(titleSourceGrid);
|
||||
|
||||
// Title textblock
|
||||
TextBlock titleTextBlock = new TextBlock
|
||||
{
|
||||
Text = Video.Title,
|
||||
FontWeight = FontWeights.Bold,
|
||||
FontSize = 15,
|
||||
};
|
||||
Grid.SetColumn(titleTextBlock, 2);
|
||||
titleSourceGrid.Children.Add(titleTextBlock);
|
||||
|
||||
// Source icon image
|
||||
Image sourceIcon = new Image
|
||||
{
|
||||
Source = new BitmapImage { UriSource = Video.SourceIcon },
|
||||
Width = 15,
|
||||
};
|
||||
Grid.SetColumn(sourceIcon, 0);
|
||||
titleSourceGrid.Children.Add(sourceIcon);
|
||||
|
||||
// Details grid
|
||||
Grid detailedMetadataGrid = new Grid();
|
||||
detailedMetadataGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
detailedMetadataGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(8) });
|
||||
detailedMetadataGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5) });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(20) });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5) });
|
||||
detailedMetadataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
Grid.SetRow(detailedMetadataGrid, 2);
|
||||
metadataGrid.Children.Add(detailedMetadataGrid);
|
||||
double iconSize = 12;
|
||||
double textSize = 10;
|
||||
|
||||
// Author icon
|
||||
Image authorIcon = new Image
|
||||
{
|
||||
Source = new BitmapImage { UriSource = new Uri($"ms-appx:///Assets/Icons/Universal/{(Application.Current.RequestedTheme == ApplicationTheme.Dark ? "Dark" : "Light")}/Author.png") },
|
||||
Width = iconSize,
|
||||
};
|
||||
Grid.SetColumn(authorIcon, 0);
|
||||
Grid.SetRow(authorIcon, 0);
|
||||
detailedMetadataGrid.Children.Add(authorIcon);
|
||||
|
||||
// Author data textblock
|
||||
TextBlock authorDataTextBlock = new TextBlock
|
||||
{
|
||||
Text = Video.Author,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
FontSize = textSize,
|
||||
};
|
||||
Grid.SetColumn(authorDataTextBlock, 2);
|
||||
Grid.SetRow(authorDataTextBlock, 0);
|
||||
detailedMetadataGrid.Children.Add(authorDataTextBlock);
|
||||
|
||||
// Views icon
|
||||
Image viewsIcon = new Image
|
||||
{
|
||||
Source = new BitmapImage { UriSource = new Uri($"ms-appx:///Assets/Icons/Universal/{(Application.Current.RequestedTheme == ApplicationTheme.Dark ? "Dark" : "Light")}/Views.png") },
|
||||
Width = iconSize,
|
||||
};
|
||||
Grid.SetColumn(viewsIcon, 0);
|
||||
Grid.SetRow(viewsIcon, 2);
|
||||
detailedMetadataGrid.Children.Add(viewsIcon);
|
||||
|
||||
// Views data textblock
|
||||
TextBlock viewsDataTextBlock = new TextBlock
|
||||
{
|
||||
Text = Video.Views.ToString(),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
FontSize = textSize,
|
||||
};
|
||||
Grid.SetColumn(viewsDataTextBlock, 2);
|
||||
Grid.SetRow(viewsDataTextBlock, 2);
|
||||
detailedMetadataGrid.Children.Add(viewsDataTextBlock);
|
||||
|
||||
// Date icon
|
||||
Image dateIcon = new Image
|
||||
{
|
||||
Source = new BitmapImage { UriSource = new Uri($"ms-appx:///Assets/Icons/Universal/{(Application.Current.RequestedTheme == ApplicationTheme.Dark ? "Dark" : "Light")}/Date.png") },
|
||||
Width = iconSize,
|
||||
};
|
||||
Grid.SetColumn(dateIcon, 4);
|
||||
Grid.SetRow(dateIcon, 0);
|
||||
detailedMetadataGrid.Children.Add(dateIcon);
|
||||
|
||||
// Date data textblock
|
||||
TextBlock dateDataTextBlock = new TextBlock
|
||||
{
|
||||
Text = Video.Date.ToString((string)Config.GetValue("date_format")),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
FontSize = textSize,
|
||||
};
|
||||
Grid.SetColumn(dateDataTextBlock, 6);
|
||||
Grid.SetRow(dateDataTextBlock, 0);
|
||||
detailedMetadataGrid.Children.Add(dateDataTextBlock);
|
||||
|
||||
// Duration icon
|
||||
Image durationIcon = new Image
|
||||
{
|
||||
Source = new BitmapImage { UriSource = new Uri($"ms-appx:///Assets/Icons/Universal/{(Application.Current.RequestedTheme == ApplicationTheme.Dark ? "Dark" : "Light")}/Duration.png") },
|
||||
Width = iconSize,
|
||||
};
|
||||
Grid.SetColumn(durationIcon, 4);
|
||||
Grid.SetRow(durationIcon, 2);
|
||||
detailedMetadataGrid.Children.Add(durationIcon);
|
||||
|
||||
// Duration data textblock
|
||||
TextBlock durationDataTextBlock = new TextBlock
|
||||
{
|
||||
Text = Video.Duration.ToString(),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
FontSize = textSize,
|
||||
};
|
||||
Grid.SetColumn(durationDataTextBlock, 6);
|
||||
Grid.SetRow(durationDataTextBlock, 2);
|
||||
detailedMetadataGrid.Children.Add(durationDataTextBlock);
|
||||
|
||||
|
||||
|
||||
// Delete button
|
||||
AppBarButton deleteButton = new AppBarButton
|
||||
{
|
||||
Icon = new SymbolIcon(Symbol.Clear),
|
||||
Width = 40,
|
||||
Height = 48,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
deleteButton.Click += (object sender, RoutedEventArgs e) =>
|
||||
{
|
||||
PlaylistPanel.Children.Remove(videoPanel);
|
||||
VObjects.Remove(Video);
|
||||
DeletedVObjects.Add(Video);
|
||||
DeletedVideosPanelHandler();
|
||||
};
|
||||
Grid.SetColumn(deleteButton, 4);
|
||||
header.Children.Add(deleteButton);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
// Content
|
||||
#region CONTENT
|
||||
|
||||
Grid content = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
//Margin = new Thickness(0, 15, 0, 15),
|
||||
};
|
||||
content.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
content.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) });
|
||||
content.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
videoPanel.Content = content;
|
||||
|
||||
|
||||
|
||||
// Download options
|
||||
Grid downloadOptionsGrid = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
downloadOptionsGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
downloadOptionsGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) });
|
||||
downloadOptionsGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
Grid.SetRow(downloadOptionsGrid, 0);
|
||||
content.Children.Add(downloadOptionsGrid);
|
||||
|
||||
// Media type
|
||||
Grid mediaTypeGrid = new Grid();
|
||||
mediaTypeGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
mediaTypeGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(8) });
|
||||
mediaTypeGrid.RowDefinitions.Add(new RowDefinition());
|
||||
mediaTypeGrid.RowDefinitions.Add(new RowDefinition());
|
||||
mediaTypeGrid.RowDefinitions.Add(new RowDefinition());
|
||||
Grid.SetColumn(mediaTypeGrid, 0);
|
||||
downloadOptionsGrid.Children.Add(mediaTypeGrid);
|
||||
|
||||
// Media type textblock
|
||||
TextBlock AddPlaylistVideoDownloadOptionsMediaTypeTextBlock = new TextBlock
|
||||
{
|
||||
Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoDownloadOptionsMediaTypeTextBlock"),
|
||||
FontWeight = FontWeights.SemiBold,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsMediaTypeTextBlock, 0);
|
||||
mediaTypeGrid.Children.Add(AddPlaylistVideoDownloadOptionsMediaTypeTextBlock);
|
||||
|
||||
// Media type radiobutton (AV)
|
||||
RadioButton AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV = new RadioButton
|
||||
{
|
||||
Content = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV"),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
VerticalAlignment = VerticalAlignment.Top,
|
||||
GroupName = $"QualityRadiobuttons{Video.UniqueID}"
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV, 2);
|
||||
mediaTypeGrid.Children.Add(AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV);
|
||||
|
||||
// Media type radiobutton (A)
|
||||
RadioButton AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA = new RadioButton
|
||||
{
|
||||
Content = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA"),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
GroupName = $"QualityRadiobuttons{Video.UniqueID}"
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA, 3);
|
||||
mediaTypeGrid.Children.Add(AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA);
|
||||
|
||||
// Media type radiobutton (V)
|
||||
RadioButton AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV = new RadioButton
|
||||
{
|
||||
Content = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV"),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
VerticalAlignment = VerticalAlignment.Bottom,
|
||||
GroupName = $"QualityRadiobuttons{Video.UniqueID}"
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV, 4);
|
||||
mediaTypeGrid.Children.Add(AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV);
|
||||
|
||||
// Separator
|
||||
AppBarSeparator AddPlaylistVideoDownloadOptionsSeparator = new AppBarSeparator
|
||||
{
|
||||
VerticalAlignment = VerticalAlignment.Stretch,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistVideoDownloadOptionsSeparator, 1);
|
||||
downloadOptionsGrid.Children.Add(AddPlaylistVideoDownloadOptionsSeparator);
|
||||
|
||||
// Quality & Trim grid
|
||||
Grid qualityTrimGrid = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
qualityTrimGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
qualityTrimGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) });
|
||||
qualityTrimGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
Grid.SetColumn(qualityTrimGrid, 2);
|
||||
downloadOptionsGrid.Children.Add(qualityTrimGrid);
|
||||
|
||||
// Quality grid
|
||||
Grid qualityGrid = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
qualityGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
qualityGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(8) });
|
||||
qualityGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
Grid.SetRow(qualityGrid, 0);
|
||||
qualityTrimGrid.Children.Add(qualityGrid);
|
||||
|
||||
// Quality textblock
|
||||
TextBlock AddPlaylistVideoDownloadOptionsQualityTextBlock = new TextBlock
|
||||
{
|
||||
Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoDownloadOptionsQualityTextBlock"),
|
||||
FontWeight = FontWeights.SemiBold,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsQualityTextBlock, 0);
|
||||
qualityGrid.Children.Add(AddPlaylistVideoDownloadOptionsQualityTextBlock);
|
||||
|
||||
// Quality combobox
|
||||
ComboBox AddPlaylistVideoDownloadOptionsQualityComboBox = new ComboBox
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsQualityComboBox, 2);
|
||||
qualityGrid.Children.Add(AddPlaylistVideoDownloadOptionsQualityComboBox);
|
||||
|
||||
// Trim grid
|
||||
Grid trimGrid = new Grid();
|
||||
trimGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
trimGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(8) });
|
||||
trimGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
Grid.SetRow(trimGrid, 2);
|
||||
qualityTrimGrid.Children.Add(trimGrid);
|
||||
|
||||
// Trim textblock
|
||||
TextBlock AddPlaylistVideoDownloadOptionsTrimTextBlock = new TextBlock
|
||||
{
|
||||
Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoDownloadOptionsTrimTextBlock"),
|
||||
FontWeight = FontWeights.SemiBold,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoDownloadOptionsTrimTextBlock, 0);
|
||||
trimGrid.Children.Add(AddPlaylistVideoDownloadOptionsTrimTextBlock);
|
||||
|
||||
// Trim textbox grid
|
||||
Grid trimTextBoxGrid = new Grid();
|
||||
trimTextBoxGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
trimTextBoxGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8) });
|
||||
trimTextBoxGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
trimTextBoxGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8) });
|
||||
trimTextBoxGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
Grid.SetRow(trimTextBoxGrid, 2);
|
||||
trimGrid.Children.Add(trimTextBoxGrid);
|
||||
|
||||
// Trim start textbox
|
||||
TextBox AddPlaylistVideoDownloadOptionsTrimStartTextBox = new TextBox();
|
||||
TextBoxExtensions.SetCustomMask(AddPlaylistVideoDownloadOptionsTrimStartTextBox, "5:[0-5]");
|
||||
TextBoxExtensions.SetMask(AddPlaylistVideoDownloadOptionsTrimStartTextBox, "99:59:59");
|
||||
Grid.SetColumn(AddPlaylistVideoDownloadOptionsTrimStartTextBox, 0);
|
||||
trimTextBoxGrid.Children.Add(AddPlaylistVideoDownloadOptionsTrimStartTextBox);
|
||||
|
||||
// Trim separator
|
||||
TextBlock AddPlaylistVideoDownloadOptionsTrimSeparatorTextBlock = new TextBlock
|
||||
{
|
||||
Text = "-",
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistVideoDownloadOptionsTrimSeparatorTextBlock, 2);
|
||||
trimTextBoxGrid.Children.Add(AddPlaylistVideoDownloadOptionsTrimSeparatorTextBlock);
|
||||
|
||||
// Trim end textbox
|
||||
TextBox AddPlaylistVideoDownloadOptionsTrimEndTextBox = new TextBox();
|
||||
TextBoxExtensions.SetCustomMask(AddPlaylistVideoDownloadOptionsTrimEndTextBox, "5:[0-5]");
|
||||
TextBoxExtensions.SetMask(AddPlaylistVideoDownloadOptionsTrimEndTextBox, "99:59:59");
|
||||
Grid.SetColumn(AddPlaylistVideoDownloadOptionsTrimEndTextBox, 4);
|
||||
trimTextBoxGrid.Children.Add(AddPlaylistVideoDownloadOptionsTrimEndTextBox);
|
||||
|
||||
|
||||
|
||||
// File & location
|
||||
Grid fileLocationGrid = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
fileLocationGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
fileLocationGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
|
||||
fileLocationGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
fileLocationGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
fileLocationGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(15) });
|
||||
fileLocationGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
Grid.SetRow(fileLocationGrid, 4);
|
||||
content.Children.Add(fileLocationGrid);
|
||||
|
||||
// File textblock
|
||||
TextBlock AddPlaylistVideoFileDataTextBlock = new TextBlock
|
||||
{
|
||||
Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoFileDataTextBlock"),
|
||||
FontWeight = FontWeights.SemiBold,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoFileDataTextBlock, 0);
|
||||
Grid.SetColumn(AddPlaylistVideoFileDataTextBlock, 0);
|
||||
fileLocationGrid.Children.Add(AddPlaylistVideoFileDataTextBlock);
|
||||
|
||||
// File grid
|
||||
Grid fileGrid = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
fileGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
fileGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(15) });
|
||||
fileGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
Grid.SetRow(fileGrid, 0);
|
||||
Grid.SetColumn(fileGrid, 2);
|
||||
fileLocationGrid.Children.Add(fileGrid);
|
||||
|
||||
// Filename textbox
|
||||
TextBox AddPlaylistVideoFileDataFilenameTextBox = new TextBox();
|
||||
Grid.SetColumn(AddPlaylistVideoFileDataFilenameTextBox, 0);
|
||||
fileGrid.Children.Add(AddPlaylistVideoFileDataFilenameTextBox);
|
||||
|
||||
// Extension combobox
|
||||
ComboBox AddPlaylistVideoFileDataExtensionComboBox = new ComboBox
|
||||
{
|
||||
Width = 80
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistVideoFileDataExtensionComboBox, 2);
|
||||
fileGrid.Children.Add(AddPlaylistVideoFileDataExtensionComboBox);
|
||||
|
||||
// Location textblock
|
||||
TextBlock AddPlaylistVideoLocationDataTextBlock = new TextBlock
|
||||
{
|
||||
Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoLocationDataTextBlock"),
|
||||
FontWeight = FontWeights.SemiBold,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetRow(AddPlaylistVideoLocationDataTextBlock, 2);
|
||||
Grid.SetColumn(AddPlaylistVideoLocationDataTextBlock, 0);
|
||||
fileLocationGrid.Children.Add(AddPlaylistVideoLocationDataTextBlock);
|
||||
|
||||
// Location grid
|
||||
Grid locationGrid = new Grid
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
};
|
||||
locationGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
locationGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0) });
|
||||
locationGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
Grid.SetRow(locationGrid, 2);
|
||||
Grid.SetColumn(locationGrid, 2);
|
||||
fileLocationGrid.Children.Add(locationGrid);
|
||||
|
||||
// Location data textblock
|
||||
TextBlock AddPlaylistVideoLocationDataLocationTextBlock = new TextBlock
|
||||
{
|
||||
Text = "//Location",
|
||||
FontSize = 11,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistVideoLocationDataLocationTextBlock, 0);
|
||||
locationGrid.Children.Add(AddPlaylistVideoLocationDataLocationTextBlock);
|
||||
|
||||
// Location selection button
|
||||
Button AddPlaylistVideoLocationDataChooseLocationButton = new Button
|
||||
{
|
||||
Content = "...",
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistVideoLocationDataChooseLocationButton, 2);
|
||||
locationGrid.Children.Add(AddPlaylistVideoLocationDataChooseLocationButton);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
// Set items in quality combobox
|
||||
foreach (string q in Video.Streams.Keys)
|
||||
{
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.Items.Add(q);
|
||||
}
|
||||
|
||||
// Set items in extension combobox
|
||||
foreach (string x in Video.MediaType == "A" ? Config.DefaultAudioExtensionList : Config.DefaultVideoExtensionList)
|
||||
{
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Add(x);
|
||||
}
|
||||
|
||||
// Set quality option
|
||||
if (Video.MediaType == "A")
|
||||
{
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.SelectedValue = ResourceLoader.GetForCurrentView().GetString("AddVideoQualityNoVideoStream");
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.SelectedValue = Video.SelectedQuality;
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.IsEnabled = true;
|
||||
}
|
||||
|
||||
// Set trim options
|
||||
AddPlaylistVideoDownloadOptionsTrimStartTextBox.Text = Video.TrimStart.ToString();
|
||||
AddPlaylistVideoDownloadOptionsTrimEndTextBox.Text = Video.TrimEnd.ToString();
|
||||
|
||||
// Set media type option
|
||||
switch (Video.MediaType)
|
||||
{
|
||||
case "AV": AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV.IsChecked = true; break;
|
||||
case "V": AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV.IsChecked = true; break;
|
||||
case "A": AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA.IsChecked = true; break;
|
||||
default: AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV.IsChecked = true; break;
|
||||
}
|
||||
|
||||
// Set filename option
|
||||
AddPlaylistVideoFileDataFilenameTextBox.Text = Video.Filename;
|
||||
|
||||
// Set extension option
|
||||
AddPlaylistVideoFileDataExtensionComboBox.SelectedItem = Video.Extension;
|
||||
|
||||
// Set location option
|
||||
if (StorageApplicationPermissions.FutureAccessList.ContainsItem("save"))
|
||||
{
|
||||
Video.CustomSaveLocation = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync("save");
|
||||
AddPlaylistVideoLocationDataLocationTextBlock.Text = Video.CustomSaveLocation.Path;
|
||||
Video.FilePath = $@"{(Video.CustomSaveLocation.Path[Video.CustomSaveLocation.Path.Length - 1] == '\\' ? Video.CustomSaveLocation.Path : Video.CustomSaveLocation.Path + '\\')}{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
}
|
||||
else
|
||||
{
|
||||
AddPlaylistVideoLocationDataLocationTextBlock.Text = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\";
|
||||
Video.FilePath = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
}
|
||||
|
||||
// Set event handlers
|
||||
AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV.Checked += (object sender, RoutedEventArgs e) =>
|
||||
{
|
||||
Video.MediaType = "AV";
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.IsEnabled = true;
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.SelectedValue = Video.Streams.Keys.ToArray()[0];
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Clear();
|
||||
foreach (string x in Config.DefaultVideoExtensionList)
|
||||
{
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Add(x);
|
||||
}
|
||||
AddPlaylistVideoFileDataExtensionComboBox.SelectedItem = Config.GetValue("default_video_extension");
|
||||
};
|
||||
AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA.Checked += (object sender, RoutedEventArgs e) =>
|
||||
{
|
||||
Video.MediaType = "A";
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.IsEnabled = false;
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.SelectedValue = ResourceLoader.GetForCurrentView().GetString("AddPlaylistVideoQualityNoVideoStream");
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Clear();
|
||||
foreach (string x in Config.DefaultAudioExtensionList)
|
||||
{
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Add(x);
|
||||
}
|
||||
AddPlaylistVideoFileDataExtensionComboBox.SelectedItem = Config.GetValue("default_audio_extension");
|
||||
};
|
||||
AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV.Checked += (object sender, RoutedEventArgs e) =>
|
||||
{
|
||||
Video.MediaType = "V";
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.IsEnabled = true;
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.SelectedValue = Video.Streams.Keys.ToArray()[0];
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Clear();
|
||||
foreach (string x in Config.DefaultVideoExtensionList)
|
||||
{
|
||||
AddPlaylistVideoFileDataExtensionComboBox.Items.Add(x);
|
||||
}
|
||||
AddPlaylistVideoFileDataExtensionComboBox.SelectedItem = Config.GetValue("default_video_extension");
|
||||
};
|
||||
AddPlaylistVideoDownloadOptionsQualityComboBox.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
|
||||
{
|
||||
if (Video.MediaType == "A")
|
||||
Video.SelectedQuality = Video.Streams.Keys.ToArray()[0];
|
||||
else
|
||||
Video.SelectedQuality = (string)AddPlaylistVideoDownloadOptionsQualityComboBox.SelectedItem;
|
||||
};
|
||||
AddPlaylistVideoDownloadOptionsTrimStartTextBox.TextChanged += (object sender, TextChangedEventArgs e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Video.TrimStart = TimeSpan.Parse(AddPlaylistVideoDownloadOptionsTrimStartTextBox.Text);
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
AddPlaylistVideoDownloadOptionsTrimEndTextBox.TextChanged += (object sender, TextChangedEventArgs e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Video.TrimEnd = TimeSpan.Parse(AddPlaylistVideoDownloadOptionsTrimEndTextBox.Text);
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
AddPlaylistVideoFileDataFilenameTextBox.TextChanged += (object sender, TextChangedEventArgs e) =>
|
||||
{
|
||||
foreach (char c in Path.GetInvalidFileNameChars())
|
||||
{
|
||||
AddPlaylistVideoFileDataFilenameTextBox.Text = AddPlaylistVideoFileDataFilenameTextBox.Text.Replace(c, ' ');
|
||||
}
|
||||
Video.Filename = AddPlaylistVideoFileDataFilenameTextBox.Text;
|
||||
if (Video.CustomSaveLocation != null)
|
||||
Video.FilePath = $@"{(Video.CustomSaveLocation.Path[Video.CustomSaveLocation.Path.Length - 1] == '\\' ? Video.CustomSaveLocation.Path : Video.CustomSaveLocation.Path + '\\')}{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
else
|
||||
Video.FilePath = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
};
|
||||
AddPlaylistVideoFileDataExtensionComboBox.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
|
||||
{
|
||||
if (!(AddPlaylistVideoFileDataExtensionComboBox.SelectedItem == null))
|
||||
{
|
||||
Video.Extension = (string)AddPlaylistVideoFileDataExtensionComboBox.SelectedItem;
|
||||
if (Video.CustomSaveLocation != null)
|
||||
Video.FilePath = $@"{(Video.CustomSaveLocation.Path[Video.CustomSaveLocation.Path.Length - 1] == '\\' ? Video.CustomSaveLocation.Path : Video.CustomSaveLocation.Path + '\\')}{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
else
|
||||
Video.FilePath = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
}
|
||||
};
|
||||
AddPlaylistVideoLocationDataChooseLocationButton.Click += async (object sender, RoutedEventArgs e) =>
|
||||
{
|
||||
FolderPicker picker = new FolderPicker();
|
||||
picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
|
||||
picker.FileTypeFilter.Add("*");
|
||||
StorageFolder folder = await picker.PickSingleFolderAsync();
|
||||
if (folder != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await (await folder.CreateFileAsync("VDownloadLocationAccessTest")).DeleteAsync();
|
||||
Video.CustomSaveLocation = folder;
|
||||
AddPlaylistVideoLocationDataLocationTextBlock.Text = Video.CustomSaveLocation.Path[Video.CustomSaveLocation.Path.Length - 1] == '\\' ? Video.CustomSaveLocation.Path : Video.CustomSaveLocation.Path + '\\';
|
||||
Video.FilePath = $@"{(Video.CustomSaveLocation.Path[Video.CustomSaveLocation.Path.Length - 1] == '\\' ? Video.CustomSaveLocation.Path : Video.CustomSaveLocation.Path + '\\')}{Video.Filename}.{Video.Extension.ToLower()}";
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Add panel
|
||||
VObjects[Video] = AddPlaylistVideoLocationDataLocationTextBlock;
|
||||
PlaylistPanel.Children.Add(videoPanel);
|
||||
}
|
||||
|
||||
// HANDLE DELETED VIDEOS PANEL
|
||||
private void DeletedVideosPanelHandler()
|
||||
{
|
||||
if (DeletedVideosPanel == null)
|
||||
{
|
||||
// Init panel
|
||||
DeletedVideosPanel = new Grid
|
||||
{
|
||||
Background = new SolidColorBrush((Color)Application.Current.Resources["SystemChromeMediumHighColor"]),
|
||||
BorderThickness = new Thickness(10),
|
||||
BorderBrush = new SolidColorBrush((Color)Application.Current.Resources["SystemChromeMediumHighColor"]),
|
||||
CornerRadius = new CornerRadius(1),
|
||||
Margin = new Thickness(0, 5, 0, 5),
|
||||
};
|
||||
DeletedVideosPanel.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
DeletedVideosPanel.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10) });
|
||||
DeletedVideosPanel.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
|
||||
// Textblock
|
||||
TextBlock AddPlaylistDeletedVideosPanelTextBlock = new TextBlock
|
||||
{
|
||||
Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistDeletedVideosPanelTextBlock").Replace("{x}", DeletedVObjects.Count.ToString()),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistDeletedVideosPanelTextBlock, 0);
|
||||
DeletedVideosPanel.Children.Add(AddPlaylistDeletedVideosPanelTextBlock);
|
||||
|
||||
// Button
|
||||
Button AddPlaylistDeletedVideosPanelButton = new Button
|
||||
{
|
||||
Content = ResourceLoader.GetForCurrentView().GetString("AddPlaylistDeletedVideosPanelButton")
|
||||
};
|
||||
AddPlaylistDeletedVideosPanelButton.Click += async (object sender, RoutedEventArgs e) =>
|
||||
{
|
||||
foreach (VObject v in DeletedVObjects)
|
||||
{
|
||||
await HandleVideoOnList(v);
|
||||
}
|
||||
DeletedVObjects.Clear();
|
||||
PlaylistPanel.Children.Remove(DeletedVideosPanel);
|
||||
DeletedVideosPanel = null;
|
||||
};
|
||||
Grid.SetColumn(AddPlaylistDeletedVideosPanelButton, 2);
|
||||
DeletedVideosPanel.Children.Add(AddPlaylistDeletedVideosPanelButton);
|
||||
|
||||
// Add panel
|
||||
PlaylistPanel.Children.Add(DeletedVideosPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
((TextBlock)DeletedVideosPanel.Children[0]).Text = ResourceLoader.GetForCurrentView().GetString("AddPlaylistDeletedVideosPanelTextBlock").Replace("{x}", DeletedVObjects.Count.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
89
VDownload/Sources/Twitch/Channel.cs
Normal file
89
VDownload/Sources/Twitch/Channel.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Sources.Twitch
|
||||
{
|
||||
internal class Channel
|
||||
{
|
||||
#region INIT
|
||||
|
||||
// ID
|
||||
private string ID { get; set; }
|
||||
|
||||
// CONSTRUCTOR
|
||||
public Channel(string id)
|
||||
{
|
||||
ID = id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region MAIN
|
||||
|
||||
// GET VIDEOS
|
||||
public async Task<string[]> GetVideos()
|
||||
{
|
||||
// Client settings
|
||||
WebClient Client = new WebClient();
|
||||
Client.Headers.Add("Accept", "application/vnd.twitchtv.v5+json");
|
||||
Client.Headers.Add("Client-ID", "uo6dggojyb8d6soh92zknwmi5ej1q2");
|
||||
|
||||
// Get channel id
|
||||
Uri requestUri;
|
||||
JObject response;
|
||||
if (!ID.All(char.IsDigit))
|
||||
{
|
||||
Debug.WriteLine(ID);
|
||||
requestUri = new Uri($"https://api.twitch.tv/kraken/users?login={ID}");
|
||||
response = JObject.Parse(await Client.DownloadStringTaskAsync(requestUri));
|
||||
response = (JObject)response["users"][0];
|
||||
}
|
||||
else
|
||||
{
|
||||
requestUri = new Uri($"https://api.twitch.tv/kraken/users/{ID}");
|
||||
response = JObject.Parse(await Client.DownloadStringTaskAsync(requestUri));
|
||||
}
|
||||
string id = response["_id"].ToString();
|
||||
|
||||
// Get list
|
||||
List<string> videos = new List<string>();
|
||||
int offset = 0;
|
||||
do
|
||||
{
|
||||
Client = new WebClient();
|
||||
Client.Headers.Add("Accept", "application/vnd.twitchtv.v5+json");
|
||||
Client.Headers.Add("Client-ID", "v8kfhyc2980it9e7t5hhc7baukzuj2");
|
||||
|
||||
requestUri = new Uri($"https://api.twitch.tv/kraken/channels/{id}/videos?limit=100&offset={offset}");
|
||||
response = JObject.Parse(await Client.DownloadStringTaskAsync(requestUri));
|
||||
foreach (var v in response["videos"])
|
||||
{
|
||||
Debug.WriteLine(v["_id"].ToString().Replace("v", ""));
|
||||
videos.Add(v["_id"].ToString().Replace("v", ""));
|
||||
}
|
||||
|
||||
if (response["videos"].ToArray().Length == 100)
|
||||
{
|
||||
offset += 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
// Return videos
|
||||
return videos.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace VDownload.Sources
|
||||
#region INIT
|
||||
|
||||
// VIDEO METADATA
|
||||
private string UniqueID { get; set; }
|
||||
public string UniqueID { get; private set; }
|
||||
public VideoSource SourceType { get; private set; }
|
||||
public string ID { get; private set; }
|
||||
public string Title { get; private set; }
|
||||
@@ -78,6 +78,8 @@ namespace VDownload.Sources
|
||||
VideoSourceHandler = new Twitch.Clip(ID);
|
||||
SourceIcon = new Uri("ms-appx:///Assets/Icons/Sources/Twitch.png");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
UniqueID = Videos.GetUniqueID();
|
||||
}
|
||||
@@ -612,7 +614,7 @@ namespace VDownload.Sources
|
||||
Grid.SetColumn(buttonsGrid, 2);
|
||||
baseGrid.Children.Add(buttonsGrid);
|
||||
|
||||
// Source icon
|
||||
// Source button
|
||||
AppBarButton sourceButton = new AppBarButton
|
||||
{
|
||||
Icon = new BitmapIcon { UriSource = SourceIcon, ShowAsMonochrome = false },
|
||||
|
||||
@@ -117,6 +117,66 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AddPlaylistBase.CloseButtonText" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="AddPlaylistBase.PrimaryButtonText" xml:space="preserve">
|
||||
<value>Add</value>
|
||||
</data>
|
||||
<data name="AddPlaylistBase.Title" xml:space="preserve">
|
||||
<value>ADD PLAYLIST</value>
|
||||
</data>
|
||||
<data name="AddPlaylistDeletedVideosPanelButton" xml:space="preserve">
|
||||
<value>Restore</value>
|
||||
</data>
|
||||
<data name="AddPlaylistDeletedVideosPanelTextBlock" xml:space="preserve">
|
||||
<value>{x} videos removed</value>
|
||||
</data>
|
||||
<data name="AddPlaylistLocationSelectionApplyLocationButton.Content" xml:space="preserve">
|
||||
<value>Apply</value>
|
||||
</data>
|
||||
<data name="AddPlaylistLocationSelectionTextBlock.Text" xml:space="preserve">
|
||||
<value>Location</value>
|
||||
</data>
|
||||
<data name="AddPlaylistNotFoundText" xml:space="preserve">
|
||||
<value>Playlist not found. Try again.</value>
|
||||
</data>
|
||||
<data name="AddPlaylistSearchButton.Content" xml:space="preserve">
|
||||
<value>Search</value>
|
||||
</data>
|
||||
<data name="AddPlaylistStartText.Text" xml:space="preserve">
|
||||
<value>Paste URL and click "Search" button</value>
|
||||
</data>
|
||||
<data name="AddPlaylistUrlPathText.Text" xml:space="preserve">
|
||||
<value>URL</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonA" xml:space="preserve">
|
||||
<value>Only audio</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonAV" xml:space="preserve">
|
||||
<value>Normal</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoDownloadOptionsMediaTypeRadiobuttonV" xml:space="preserve">
|
||||
<value>Only video</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoDownloadOptionsMediaTypeTextBlock" xml:space="preserve">
|
||||
<value>Media type</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoDownloadOptionsQualityTextBlock" xml:space="preserve">
|
||||
<value>Quality</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoDownloadOptionsTrimTextBlock" xml:space="preserve">
|
||||
<value>Trim</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoFileDataTextBlock" xml:space="preserve">
|
||||
<value>File</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoLocationDataTextBlock" xml:space="preserve">
|
||||
<value>Location</value>
|
||||
</data>
|
||||
<data name="AddPlaylistVideoQualityNoVideoStream" xml:space="preserve">
|
||||
<value>Only audio</value>
|
||||
</data>
|
||||
<data name="AddVideoBase.CloseButtonText" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
@@ -159,6 +219,12 @@
|
||||
<data name="AddVideoStartText.Text" xml:space="preserve">
|
||||
<value>Paste URL and click "Search" button</value>
|
||||
</data>
|
||||
<data name="AppBarAddPlaylistButton.Label" xml:space="preserve">
|
||||
<value>Add playlist</value>
|
||||
</data>
|
||||
<data name="AppBarAddPlaylistButton.Width" xml:space="preserve">
|
||||
<value>85</value>
|
||||
</data>
|
||||
<data name="AppBarAddVideoButton.Label" xml:space="preserve">
|
||||
<value>Add video</value>
|
||||
</data>
|
||||
|
||||
@@ -119,15 +119,33 @@
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Objects\Enums\PlaylistSource.cs" />
|
||||
<Compile Include="Objects\Enums\VideoSource.cs" />
|
||||
<Compile Include="Objects\Enums\VideoStatus.cs" />
|
||||
<Compile Include="Services\Config.cs" />
|
||||
<Compile Include="Services\Media.cs" />
|
||||
<Compile Include="Services\Source.cs" />
|
||||
<Compile Include="Services\Videos.cs" />
|
||||
<Compile Include="Sources\PObject.cs" />
|
||||
<Compile Include="Sources\Twitch\Channel.cs" />
|
||||
<Compile Include="Sources\Twitch\Clip.cs" />
|
||||
<Compile Include="Sources\Twitch\Vod.cs" />
|
||||
<Compile Include="Sources\VObject.cs" />
|
||||
<Compile Include="Views\AddPlaylist\AddPlaylistBase.xaml.cs">
|
||||
<DependentUpon>AddPlaylistBase.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AddPlaylist\AddPlaylistLoading.xaml.cs">
|
||||
<DependentUpon>AddPlaylistLoading.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AddPlaylist\AddPlaylistMain.xaml.cs">
|
||||
<DependentUpon>AddPlaylistMain.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AddPlaylist\AddPlaylistNotFound.xaml.cs">
|
||||
<DependentUpon>AddPlaylistNotFound.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AddPlaylist\AddPlaylistStart.xaml.cs">
|
||||
<DependentUpon>AddPlaylistStart.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AddVideo\AddVideoBase.xaml.cs">
|
||||
<DependentUpon>AddVideoBase.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -154,8 +172,8 @@
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\Icons\AddVideo\NotFound.png" />
|
||||
<Content Include="Assets\Icons\AddVideo\Start.png" />
|
||||
<Content Include="Assets\Icons\Add\NotFound.png" />
|
||||
<Content Include="Assets\Icons\Add\Start.png" />
|
||||
<Content Include="Assets\Icons\Sources\Twitch.png" />
|
||||
<Content Include="Assets\Icons\Sources\Unknown.png" />
|
||||
<Content Include="Assets\Icons\Sources\Youtube.png" />
|
||||
@@ -250,6 +268,26 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Views\AddPlaylist\AddPlaylistBase.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\AddPlaylist\AddPlaylistLoading.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\AddPlaylist\AddPlaylistMain.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\AddPlaylist\AddPlaylistNotFound.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\AddPlaylist\AddPlaylistStart.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\AddVideo\AddVideoBase.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -292,6 +330,7 @@
|
||||
<ItemGroup>
|
||||
<PRIResource Include="Strings\en-US\Resources.resw" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
39
VDownload/Views/AddPlaylist/AddPlaylistBase.xaml
Normal file
39
VDownload/Views/AddPlaylist/AddPlaylistBase.xaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<ContentDialog
|
||||
x:Class="VDownload.Views.AddPlaylist.AddPlaylistBase"
|
||||
x:Uid="AddPlaylistBase"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:VDownload.Views.AddPlaylist"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="ADD PLAYLIST"
|
||||
PrimaryButtonText="Add"
|
||||
CloseButtonText="Cancel"
|
||||
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
|
||||
IsPrimaryButtonEnabled="False">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- SEARCH BAR -->
|
||||
<Grid VerticalAlignment="Top" Width="498" Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="AddPlaylistUrlPathText" x:Uid="AddPlaylistUrlPathText" HorizontalAlignment="Left" Text="URL" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="0"/>
|
||||
<TextBox x:Name="AddPlaylistUrlTextBox" HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Column="2"/>
|
||||
<Button x:Name="AddPlaylistSearchButton" x:Uid="AddPlaylistSearchButton" Content="Search" VerticalAlignment="Center" Grid.Column="4" HorizontalAlignment="Right" Click="AddPlaylistSearchButton_Click"/>
|
||||
</Grid>
|
||||
|
||||
<!-- CONTENT FRAME -->
|
||||
<Frame x:Name="AddPlaylistContent" Height="500" Grid.Row="2"/>
|
||||
</Grid>
|
||||
</ContentDialog>
|
||||
89
VDownload/Views/AddPlaylist/AddPlaylistBase.xaml.cs
Normal file
89
VDownload/Views/AddPlaylist/AddPlaylistBase.xaml.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using VDownload.Sources;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace VDownload.Views.AddPlaylist
|
||||
{
|
||||
public sealed partial class AddPlaylistBase : ContentDialog
|
||||
{
|
||||
public AddPlaylistBase()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistStart));
|
||||
}
|
||||
|
||||
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
// Attach video info as content
|
||||
Content = AddPlaylistMain.Playlist.VObjects.Keys.ToArray();
|
||||
}
|
||||
|
||||
private async void AddPlaylistSearchButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Navigate to loading page
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistLoading));
|
||||
IsPrimaryButtonEnabled = false;
|
||||
|
||||
// Check url and get data
|
||||
Uri url = null;
|
||||
try
|
||||
{
|
||||
// Get url from textbox
|
||||
url = new Uri(AddPlaylistUrlTextBox.Text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Navigate to not found page if url or path is invalid
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistNotFound));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (url != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get videos list
|
||||
PObject playlist = new PObject(url);
|
||||
await playlist.GetVideos();
|
||||
|
||||
if (playlist.VObjects.Count > 0)
|
||||
{
|
||||
// Navigate to playlist main page
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistMain), playlist);
|
||||
IsPrimaryButtonEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Navigate to not found page if playlist is empty
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistNotFound));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Navigate to not found page if url or path is invalid
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistNotFound));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Navigate to not found page if url or path is invalid
|
||||
AddPlaylistContent.Navigate(typeof(AddPlaylistNotFound));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
VDownload/Views/AddPlaylist/AddPlaylistLoading.xaml
Normal file
17
VDownload/Views/AddPlaylist/AddPlaylistLoading.xaml
Normal file
@@ -0,0 +1,17 @@
|
||||
<Page
|
||||
x:Class="VDownload.Views.AddPlaylist.AddPlaylistLoading"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:VDownload.Views.AddPlaylist"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
Height="500"
|
||||
Width="498">
|
||||
|
||||
<!-- PROGRESS RING -->
|
||||
<Grid>
|
||||
<ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="True" Width="50" Height="50"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
13
VDownload/Views/AddPlaylist/AddPlaylistLoading.xaml.cs
Normal file
13
VDownload/Views/AddPlaylist/AddPlaylistLoading.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
// System
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace VDownload.Views.AddPlaylist
|
||||
{
|
||||
public sealed partial class AddPlaylistLoading : Page
|
||||
{
|
||||
public AddPlaylistLoading()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
VDownload/Views/AddPlaylist/AddPlaylistMain.xaml
Normal file
41
VDownload/Views/AddPlaylist/AddPlaylistMain.xaml
Normal file
@@ -0,0 +1,41 @@
|
||||
<Page
|
||||
x:Class="VDownload.Views.AddPlaylist.AddPlaylistMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:VDownload.Views.AddPlaylist"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
Height="500"
|
||||
Width="498">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- VIDEO LIST -->
|
||||
<ScrollViewer Grid.Row="0">
|
||||
<StackPanel x:Name="AddPlaylistVideoPanel"/>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- LOCATION SELECTION -->
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="AddPlaylistLocationSelectionTextBlock" x:Uid="AddPlaylistLocationSelectionTextBlock" Text="Location" FontWeight="SemiBold" VerticalAlignment="Center" Grid.Column="0"/>
|
||||
<TextBlock x:Name="AddPlaylistLocationSelectionLocationTextBlock" Text="//Location" FontSize="11" VerticalAlignment="Center" Grid.Column="2"/>
|
||||
<Button x:Name="AddPlaylistLocationSelectionSelectLocationButton" Content="..." Click="AddPlaylistLocationSelectionSelectLocationButton_Click" Grid.Column="4"/>
|
||||
<Button x:Name="AddPlaylistLocationSelectionApplyLocationButton" x:Uid="AddPlaylistLocationSelectionApplyLocationButton" Content="Apply" Click="AddPlaylistLocationSelectionApplyLocationButton_Click" Grid.Column="6"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
111
VDownload/Views/AddPlaylist/AddPlaylistMain.xaml.cs
Normal file
111
VDownload/Views/AddPlaylist/AddPlaylistMain.xaml.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using VDownload.Sources;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace VDownload.Views.AddPlaylist
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class AddPlaylistMain : Page
|
||||
{
|
||||
#region INIT
|
||||
|
||||
// PLAYLIST OBJECT
|
||||
public static PObject Playlist;
|
||||
private StorageFolder ApplyToAllLocation;
|
||||
|
||||
// CONSTRUCTOR
|
||||
public AddPlaylistMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region MAIN
|
||||
|
||||
// NAVIGATED TO THIS PAGE
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// Set ApplyToAllLocation
|
||||
if (StorageApplicationPermissions.FutureAccessList.ContainsItem("save"))
|
||||
{
|
||||
ApplyToAllLocation = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync("save");
|
||||
AddPlaylistLocationSelectionLocationTextBlock.Text = ApplyToAllLocation.Path;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddPlaylistLocationSelectionLocationTextBlock.Text = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\";
|
||||
}
|
||||
|
||||
// Get playlist object from parent
|
||||
base.OnNavigatedTo(e);
|
||||
Playlist = (PObject)e.Parameter;
|
||||
await Playlist.InitPlaylistPanel(AddPlaylistVideoPanel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// SELECT LOCATION
|
||||
private async void AddPlaylistLocationSelectionSelectLocationButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FolderPicker picker = new FolderPicker();
|
||||
picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
|
||||
picker.FileTypeFilter.Add("*");
|
||||
StorageFolder folder = await picker.PickSingleFolderAsync();
|
||||
if (folder != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await(await folder.CreateFileAsync("VDownloadLocationAccessTest")).DeleteAsync();
|
||||
ApplyToAllLocation = folder;
|
||||
AddPlaylistLocationSelectionLocationTextBlock.Text = ApplyToAllLocation.Path[ApplyToAllLocation.Path.Length - 1] == '\\' ? ApplyToAllLocation.Path : ApplyToAllLocation.Path + '\\';
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
// APPLY LOCATION
|
||||
private void AddPlaylistLocationSelectionApplyLocationButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (KeyValuePair<VObject, TextBlock> v in Playlist.VObjects)
|
||||
{
|
||||
if (ApplyToAllLocation != null)
|
||||
{
|
||||
v.Key.CustomSaveLocation = ApplyToAllLocation;
|
||||
v.Value.Text = v.Key.CustomSaveLocation.Path;
|
||||
v.Key.FilePath = $@"{(v.Key.CustomSaveLocation.Path[v.Key.CustomSaveLocation.Path.Length - 1] == '\\' ? v.Key.CustomSaveLocation.Path : v.Key.CustomSaveLocation.Path + '\\')}{v.Key.Filename}.{v.Key.Extension.ToLower()}";
|
||||
}
|
||||
else
|
||||
{
|
||||
v.Key.CustomSaveLocation = null;
|
||||
v.Value.Text = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\";
|
||||
v.Key.FilePath = $@"{UserDataPaths.GetDefault().Downloads}\VDownload\{v.Key.Filename}.{v.Key.Extension.ToLower()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
22
VDownload/Views/AddPlaylist/AddPlaylistNotFound.xaml
Normal file
22
VDownload/Views/AddPlaylist/AddPlaylistNotFound.xaml
Normal file
@@ -0,0 +1,22 @@
|
||||
<Page
|
||||
x:Class="VDownload.Views.AddPlaylist.AddPlaylistNotFound"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:VDownload.Views.AddPlaylist"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
Height="500"
|
||||
Width="498">
|
||||
|
||||
<!-- MESSAGE -->
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="AddPlaylistNotFoundImage" HorizontalAlignment="Center" Height="100" VerticalAlignment="Center" Width="100" Source="/Assets/Icons/Add/NotFound.png" Grid.Row="0"/>
|
||||
<TextBlock x:Name="AddPlaylistNotFoundText" x:Uid="AddPlaylistNotFoundText" HorizontalAlignment="Center" Text="Playlist not found. Try again." TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#AAAAAA" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
13
VDownload/Views/AddPlaylist/AddPlaylistNotFound.xaml.cs
Normal file
13
VDownload/Views/AddPlaylist/AddPlaylistNotFound.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
// System
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace VDownload.Views.AddPlaylist
|
||||
{
|
||||
public sealed partial class AddPlaylistNotFound : Page
|
||||
{
|
||||
public AddPlaylistNotFound()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
22
VDownload/Views/AddPlaylist/AddPlaylistStart.xaml
Normal file
22
VDownload/Views/AddPlaylist/AddPlaylistStart.xaml
Normal file
@@ -0,0 +1,22 @@
|
||||
<Page
|
||||
x:Class="VDownload.Views.AddPlaylist.AddPlaylistStart"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:VDownload.Views.AddPlaylist"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
Height="500"
|
||||
Width="498">
|
||||
|
||||
<!-- MESSAGE -->
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="AddPlaylistStartImage" HorizontalAlignment="Center" Height="100" VerticalAlignment="Center" Width="100" Source="/Assets/Icons/Add/Start.png" Grid.Row="0"/>
|
||||
<TextBlock x:Name="AddPlaylistStartText" x:Uid="AddPlaylistStartText" HorizontalAlignment="Center" Text="Paste URL and click "Search" button" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#AAAAAA" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
13
VDownload/Views/AddPlaylist/AddPlaylistStart.xaml.cs
Normal file
13
VDownload/Views/AddPlaylist/AddPlaylistStart.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
// System
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace VDownload.Views.AddPlaylist
|
||||
{
|
||||
public sealed partial class AddPlaylistStart : Page
|
||||
{
|
||||
public AddPlaylistStart()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,14 @@
|
||||
<Grid VerticalAlignment="Top" Width="498" Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="AddVideoUrlText" HorizontalAlignment="Left" Text="URL" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="0" Margin="0,0,10,0"/>
|
||||
<TextBox x:Name="AddVideoUrlTextBox" HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Column="1"/>
|
||||
<Button x:Name="AddVideoSearchButton" x:Uid="AddVideoSearchButton" Content="Search" VerticalAlignment="Center" Grid.Column="2" HorizontalAlignment="Right" Click="AddVideoSearchButton_Click" Margin="10,0,0,0"/>
|
||||
<TextBlock x:Name="AddVideoUrlText" HorizontalAlignment="Left" Text="URL" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="0"/>
|
||||
<TextBox x:Name="AddVideoUrlTextBox" HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Column="2"/>
|
||||
<Button x:Name="AddVideoSearchButton" x:Uid="AddVideoSearchButton" Content="Search" VerticalAlignment="Center" Grid.Column="4" HorizontalAlignment="Right" Click="AddVideoSearchButton_Click"/>
|
||||
</Grid>
|
||||
|
||||
<!-- CONTENT FRAME -->
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace VDownload.Views.AddVideo
|
||||
VObject video = new VObject(url);
|
||||
await video.GetMetadata();
|
||||
|
||||
// Navigate to video found page
|
||||
// Navigate to video main page
|
||||
AddVideoContent.Navigate(typeof(AddVideoMain), video);
|
||||
IsPrimaryButtonEnabled = true;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
<Grid VerticalAlignment="Center" Grid.Row="2" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="AddVideoLocationDataLocationTextBlock" Text="//Location" FontSize="11" VerticalAlignment="Center" Grid.Column="0"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="AddVideoNotFoundImage" HorizontalAlignment="Center" Height="100" VerticalAlignment="Center" Width="100" Source="/Assets/Icons/AddVideo/NotFound.png" Grid.Row="0"/>
|
||||
<Image x:Name="AddVideoNotFoundImage" HorizontalAlignment="Center" Height="100" VerticalAlignment="Center" Width="100" Source="/Assets/Icons/Add/NotFound.png" Grid.Row="0"/>
|
||||
<TextBlock x:Name="AddVideoNotFoundText" x:Uid="AddVideoNotFoundText" HorizontalAlignment="Center" Text="Video not found. Try again." TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#AAAAAA" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="AddVideoStartImage" HorizontalAlignment="Center" Height="100" VerticalAlignment="Center" Width="100" Source="/Assets/Icons/AddVideo/Start.png" Grid.Row="0"/>
|
||||
<Image x:Name="AddVideoStartImage" HorizontalAlignment="Center" Height="100" VerticalAlignment="Center" Width="100" Source="/Assets/Icons/Add/Start.png" Grid.Row="0"/>
|
||||
<TextBlock x:Name="AddVideoStartText" x:Uid="AddVideoStartText" HorizontalAlignment="Center" Text="Paste URL and click "Search" button" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#AAAAAA" Grid.Row="1"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
@@ -40,8 +41,9 @@
|
||||
<AppBarButton Grid.Column="0" x:Name="AppBarDownloadAllButton" x:Uid="AppBarDownloadAllButton" Click="AppBarDownloadAllButton_Click" Icon="Download" Label="Download All" Width="90"/>
|
||||
<AppBarSeparator Grid.Column="1" VerticalAlignment="Center" Height="50"/>
|
||||
<AppBarButton Grid.Column="2" x:Name="AppBarAddVideoButton" x:Uid="AppBarAddVideoButton" Click="AppBarAddVideoButton_Click" Icon="Add" Label="Add video" Width="75"/>
|
||||
<AppBarButton Grid.Column="3" x:Name="AppBarAddPlaylistButton" x:Uid="AppBarAddPlaylistButton" Click="AppBarAddPlaylistButton_Click" Icon="List" Label="Add playlist" Width="85"/>
|
||||
<!-- Right -->
|
||||
<AppBarButton Grid.Column="4" x:Name="AppBarSettingsButton" x:Uid="AppBarSettingsButton" Click="AppBarSettingsButton_Click" Icon="Setting" Label="Settings" Width="65"/>
|
||||
<AppBarButton Grid.Column="5" x:Name="AppBarSettingsButton" x:Uid="AppBarSettingsButton" Click="AppBarSettingsButton_Click" Icon="Setting" Label="Settings" Width="65"/>
|
||||
</Grid>
|
||||
|
||||
<!-- VIDEO PANEL -->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Internal
|
||||
using VDownload.Views.AddVideo;
|
||||
using VDownload.Views.AddPlaylist;
|
||||
using VDownload.Sources;
|
||||
using VDownload.Services;
|
||||
using VDownload.Objects.Enums;
|
||||
@@ -66,6 +67,27 @@ namespace VDownload
|
||||
}
|
||||
}
|
||||
|
||||
// ADD PLAYLIST BUTTON
|
||||
private async void AppBarAddPlaylistButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Create window
|
||||
AddPlaylistBase addPlaylistPage = new AddPlaylistBase();
|
||||
ContentDialogResult result = await addPlaylistPage.ShowAsync();
|
||||
|
||||
// Add videos to list
|
||||
if (result == ContentDialogResult.Primary)
|
||||
{
|
||||
// Get videos list
|
||||
VObject[] videos = (VObject[])addPlaylistPage.Content;
|
||||
|
||||
// Create and attach video panels
|
||||
foreach (VObject video in videos)
|
||||
{
|
||||
video.AddVideoToList(VideoPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SETTINGS BUTTON
|
||||
private void AppBarSettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user