Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* https://github.com/leiurayer/downkyi:
  更新UP主空间API leiurayer#722 leiurayer#730
  发布v1.5.8
  微调UI
  注释调整
  优化打开文件夹,之前因为后缀名问题,打开失败
  fix bug:Issues 下载管理在只下载音频的情况下点击打开文件夹没反应 leiurayer#709
  修复因为浅拷贝,导致用于查询的CaCheVideoSections数据变化所引起的bug
  增加搜索功能
  增加搜索功能
  增加CaCheVideoSections
  增加输入事件
  视频详情页面增加搜索框,并增加多语言
  • Loading branch information
github-actions[bot] committed Apr 30, 2023
2 parents 5e1ebeb + 29b154a commit 1691a49
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 13 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# 更新日志

## `2023/04/30` v1.5.8

* [新增] 视频详情页搜索功能。
* [优化] 确认下载路径之前检查盘符是否存在。
* [优化] 弹出框的UI。
* [优化] 音质描述【普通音质有3档质量,但不是固定的320K或192K,因此仅用高中低表述,以免产生误解】。
* [修复] 下载管理在只下载音频的情况下点击打开文件夹无响应。
* [修复] 解决tabId溢出的问题。

## `2023/02/18` v1.5.7

* [新增] 自定义UserAgent。
Expand Down
2 changes: 1 addition & 1 deletion src/DownKyi.Core/BiliApi/Users/UserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static UserInfoForNavigation GetUserInfoForNavigation()
/// <returns></returns>
public static UserInfoForSpace GetUserInfoForSpace(long mid)
{
string url = $"https://api.bilibili.com/x/space/acc/info?mid={mid}";
string url = $"https://api.bilibili.com/x/space/wbi/acc/info?mid={mid}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);

Expand Down
2 changes: 1 addition & 1 deletion src/DownKyi.Core/BiliApi/Users/UserSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static List<SpacePublicationListVideo> GetAllPublication(long mid, int ti
/// <returns></returns>
public static SpacePublicationList GetPublication(long mid, int pn, int ps, long tid = 0, PublicationOrder order = PublicationOrder.PUBDATE, string keyword = "")
{
string url = $"https://api.bilibili.com/x/space/arc/search?mid={mid}&pn={pn}&ps={ps}&order={order.ToString("G").ToLower()}&tid={tid}&keyword={keyword}";
string url = $"https://api.bilibili.com/x/space/wbi/arc/search?mid={mid}&pn={pn}&ps={ps}&order={order.ToString("G").ToLower()}&tid={tid}&keyword={keyword}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);

Expand Down
4 changes: 2 additions & 2 deletions src/DownKyi.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.7.0")]
[assembly: AssemblyFileVersion("2.1.7.0")]
[assembly: AssemblyVersion("2.1.8.0")]
[assembly: AssemblyFileVersion("2.1.8.0")]
2 changes: 2 additions & 0 deletions src/DownKyi/Languages/Default.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<system:String x:Key="VideoCodec">视频编码</system:String>

<system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String>
<system:String x:Key="DownloadSelected">下载选中项</system:String>
Expand Down
4 changes: 3 additions & 1 deletion src/DownKyi/Languages/en_US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
<system:String x:Key="AudioQuality">音质</system:String>
<system:String x:Key="VideoQuality">画质</system:String>
<system:String x:Key="VideoCodec">视频编码</system:String>


<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String>
Expand Down
2 changes: 2 additions & 0 deletions src/DownKyi/Languages/zh_CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<system:String x:Key="VideoQuality">画质</system:String>
<system:String x:Key="VideoCodec">视频编码</system:String>

<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String>
Expand Down
2 changes: 2 additions & 0 deletions src/DownKyi/Languages/zh_TW.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<system:String x:Key="VideoQuality">画质</system:String>
<system:String x:Key="VideoCodec">视频编码</system:String>

<system:String x:Key="Search">搜索</system:String>
<system:String x:Key="SearchVideoByName">搜索视频名称</system:String>
<system:String x:Key="SelectAll">全选</system:String>
<system:String x:Key="Parse">解析</system:String>
<system:String x:Key="ParseVideo">解析视频</system:String>
Expand Down
2 changes: 1 addition & 1 deletion src/DownKyi/Models/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AppInfo

const int a = 1;
const int b = 5;
const int c = 7;
const int c = 8;

public AppInfo()
{
Expand Down
4 changes: 2 additions & 2 deletions src/DownKyi/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.7.0")]
[assembly: AssemblyFileVersion("1.5.7.0")]
[assembly: AssemblyVersion("1.5.8.0")]
[assembly: AssemblyFileVersion("1.5.8.0")]
2 changes: 2 additions & 0 deletions src/DownKyi/Services/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ internal static void VideoPageInfo(PlayUrl playUrl, VideoPage page)

// 时长
page.Duration = Format.FormatDuration(playUrl.Dash.Duration);

return;
}
}

Expand Down
21 changes: 19 additions & 2 deletions src/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Prism.Commands;
using Prism.Services.Dialogs;
using System.IO;
using System.Linq;

namespace DownKyi.ViewModels.DownloadManager
{
Expand Down Expand Up @@ -91,8 +92,24 @@ public VectorImage RemoveVideo
private void ExecuteOpenFolderCommand()
{
if (DownloadBase == null) { return; }

string videoPath = $"{DownloadBase.FilePath}.mp4";
//TODO:这里不光有mp4视频文件,也可能存在音频文件、字幕,或者其他文件类型
//fix bug:Issues #709
//这里根据需要下载的类型判断,具体对应的文件后缀名
var downLoadContents = DownloadBase.NeedDownloadContent.Where(e => e.Value == true).Select(e => e.Key);
string fileSuffix = string.Empty;
if (downLoadContents.Contains("downloadVideo"))
{
fileSuffix = ".mp4";
}
else if (downLoadContents.Contains("downloadAudio"))
{
fileSuffix = ".aac";
}
else if (downLoadContents.Contains("downloadCover"))
{
fileSuffix = ".jpg";
}
string videoPath = $"{DownloadBase.FilePath}{fileSuffix}";
FileInfo fileInfo = new FileInfo(videoPath);
if (File.Exists(fileInfo.FullName))
{
Expand Down
62 changes: 59 additions & 3 deletions src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
using DownKyi.Utils;
using DownKyi.ViewModels.Dialogs;
using DownKyi.ViewModels.PageViewModels;
using Newtonsoft.Json;
using Prism.Commands;
using Prism.Events;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -46,7 +49,13 @@ public string InputText
get => inputText;
set => SetProperty(ref inputText, value);
}
private string inputSearchText;

public string InputSearchText
{
get => inputSearchText;
set => SetProperty(ref inputSearchText, value);
}
private GifImage loading;
public GifImage Loading
{
Expand Down Expand Up @@ -81,7 +90,7 @@ public ObservableCollection<VideoSection> VideoSections
get => videoSections;
set => SetProperty(ref videoSections, value);
}

public ObservableCollection<VideoSection> CaCheVideoSections { get; set; }
private bool isSelectAll;
public bool IsSelectAll
{
Expand Down Expand Up @@ -125,7 +134,7 @@ public ViewVideoDetailViewModel(IEventAggregator eventAggregator, IDialogService
DownloadManage.Fill = DictionaryResource.GetColor("ColorPrimary");

VideoSections = new ObservableCollection<VideoSection>();

CaCheVideoSections = new ObservableCollection<VideoSection>();
#endregion
}

Expand Down Expand Up @@ -172,6 +181,41 @@ private void ExecuteDownloadManagerCommand()
private DelegateCommand inputCommand;
public DelegateCommand InputCommand => inputCommand ?? (inputCommand = new DelegateCommand(ExecuteInputCommand, CanExecuteInputCommand));


private DelegateCommand inputSearchCommand;

public DelegateCommand InputSearchCommand => inputSearchCommand ?? (inputSearchCommand = new DelegateCommand(ExcuteInputSearchCommand));
/// <summary>
/// 搜索视频输入时间
/// </summary>
private async void ExcuteInputSearchCommand() {
await Task.Run(() =>
{
if (InputSearchText == null || InputSearchText == string.Empty)
{
foreach (VideoSection section in VideoSections) {
var cache= CaCheVideoSections.FirstOrDefault(e=>e.Id==section.Id);
if (cache!=null)
{
section.VideoPages=cache.VideoPages;
}
}
}
else
{
foreach (VideoSection section in VideoSections)
{
var cache = CaCheVideoSections.FirstOrDefault(e => e.Id == section.Id);
if (cache != null)
{
var pages = cache.VideoPages.Where(e => e.Name.Contains(InputSearchText)).ToList();
section.VideoPages = pages;
}

}
}
});
}
/// <summary>
/// 处理输入事件
/// </summary>
Expand Down Expand Up @@ -582,6 +626,7 @@ private void InitView()
NoDataVisibility = Visibility.Collapsed;

VideoSections.Clear();
CaCheVideoSections.Clear();
}

/// <summary>
Expand Down Expand Up @@ -642,6 +687,7 @@ private void UpdateView(IInfoService videoInfoService, VideoPage param)
PropertyChangeAsync(new Action(() =>
{
VideoSections.Clear();
CaCheVideoSections.Clear();
}));

// 添加新数据
Expand All @@ -660,17 +706,27 @@ private void UpdateView(IInfoService videoInfoService, VideoPage param)
IsSelected = true,
VideoPages = pages
});
CaCheVideoSections.Add(new VideoSection
{
Id = 0,
Title = "default",
IsSelected = true,
VideoPages = pages
});
}));
}
else
{
//这里如果浅拷贝会导致用于查询的CaCheVideoSections数据变化,所以这样处理
var videoSectionsStr = JsonConvert.SerializeObject(videoSections);
var videoSectionsData = JsonConvert.DeserializeObject<List<VideoSection>>(videoSectionsStr);
PropertyChangeAsync(new Action(() =>
{
VideoSections.AddRange(videoSections);
CaCheVideoSections.AddRange(videoSectionsData);
}));
}
}

/// <summary>
/// 解析视频流
/// </summary>
Expand Down
45 changes: 45 additions & 0 deletions src/DownKyi/Views/ViewVideoDetail.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,51 @@
<!--<CheckBox Grid.Column="1" Content="自动解析" IsChecked="False" Foreground="{DynamicResource BrushTextDark}" Style="{StaticResource CheckBoxStyle}" Margin="0 10 0 0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<CheckBox Grid.Column="2" Content="解析后自动下载所有" IsChecked="False" Foreground="{DynamicResource BrushTextDark}" Style="{StaticResource CheckBoxStyle}" Margin="0 10 0 0" VerticalAlignment="Top" HorizontalAlignment="Left"/>-->

<Label
Grid.Column="3"
Margin="9,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="{DynamicResource Search}" />
<TextBox
Grid.Column="3"
Width="200"
Height="25"
Margin="48,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
Text="{Binding Path=InputSearchText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextWrapping="Wrap">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding InputSearchCommand}" />
</TextBox.InputBindings>
<TextBox.Resources>
<VisualBrush
x:Key="HintText"
AlignmentX="Left"
Opacity="0.5"
Stretch="None"
TileMode="None">
<VisualBrush.Visual>
<TextBlock Text="{DynamicResource SearchVideoByName}" />
</VisualBrush.Visual>
</VisualBrush>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>

<Button
Grid.Column="4"
HorizontalAlignment="Right"
Expand Down

0 comments on commit 1691a49

Please sign in to comment.