Skip to content

Commit

Permalink
Merge pull request #34 from ywmoyue/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ywmoyue authored Apr 6, 2023
2 parents e8b2de6 + 9a87f5d commit ba5892d
Show file tree
Hide file tree
Showing 28 changed files with 401 additions and 92 deletions.
6 changes: 3 additions & 3 deletions document/new_version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4.5.3",
"version_num": 40503,
"version_desc": "更新内容:\r\n\r\n* 支持视频详情页右侧标题可右键复制\r\n\r\n* 修复少部分视频打不开问题\r\n\r\n\r\n 如果无法打开下载地址,请访问:https://github.com/ywmoyue/biliuwp-lite/releases",
"version": "4.5.4",
"version_num": 40504,
"version_desc": "更新内容:\r\n\r\n* 首页推荐视频同时显示标签和up主名字\r\n\r\n* 添加搜索建议\r\n\r\n* 优化日志输出\r\n\r\n\r\n 如果无法打开下载地址,请访问:https://github.com/ywmoyue/biliuwp-lite/releases",
"url": "https://github.com/ywmoyue/biliuwp-lite/releases",
"download_url": "https://github.com/ywmoyue/biliuwp-lite/releases"
}
2 changes: 1 addition & 1 deletion src/BiliLite.Packages/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Identity
Name="5422.502643927C6AD"
Publisher="CN=muyan"
Version="4.5.3.0" />
Version="4.5.4.0" />
<mp:PhoneIdentity PhoneProductId="8bceed6a-7e89-4141-a693-923401d5b2ac" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
Expand Down
1 change: 1 addition & 0 deletions src/BiliLite.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public App()
FFmpegInteropLogging.SetLogLevel(LogLevel.Info);
FFmpegInteropLogging.SetLogProvider(this);
SqlHelper.InitDB();
LogHelper.Init();
this.Suspending += OnSuspending;
}
private void RegisterExceptionHandlingSynchronizationContext()
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Assets/Text/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ Webp图片扩展安装地址:[ms-windows-store://pdp/?productid=9PG2DK419DRG](ms

### 日志文件

路径:`%USERPROFILE%\AppData\Local\Packages\5421.502643927C6AD_wp9dg7z2zqgtj\LocalState\log`
路径:`%USERPROFILE%\AppData\Local\Packages\5422.502643927C6AD_vn31kc91nth4r\LocalState\log`

为了你的账号安全,发送日志时请一定要移除access_key=...里的内容
为了你的账号安全,发送日志时请一定要确保access_key/access_token/csrf=...里的内容已清除或已经被修改为{hasValue}

[点击打开日志存放目录](OpenLog)
11 changes: 11 additions & 0 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Extensions\ApiModelExtensions.cs" />
<Compile Include="Extensions\ExceptionExtensions.cs" />
<Compile Include="Extensions\HttpResultsExtensions.cs" />
<Compile Include="Extensions\ObservableCollectionExtension.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Models\Common\NavigationInfo.cs" />
<Compile Include="Models\Responses\HttpResults.cs" />
Expand All @@ -144,6 +146,7 @@
<Compile Include="Models\Common\CustomizedErrorException.cs" />
<Compile Include="Models\Common\Subtitle.cs" />
<Compile Include="Models\Requests\Api\AccountApi.cs" />
<Compile Include="Models\Responses\SearchSuggestResponse.cs" />
<Compile Include="Models\Responses\UserAttentionResponse.cs" />
<Compile Include="Services\ApiHelper.cs" />
<Compile Include="Models\Requests\Api\CommentApi.cs" />
Expand Down Expand Up @@ -277,6 +280,7 @@
<Compile Include="Extensions\ExceptionHandler.cs" />
<Compile Include="Extensions\StringHttpExtensions.cs" />
<Compile Include="Services\LogHelper.cs" />
<Compile Include="Services\LogService.cs" />
<Compile Include="Services\MessageCenter.cs" />
<Compile Include="Helpers\SettingHelper.cs" />
<Compile Include="Helpers\SqlHelper.cs" />
Expand Down Expand Up @@ -476,6 +480,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Models\Requests\ApiModel.cs" />
<Compile Include="Models\Common\ApiKeyInfo.cs" />
<Compile Include="Services\SearchService.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\GeeTest\bili_gt.html" />
Expand Down Expand Up @@ -596,6 +601,9 @@
<SubType>Designer</SubType>
</AppxManifest>
<None Include="BiliLite.UWP_TemporaryKey.pfx" />
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Package.StoreAssociation.xml" />
<Content Include="Assets\Wide310x150Logo.scale-100.png" />
<Content Include="Assets\Wide310x150Logo.scale-125.png" />
Expand Down Expand Up @@ -876,6 +884,9 @@
<PackageReference Include="Google.Protobuf">
<Version>3.19.4</Version>
</PackageReference>
<PackageReference Include="log4net">
<Version>2.0.15</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.10</Version>
</PackageReference>
Expand Down
16 changes: 16 additions & 0 deletions src/BiliLite.UWP/Extensions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliLite.Extensions
{
public static class ExceptionExtensions
{
public static bool IsNetworkError(this Exception ex)
{
return ex.HResult == -2147012867 || ex.HResult == -2147012889;
}
}
}
27 changes: 27 additions & 0 deletions src/BiliLite.UWP/Extensions/ObservableCollectionExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace BiliLite.Extensions
{
public static class ObservableCollectionExtension
{
public static void AddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> range)
{
if (range == null) return;
foreach (var item in range)
{
collection.Add(item);
}
}

public static void ReplaceRange<T>(this ObservableCollection<T> collection, IEnumerable<T> range)
{
if (range == null) return;
collection.Clear();
foreach (var item in range)
{
collection.Add(item);
}
}
}
}
11 changes: 11 additions & 0 deletions src/BiliLite.UWP/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ public static RichTextBlock ToRichTextBlock(this string txt, JObject emote)
}
}

public static string ProtectValues(this string url, params string[] keys)
{
foreach (string key in keys)
{
string pattern = $@"({key}=)([^&]*)";
string replacement = $"$1{{hasValue}}";
url = Regex.Replace(url, pattern, replacement);
}
return url;
}

#region Private methods

/// <summary>
Expand Down
18 changes: 18 additions & 0 deletions src/BiliLite.UWP/Helpers/SettingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,5 +535,23 @@ public class Download
public const string DEFAULT_VIDEO_TYPE = "DownloadDefaultVideoType";

}

public class Other
{
/// <summary>
/// 自动清理日志文件
/// </summary>
public const string AUTO_CLEAR_LOG_FILE = "autoClearLogFile";

/// <summary>
/// 自动清理多少天前的日志文件
/// </summary>
public const string AUTO_CLEAR_LOG_FILE_DAY = "autoClearLogFileDay";

/// <summary>
/// 保护日志敏感信息
/// </summary>
public const string PROTECT_LOG_INFO = "protectLogInfo";
}
}
}
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ protected async override void OnNavigatedTo(NavigationEventArgs e)
Utils.ShowMessageToast("无法打开链接:" + e.Parameter.ToString());
}
}
//#if !DEBUG
#if !DEBUG
await Utils.CheckVersion();
//#endif
#endif
}

private void MessageCenter_ChangeTitleEvent(object sender, string e)
Expand Down
11 changes: 11 additions & 0 deletions src/BiliLite.UWP/Models/Requests/Api/SearchAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,16 @@ public ApiModel WebSearchTopic(string keyword, int pn = 1, string area = "")
}
return api;
}

public ApiModel SearchSuggest(string content)
{
var api = new ApiModel()
{
method = RestSharp.Method.Get,
baseUrl = $"https://s.search.bilibili.com/main/suggest",
parameter = $"term={content}&main_ver=v1"
};
return api;
}
}
}
10 changes: 9 additions & 1 deletion src/BiliLite.UWP/Models/Requests/BiliRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,21 @@ private HttpResults ConstructRedirectResults(IFlurlResponse response)
return httpResults;
}

private async Task LogRequest()
{
var body = "";
if (m_body != null)
body = await m_body?.ReadAsStringAsync();
LogHelper.Log($"http request: [{m_method}]{m_url} {body}", LogType.INFO);
}

public async Task<HttpResults> Send()
{
await LogRequest();
IFlurlResponse response = null;
HttpResults httpResults;
try
{

if (m_method == HttpMethod.Get)
{
response = await m_request.GetAsync();
Expand Down
14 changes: 14 additions & 0 deletions src/BiliLite.UWP/Models/Responses/SearchSuggestResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace BiliLite.Models.Responses
{
public class SearchSuggestResponse
{
public List<SearchSuggestResponseTag> Tag { get; set; }
}

public class SearchSuggestResponseTag
{
public string Value { get; set; }
}
}
14 changes: 10 additions & 4 deletions src/BiliLite.UWP/Modules/Home/HomeVM.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using BiliLite.Helpers;
using BiliLite.Models;
using FontAwesome5;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
using System.Collections.ObjectModel;

namespace BiliLite.Modules
Expand Down Expand Up @@ -170,6 +166,16 @@ public async Task LoginUserCard()

}

private ObservableCollection<string> m_suggestSearchContents;

public ObservableCollection<string> SuggestSearchContents
{
get => m_suggestSearchContents;
set {
m_suggestSearchContents = value;
DoPropertyChanged("SuggestSearchContents");
}
}
}
public class HomeNavItem : IModules
{
Expand Down
6 changes: 1 addition & 5 deletions src/BiliLite.UWP/Modules/Home/RecommendVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,7 @@ public string bottomText
{
return desc_button.text;
}
if (card_goto=="live")
{
return args.up_name;
}
return "";
return args.up_name;
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/BiliLite.UWP/Modules/IModules.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using BiliLite.Models;
using BiliLite.Extensions;
using BiliLite.Models;
using BiliLite.Models.Common;
using BiliLite.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;

namespace BiliLite.Modules
{
public class IModules : INotifyPropertyChanged
{
public virtual ReturnModel<T> HandelError<T>(Exception ex)
{
if (LogHelper.IsNetworkError(ex))
if (ex.IsNetworkError())
{
return new ReturnModel<T>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using BiliLite.gRPC.Api;
using Proto.Reply;
using BiliLite.Models.Requests.Api;
using BiliLite.Services;

namespace BiliLite.Modules.Player.Playurl
{
Expand Down Expand Up @@ -688,7 +689,6 @@ private async Task<BiliPlayUrlQualitesInfo> GetPlayUrlUseWebApi(PlayInfo playInf
}
catch (Exception ex)
{

return BiliPlayUrlQualitesInfo.Failure(ex.Message);
}

Expand Down
12 changes: 12 additions & 0 deletions src/BiliLite.UWP/Modules/SearchVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public bool ShowLoadMore
get { return _ShowLoadMore; }
set { _ShowLoadMore = value; DoPropertyChanged("ShowLoadMore"); }
}

public async virtual void Refresh()
{
HasData = false;
Expand Down Expand Up @@ -161,6 +162,17 @@ public ISearchVM SelectItem
set { _SelectItem = value; }
}

private ObservableCollection<string> m_suggestSearchContents;

public ObservableCollection<string> SuggestSearchContents
{
get => m_suggestSearchContents;
set
{
m_suggestSearchContents = value;
DoPropertyChanged("SuggestSearchContents");
}
}
}
public class SearchVideoVM : ISearchVM
{
Expand Down
8 changes: 7 additions & 1 deletion src/BiliLite.UWP/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
PaneDisplayMode="Top"
IsBackButtonVisible="Collapsed" >
<winui:NavigationView.AutoSuggestBox>
<AutoSuggestBox x:Name="SearchBox" QuerySubmitted="SearchBox_QuerySubmitted" MinWidth="140" PlaceholderText="你想找什么呢?" QueryIcon="Find"></AutoSuggestBox>
<AutoSuggestBox x:Name="SearchBox"
TextChanged="SearchBox_TextChanged"
QuerySubmitted="SearchBox_QuerySubmitted"
MinWidth="140"
PlaceholderText="你想找什么呢?"
ItemsSource="{x:Bind Path=homeVM.SuggestSearchContents,Mode=OneWay}"
QueryIcon="Find"></AutoSuggestBox>
</winui:NavigationView.AutoSuggestBox>
<winui:NavigationView.PaneFooter>
<StackPanel Margin="-8 0 0 0" Orientation="Horizontal">
Expand Down
Loading

0 comments on commit ba5892d

Please sign in to comment.