Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add videos per page selector to mass downloaders #837

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion TwitchDownloaderWPF/PageQueue.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TwitchDownloaderWPF"
xmlns:task="clr-namespace:TwitchDownloaderWPF.TwitchTasks"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
lex:LocalizeDictionary.DesignCulture=""
lex:ResxLocalizationProvider.DefaultAssembly="TwitchDownloaderWPF"
Expand Down
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -772,4 +772,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Unable to start Windows application theme watcher. Error code: {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Videos per page:</value>
</data>
</root>
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Impossible de démarrer l'observateur de thème de l'application Windows. Code d'erreur : {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Vidéos par page:</value>
</data>
</root>
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Unable to start Windows application theme watcher. Error code: {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Videos per page:</value>
</data>
</root>
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -770,4 +770,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Unable to start Windows application theme watcher. Error code: {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Videos per page:</value>
</data>
</root>
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Unable to start Windows application theme watcher. Error code: {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Videos per page:</value>
</data>
</root>
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.tr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -772,4 +772,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Unable to start Windows application theme watcher. Error code: {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Videos per page:</value>
</data>
</root>
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -770,4 +770,7 @@
<data name="UnableToStartWindowsThemeWatcher" xml:space="preserve">
<value>Unable to start Windows application theme watcher. Error code: {0}</value>
</data>
<data name="LabelVideosPerPage" xml:space="preserve">
<value>Videos per page:</value>
</data>
</root>
16 changes: 11 additions & 5 deletions TwitchDownloaderWPF/WindowMassDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TwitchDownloaderWPF"
xmlns:task="clr-namespace:TwitchDownloaderWPF.TwitchTasks"
xmlns:behave="clr-namespace:TwitchDownloaderWPF.Behaviors"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
lex:LocalizeDictionary.DesignCulture=""
Expand All @@ -22,20 +21,27 @@

<Grid Background="{DynamicResource AppBackground}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
<Label x:Name="labelSort" Content="{lex:Loc Sort}" Margin="10,6,0,0" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
<ComboBox SelectedIndex="2" x:Name="comboSort" Margin="5,6,0,0" MinWidth="120" SelectionChanged="comboSort_SelectionChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
<Label x:Name="LabelSort" Content="{lex:Loc Sort}" Margin="6,6,0,0" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
<ComboBox SelectedIndex="2" x:Name="ComboSortByDate" Margin="5,6,0,0" MinWidth="120" SelectionChanged="ComboSortByDate_SelectionChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
<ComboBoxItem Content="{lex:Loc TopTwentyFourHours}" Tag="LAST_DAY"/>
<ComboBoxItem Content="{lex:Loc TopSevenDays}" Tag="LAST_WEEK"/>
<ComboBoxItem Content="{lex:Loc TopThirtyDays}" Tag="LAST_MONTH"/>
<ComboBoxItem Content="{lex:Loc TopAllTime}" Tag="ALL_TIME"/>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
<TextBox x:Name="textChannel" Height="23" TextWrapping="Wrap" Text="" Width="194" Margin="0,6,0,0" KeyDown="TextChannel_OnKeyDown" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<Image x:Name="StatusImage" gif:ImageBehavior.AnimatedSource="Images/ppOverheat.gif" MaxWidth="50" Margin="0, 6, 6, 0" Visibility="Hidden" />
<TextBox x:Name="textChannel" Height="23" Text="" MinWidth="194" MaxWidth="300" Margin="0,6,0,0" KeyDown="TextChannel_OnKeyDown" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<Button x:Name="btnChannel" Content="{lex:Loc SetChannel}" Margin="3,6,0,0" MinWidth="84" Height="30" Click="btnChannel_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
<Image x:Name="StatusImage" gif:ImageBehavior.AnimatedSource="Images/ppOverheat.gif" MaxWidth="50" Margin="0, 6, 6, 0" Visibility="Collapsed" />
<Label x:Name="LabelVideoCount" Content="{lex:Loc LabelVideosPerPage}" Margin="6,6,0,0" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
<ComboBox SelectedIndex="1" x:Name="ComboVideoCount" Margin="5,6,6,0" MinWidth="70" SelectionChanged="ComboVideoCount_SelectionChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
<ComboBoxItem Content="16" />
<ComboBoxItem Content="30" />
<ComboBoxItem Content="50" />
<ComboBoxItem Content="100" />
</ComboBox>
</StackPanel>
<ScrollViewer x:Name="scrollDownload" VerticalScrollBarVisibility="Auto" Margin="10,41,10,45">
<ItemsControl x:Name="itemList" ItemsSource="{Binding videoList}" d:DataContext="{d:DesignInstance local:WindowMassDownload}">
Expand Down
35 changes: 28 additions & 7 deletions TwitchDownloaderWPF/WindowMassDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class WindowMassDownload : Window
public int cursorIndex = -1;
public string currentChannel = "";
public string period = "";
public int videoCount = 50;

public WindowMassDownload(DownloadType type)
{
Expand All @@ -35,8 +36,8 @@ public WindowMassDownload(DownloadType type)
itemList.ItemsSource = videoList;
if (downloaderType == DownloadType.Video)
{
comboSort.Visibility = Visibility.Hidden;
labelSort.Visibility = Visibility.Hidden;
ComboSortByDate.Visibility = Visibility.Hidden;
LabelSort.Visibility = Visibility.Hidden;
}
btnNext.IsEnabled = false;
btnPrev.IsEnabled = false;
Expand All @@ -60,14 +61,25 @@ private async Task UpdateList()
{
if (StatusImage != null) StatusImage.Visibility = Visibility.Visible;

if (string.IsNullOrWhiteSpace(currentChannel))
{
// Pretend we are doing something so the status icon has time to show
await Task.Delay(50);
videoList.Clear();
cursorList.Clear();
cursorIndex = -1;
if (StatusImage != null) StatusImage.Visibility = Visibility.Hidden;
return;
}

if (downloaderType == DownloadType.Video)
{
string currentCursor = "";
if (cursorList.Count > 0 && cursorIndex >= 0)
{
currentCursor = cursorList[cursorIndex];
}
GqlVideoSearchResponse res = await TwitchHelper.GetGqlVideos(currentChannel, currentCursor, 50);
GqlVideoSearchResponse res = await TwitchHelper.GetGqlVideos(currentChannel, currentCursor, videoCount);
videoList.Clear();
if (res.data.user != null)
{
Expand Down Expand Up @@ -109,7 +121,7 @@ private async Task UpdateList()
{
currentCursor = cursorList[cursorIndex];
}
GqlClipSearchResponse res = await TwitchHelper.GetGqlClips(currentChannel, period, currentCursor, 50);
GqlClipSearchResponse res = await TwitchHelper.GetGqlClips(currentChannel, period, currentCursor, videoCount);
videoList.Clear();
if (res.data.user != null)
{
Expand Down Expand Up @@ -145,7 +157,7 @@ private async Task UpdateList()
}
}

if (StatusImage != null) StatusImage.Visibility = Visibility.Collapsed;
if (StatusImage != null) StatusImage.Visibility = Visibility.Hidden;
}

private void Border_MouseUp(object sender, MouseButtonEventArgs e)
Expand Down Expand Up @@ -203,9 +215,9 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
}
}

private async void comboSort_SelectionChanged(object sender, SelectionChangedEventArgs e)
private async void ComboSortByDate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
period = ((ComboBoxItem)comboSort.SelectedItem).Tag.ToString();
period = ((ComboBoxItem)ComboSortByDate.SelectedItem).Tag.ToString();
videoList.Clear();
cursorList.Clear();
cursorIndex = -1;
Expand Down Expand Up @@ -250,5 +262,14 @@ private async void TextChannel_OnKeyDown(object sender, KeyEventArgs e)
e.Handled = true;
}
}

private async void ComboVideoCount_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
videoCount = int.Parse((string)((ComboBoxItem)ComboVideoCount.SelectedValue).Content);
videoList.Clear();
cursorList.Clear();
cursorIndex = -1;
await UpdateList();
}
}
}