Skip to content

Commit

Permalink
Add context menu to video/clip search mass downloaders (#876)
Browse files Browse the repository at this point in the history
* Add context menu to mass downloaders

* Update TaskData

* Update translations
  • Loading branch information
ScrubN authored Oct 28, 2023
1 parent 8104934 commit 2d64a7d
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 5 deletions.
28 changes: 28 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.

11 changes: 10 additions & 1 deletion TwitchDownloaderWPF/Translations/Strings.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Descarga FFmpeg {0}%</value>
</data>
</root>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Downloading FFmpeg {0}%</value>
</data>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copier l'identifiant vidéo</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copier le lien vidéo</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Ouvrir dans un navigateur web</value>
</data>
</root>
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Downloading FFmpeg {0}%</value>
</data>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Downloading FFmpeg {0}%</value>
</data>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Downloading FFmpeg {0}%</value>
</data>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
11 changes: 10 additions & 1 deletion TwitchDownloaderWPF/Translations/Strings.tr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>FFmpeg İndiriliyor {0}%</value>
</data>
</root>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.uk.resx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Завантаження FFmpeg {0}%</value>
</data>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,13 @@
<data name="StatusDownloaderFFmpeg" xml:space="preserve">
<value>Downloading FFmpeg {0}%</value>
</data>
<data name="CopyVideoIDToClipboard" xml:space="preserve">
<value>Copy ID to clipboard</value>
</data>
<data name="CopyVideoURLToClipboard" xml:space="preserve">
<value>Copy URL to clipboard</value>
</data>
<data name="OpenVideoInBrowser" xml:space="preserve">
<value>Open in browser</value>
</data>
</root>
2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/TwitchTasks/TaskData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public string LengthFormatted
return $"{time.Minutes:D2}:{time.Seconds:D2}";
}

return $"{time.Seconds:D2}s";
return $"{time.Seconds:D1}s";
}
}
}
Expand Down
22 changes: 21 additions & 1 deletion TwitchDownloaderWPF/WindowMassDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TwitchDownloaderWPF"
xmlns:behave="clr-namespace:TwitchDownloaderWPF.Behaviors"
xmlns:fa="http://schemas.fontawesome.com/icons/"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
lex:LocalizeDictionary.DesignCulture=""
lex:ResxLocalizationProvider.DefaultAssembly="TwitchDownloaderWPF"
Expand Down Expand Up @@ -52,7 +53,26 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderThickness="1" CornerRadius="8" Margin="0,0,8,8" Padding="4" MouseUp="Border_MouseUp" Initialized="Border_Initialized" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}">
<Border BorderThickness="1" CornerRadius="8" Margin="0,0,8,8" Padding="4" MouseLeftButtonUp="Border_OnMouseLeftButtonUp" Initialized="Border_Initialized" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}">
<Border.ContextMenu>
<ContextMenu>
<MenuItem Header="{lex:Loc CopyVideoIDToClipboard}" Click="MenuItemCopyVideoID_OnClick" Foreground="{DynamicResource AppText}">
<MenuItem.Icon>
<fa:SvgAwesome Icon="Solid_Copy" Foreground="{DynamicResource AppText}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{lex:Loc CopyVideoURLToClipboard}" Click="MenuItemCopyVideoUrl_OnClick" Foreground="{DynamicResource AppText}">
<MenuItem.Icon>
<fa:SvgAwesome Icon="Solid_Link" Foreground="{DynamicResource AppText}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{lex:Loc OpenVideoInBrowser}" Click="MenuItemOpenInBrowser_OnClick" Foreground="{DynamicResource AppText}">
<MenuItem.Icon>
<fa:SvgAwesome Icon="Solid_ExternalLinkAlt" Foreground="{DynamicResource AppText}" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Border.ContextMenu>
<StackPanel Orientation="Vertical" Width="220" Background="{DynamicResource AppElementBackground}">
<Image Source="{Binding Thumbnail}" MaxHeight="90"></Image>
<emoji:TextBlock TextWrapping="Wrap" MaxHeight="40" TextTrimming="CharacterEllipsis" Foreground="{DynamicResource AppText}">
Expand Down
41 changes: 40 additions & 1 deletion TwitchDownloaderWPF/WindowMassDownload.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -160,7 +161,7 @@ private async Task UpdateList()
if (StatusImage != null) StatusImage.Visibility = Visibility.Hidden;
}

private void Border_MouseUp(object sender, MouseButtonEventArgs e)
private void Border_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (sender is not Border border) return;
if (border.DataContext is not TaskData taskData) return;
Expand Down Expand Up @@ -271,5 +272,43 @@ private async void ComboVideoCount_SelectionChanged(object sender, SelectionChan
cursorIndex = -1;
await UpdateList();
}

private void MenuItemCopyVideoID_OnClick(object sender, RoutedEventArgs e)
{
if (sender is not MenuItem { DataContext: TaskData taskData }) return;

var id = taskData.Id;
Clipboard.SetText(id);

e.Handled = true;
}

private void MenuItemCopyVideoUrl_OnClick(object sender, RoutedEventArgs e)
{
if (sender is not MenuItem { DataContext: TaskData taskData }) return;

var id = taskData.Id;
var url = id.All(char.IsDigit)
? $"https://twitch.tv/videos/{id}"
: $"https://clips.twitch.tv/{id}";

Clipboard.SetText(url);

e.Handled = true;
}

private void MenuItemOpenInBrowser_OnClick(object sender, RoutedEventArgs e)
{
if (sender is not MenuItem { DataContext: TaskData taskData }) return;

var id = taskData.Id;
var url = id.All(char.IsDigit)
? $"https://twitch.tv/videos/{id}"
: $"https://clips.twitch.tv/{id}";

Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });

e.Handled = true;
}
}
}

0 comments on commit 2d64a7d

Please sign in to comment.