Now can download videos
This commit is contained in:
@@ -9,28 +9,9 @@
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Grid Padding="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<TextBlock FontSize="28" Text="Downloads"/>
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Name="openFolder" Click="openFolder_Click" Content="Open folder" Margin="5"/>
|
||||
<TextBlock Name="path" IsTextSelectionEnabled="True" Grid.Column="1" Text="C://Users/Admin/Downloads" VerticalAlignment="Center"/>
|
||||
<Button Name="changePath" Click="changePath_Click" Grid.Column="2" Content="Change path" Margin="5"/>
|
||||
</Grid>
|
||||
<ItemsControl Name="stack"/>
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<StackPanel Margin="5" Name="stack">
|
||||
<ListView ItemsSource="{Binding Path=Methods.MainPage.agent.items}" SelectionMode="None"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
|
||||
@@ -22,14 +22,13 @@ namespace FoxTube.Pages
|
||||
/// </summary>
|
||||
public sealed partial class Downloads : Page
|
||||
{
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
public Downloads()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
path.Text = settings.Values["defaultDownload"] as string;
|
||||
stack.ItemsSource = Methods.MainPage.Agent.items;
|
||||
}
|
||||
|
||||
private async void changePath_Click(object sender, RoutedEventArgs e)
|
||||
/*private async void changePath_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FolderPicker picker = new FolderPicker()
|
||||
{
|
||||
@@ -42,11 +41,6 @@ namespace FoxTube.Pages
|
||||
if (p != null)
|
||||
settings.Values["defaultDownload"] = p.Path;
|
||||
path.Text = settings.Values["defaultDownload"] as string;
|
||||
}
|
||||
|
||||
private async void openFolder_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Launcher.LaunchFolderAsync( await StorageFolder.GetFolderFromPathAsync(settings.Values["defaultDownload"] as string));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ using System.Net;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.Networking.Connectivity;
|
||||
using Windows.UI.Core;
|
||||
using Syroot.Windows.IO;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
@@ -72,9 +71,6 @@ namespace FoxTube
|
||||
if (settings.Values["safeSearch"] == null)
|
||||
settings.Values.Add("safeSearch", 0);
|
||||
|
||||
if (settings.Values["defaultDownload"] == null)
|
||||
settings.Values.Add("defaultDownload", Syroot.Windows.IO.KnownFolders.Downloads.Path + "\\DownloadedVideos");
|
||||
|
||||
if (settings.Values["notificationsHistory"] == null)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace FoxTube.Pages.SettingsPages
|
||||
this.InitializeComponent();
|
||||
|
||||
language.SelectedIndex = (string)settings.Values["language"] == "en-US"? 0 : 1;
|
||||
quality.SelectedIndex = (int)settings.Values["quality"];
|
||||
quality.SelectedItem = quality.Items.ToList().Find(x => (x as ComboBoxItem).Tag as string == (string)settings.Values["quality"]);
|
||||
|
||||
newVideo.IsOn = (bool)settings.Values["newVideoNotification"];
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ using Windows.ApplicationModel;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI;
|
||||
using FoxTube.Controls;
|
||||
using YoutubeExplode.Models.MediaStreams;
|
||||
using YoutubeExplode;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
@@ -235,38 +237,30 @@ namespace FoxTube.Pages
|
||||
|
||||
async void LoadDownloads()
|
||||
{
|
||||
/*List<YouTubeUri> uris = (await YouTube.GetUrisAsync(item.Id)).ToList();
|
||||
if (uris.Count > 0)
|
||||
foreach (YouTubeUri u in uris)
|
||||
MediaStreamInfoSet infoSet = await new YoutubeClient().GetVideoMediaStreamInfosAsync(videoId);
|
||||
foreach(MuxedStreamInfo i in infoSet.Muxed)
|
||||
{
|
||||
MenuFlyoutItem menuItem = new MenuFlyoutItem()
|
||||
{
|
||||
if (u.HasAudio && u.HasVideo)
|
||||
{
|
||||
MenuFlyoutItem menuItem = new MenuFlyoutItem()
|
||||
{
|
||||
Text = Methods.QualityToString(u.VideoQuality),
|
||||
Tag = u.Uri.AbsoluteUri
|
||||
};
|
||||
menuItem.Click += downloadItemSelected;
|
||||
downloadSelector.Items.Add(menuItem);
|
||||
}
|
||||
else if (u.HasAudio)
|
||||
{
|
||||
MenuFlyoutItem menuItem = new MenuFlyoutItem()
|
||||
{
|
||||
Text = Methods.QualityToString(u.AudioQuality),
|
||||
Tag = u.Uri.AbsoluteUri
|
||||
};
|
||||
menuItem.Click += downloadItemSelected;
|
||||
downloadSelector.Items.Add(menuItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
download.Visibility = Visibility.Collapsed;*/
|
||||
Text = i.VideoQualityLabel,
|
||||
Tag = new object[] { i, i.VideoQualityLabel }
|
||||
};
|
||||
menuItem.Click += downloadItemSelected;
|
||||
downloadSelector.Items.Add(menuItem);
|
||||
}
|
||||
|
||||
MenuFlyoutItem audioItem = new MenuFlyoutItem()
|
||||
{
|
||||
Text = "Audio track",
|
||||
Tag = new object[] { infoSet.Audio[0], "Audio only" }
|
||||
};
|
||||
audioItem.Click += downloadItemSelected;
|
||||
downloadSelector.Items.Add(audioItem);
|
||||
}
|
||||
|
||||
private void downloadItemSelected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.Agent.Add((sender as MenuFlyoutItem).Tag.ToString());
|
||||
Methods.MainPage.Agent.Add(((sender as MenuFlyoutItem).Tag as object[])[0] as MediaStreamInfo, item, ((sender as MenuFlyoutItem).Tag as object[])[1] as string);
|
||||
}
|
||||
|
||||
async void LoadRelatedVideos()
|
||||
|
||||
Reference in New Issue
Block a user