Skip to content

Commit

Permalink
Merge pull request #502 from ywmoyue/dev
Browse files Browse the repository at this point in the history
4.6.26
  • Loading branch information
ywmoyue authored Feb 24, 2024
2 parents cd33463 + 0404b4a commit 36e5236
Show file tree
Hide file tree
Showing 64 changed files with 1,980 additions and 1,104 deletions.
Binary file modified document/_img/contributors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/BiliLite.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using BiliLite.ViewModels.Download;
using Microsoft.Extensions.DependencyInjection;

namespace BiliLite
{
Expand Down Expand Up @@ -181,8 +183,9 @@ private async void InitBili()
//圆角
App.Current.Resources["ImageCornerRadius"] = new CornerRadius(SettingService.GetValue<double>(SettingConstants.UI.IMAGE_CORNER_RADIUS, 0));
await AppHelper.SetRegions();
DownloadVM.Instance.LoadDownloading();
DownloadVM.Instance.LoadDownloaded();
var downloadViewModel = ServiceProvider.GetRequiredService<DownloadPageViewModel>();
downloadViewModel.LoadDownloading();
downloadViewModel.LoadDownloaded();
VideoPlayHistoryHelper.LoadABPlayHistories(true);
}

Expand Down
19 changes: 15 additions & 4 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<ItemGroup>
<Compile Include="Extensions\QrCodeExtensions.cs" />
<Compile Include="Models\Common\Anime\ISeasonItem.cs" />
<Compile Include="Models\Common\Dynamic\DynamicUgcSeasonCardModel.cs" />
<Compile Include="Models\Common\Home\DefaultHomeNavItems.cs" />
<Compile Include="Models\Common\Live\DefaultPlayUrlSourceOptions.cs" />
<Compile Include="Models\Common\Live\InteractWordModel.cs" />
<Compile Include="Models\Common\Live\LiveMessageHandleActionsMap.cs" />
Expand Down Expand Up @@ -183,12 +185,19 @@
<Compile Include="Models\Common\Live\GiftMsgModel.cs" />
<Compile Include="Models\Common\Live\GuardBuyMsgModel.cs" />
<Compile Include="Models\Common\Live\RoomChangeMsgModel.cs" />
<Compile Include="Models\Common\User\SearchHistoryData.cs" />
<Compile Include="Models\Common\User\SubmitCollectionItemModel.cs" />
<Compile Include="Models\Common\Video\BiliVideoTag.cs" />
<Compile Include="Models\Common\WbiKey.cs" />
<Compile Include="Models\Exceptions\NotFoundException.cs" />
<Compile Include="Models\Exceptions\CustomizedErrorWithDataException.cs" />
<Compile Include="Models\Exceptions\PlayerException.cs" />
<Compile Include="Models\Requests\Api\BaseApi.cs" />
<Compile Include="Models\Common\Download\DownloadedItem.cs" />
<Compile Include="Models\Common\Download\DownloadedSubItem.cs" />
<Compile Include="Models\Common\Home\HomeNavItem.cs" />
<Compile Include="ViewModels\Home\HomeNavItemViewModel.cs" />
<Compile Include="ViewModels\Download\DownloadingItemViewModel.cs" />
<Compile Include="Player\Controllers\BasePlayerController.cs" />
<Compile Include="Player\Controllers\LivePlayerController.cs" />
<Compile Include="Player\Controllers\PlayerControllerFactory.cs" />
Expand Down Expand Up @@ -232,6 +241,8 @@
<Compile Include="Services\QrCoderQrCodeService.cs" />
<Compile Include="Services\WbiKeyService.cs" />
<Compile Include="Services\ZXingQrCodeService.cs" />
<Compile Include="ViewModels\Download\DownloadingSubItemViewModel.cs" />
<Compile Include="ViewModels\Download\DownloadPageViewModel.cs" />
<Compile Include="ViewModels\Live\LiveDetailPageViewModel.cs" />
<Compile Include="ViewModels\Live\LiveRoomLotteryViewModel.cs" />
<Compile Include="ViewModels\Live\SuperChatMsgViewModel.cs" />
Expand All @@ -256,6 +267,7 @@
<Compile Include="Models\Common\Live\LiveRoomWebUrlUrlinfoItemModel.cs" />
<Compile Include="Models\Common\Live\LiveTitleModel.cs" />
<Compile Include="Models\Common\Live\LiveWalletInfo.cs" />
<Compile Include="ViewModels\PlayControlViewModel.cs" />
<Compile Include="ViewModels\UserDynamic\UserDynamicItemDisplayViewModel.cs" />
<Compile Include="Models\Common\UserDynamic\UserDynamicItemDisplayOneRowInfo.cs" />
<Compile Include="Models\Common\UserDynamic\UserDynamicItemDisplayImageInfo.cs" />
Expand Down Expand Up @@ -570,7 +582,6 @@
<Compile Include="Models\ReturnModel.cs" />
<Compile Include="Models\UserModels.cs" />
<Compile Include="Modules\Detail\FavoriteDetailVM.cs" />
<Compile Include="Modules\DownloadVM.cs" />
<Compile Include="Modules\EmoteVM.cs" />
<Compile Include="Modules\Home\RegionVM.cs" />
<Compile Include="Modules\Live\LiveAreaDetailVM.cs" />
Expand All @@ -595,7 +606,7 @@
<Compile Include="ViewModels\Home\AnimePageViewModel.cs" />
<Compile Include="Modules\Home\CinemaVM.cs" />
<Compile Include="ViewModels\Home\DynamicPageViewModel.cs" />
<Compile Include="Modules\Home\HomeVM.cs" />
<Compile Include="ViewModels\Home\HomeViewModel.cs" />
<Compile Include="Modules\Home\HotVM.cs" />
<Compile Include="Modules\IModules.cs" />
<Compile Include="ViewModels\Live\LiveRoomViewModel.cs" />
Expand All @@ -604,7 +615,7 @@
<Compile Include="ViewModels\UserDynamic\UserDynamicViewModel.cs" />
<Compile Include="Modules\User\LoginVM.cs" />
<Compile Include="Modules\User\SendDynamic\AtVM.cs" />
<Compile Include="Modules\User\HistoryVM.cs" />
<Compile Include="ViewModels\User\HistoryViewModel.cs" />
<Compile Include="Modules\User\MyFollowSeasonVM.cs" />
<Compile Include="Modules\Player\PlayerVM.cs" />
<Compile Include="Modules\RankVM.cs" />
Expand Down Expand Up @@ -1288,4 +1299,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ public class DynamicItemDataTemplateSelector : DataTemplateSelector

protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{
if (item is DynamicItemModel card && card.Desc.Type == 8)
if (item is DynamicItemModel videoCard && videoCard.Desc.Type == 8)
{
return Resource["DynamicVideo"] as DataTemplate;
}
else if(item is DynamicItemModel ugcSeasonCard && ugcSeasonCard.Desc.Type == 4310)
{
return Resource["DynamicUgcSeason"] as DataTemplate;
}
else
{
return Resource["DynamicSeason"] as DataTemplate;
Expand Down
25 changes: 25 additions & 0 deletions src/BiliLite.UWP/Controls/Player.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,30 @@ public void SetRatioMode(int mode)
mediaPlayerVideo.Height = this.ActualHeight;
mediaPlayerVideo.Width = this.ActualHeight * 4 / 3;
break;
case 4:
if (m_dashInfo != null)
{
if (((double)this.ActualWidth / (double)this.ActualHeight) <= ((double)m_dashInfo.Video.Width / (double)m_dashInfo.Video.Height))
{
/// 原视频长宽比大于等于窗口长宽比
mediaPlayerVideo.Stretch = Stretch.Fill;
mediaPlayerVideo.Width = this.ActualWidth;
mediaPlayerVideo.Height = this.ActualWidth * (double)m_dashInfo.Video.Height / (double)m_dashInfo.Video.Width;
}
else {
/// 原视频长宽比小于窗口长宽比
mediaPlayerVideo.Stretch = Stretch.Fill;
mediaPlayerVideo.Width = this.ActualHeight * (double)m_dashInfo.Video.Width / (double)m_dashInfo.Video.Height;
mediaPlayerVideo.Height = this.ActualHeight;
}
}
else {
/// 未获取到DASH视频信息则不缩放
mediaPlayerVideo.Stretch = Stretch.None;
mediaPlayerVideo.Width = double.NaN;
mediaPlayerVideo.Height = double.NaN;
}
break;
default:
break;
}
Expand Down Expand Up @@ -1308,6 +1332,7 @@ public string GetMediaInfo()
if (m_dashInfo != null && m_dashInfo.Audio != null)
{
info += $"Resolution: {m_dashInfo.Video.Width} x {m_dashInfo.Video.Height}\r\n";
info += $"View Resolution: {(int)mediaPlayerVideo.Width} x {(int)mediaPlayerVideo.Height}\r\n";
info += $"Video Codec: {m_dashInfo.Video.Codecs}\r\n";
info += $"Video DataRate: {(m_dashInfo.Video.BandWidth / 1024).ToString("0.0")}Kbps\r\n";
info += $"Average Frame: {m_dashInfo.Video.FrameRate}\r\n";
Expand Down
5 changes: 3 additions & 2 deletions src/BiliLite.UWP/Controls/PlayerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
<ComboBoxItem>填充</ComboBoxItem>
<ComboBoxItem>16:9</ComboBoxItem>
<ComboBoxItem>4:3</ComboBoxItem>
<ComboBoxItem>兼容</ComboBoxItem>
</ComboBox.Items>
</ComboBox>
<ToggleSwitch x:Name="PlayerSettingABPlayMode" Margin="0 8" Foreground="White" >
Expand Down Expand Up @@ -609,7 +610,7 @@
</StackPanel>
</Grid>
<ItemsControl x:Name="InteractionChoices"
ItemsSource="{x:Bind interactionVideoVM.Info.edges.questions}"
ItemsSource="{x:Bind m_viewModel.Questions, Mode=OneWay}"
Visibility="Collapsed" VerticalAlignment="Bottom" Margin="0 0 0 80">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="player:InteractionEdgeInfoQuestionModel">
Expand All @@ -618,7 +619,7 @@
x:Name="SelectChoice"
IsItemClickEnabled="True"
ItemClick="SelectChoice_ItemClick"
ItemsSource="{x:Bind Path=choices}">
ItemsSource="{x:Bind Path=choices, Mode=OneWay}">
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Margin" Value="12"></Setter>
Expand Down
10 changes: 9 additions & 1 deletion src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using BiliLite.Models.Common.Player;
using BiliLite.Models.Common.Video.PlayUrlInfos;
using BiliLite.Services.Interfaces;
using BiliLite.ViewModels;

//https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板

Expand All @@ -51,13 +52,16 @@ public sealed partial class PlayerControl : UserControl, IDisposable
private static readonly ILogger _logger = GlobalLogger.FromCurrentType();
private readonly bool m_useNsDanmaku = true;
private readonly IDanmakuController m_danmakuController;
private readonly PlayControlViewModel m_viewModel;
public event PropertyChangedEventHandler PropertyChanged;
private GestureRecognizer gestureRecognizer;
private void DoPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

InteractionVideoVM interactionVideoVM;

/// <summary>
/// 铺满窗口事件
/// </summary>
Expand Down Expand Up @@ -120,6 +124,7 @@ public BiliPlayUrlQualitesInfo playUrlInfo

public PlayerControl()
{
m_viewModel = new PlayControlViewModel();
this.InitializeComponent();
dispRequest = new DisplayRequest();
playerHelper = new PlayerVM();
Expand Down Expand Up @@ -1262,6 +1267,7 @@ private async Task ChangedNode(int node_id, string cid)
CurrentPlayItem.cid = cid;

await interactionVideoVM.GetNodes(node_id);
m_viewModel.Questions = interactionVideoVM.Info.edges.questions;

TopTitle.Text = interactionVideoVM.Select.title;
//if ((interactionVideoVM.Info.edges?.questions?.Count ?? 0) <= 0)
Expand Down Expand Up @@ -1588,9 +1594,9 @@ private async Task GetPlayerInfo()
{
interactionVideoVM = new InteractionVideoVM(CurrentPlayItem.avid, player_info.interaction.graph_version);
NodeList.DataContext = interactionVideoVM;
InteractionChoices.DataContext = interactionVideoVM;
ShowPlaylistButton = false;
await interactionVideoVM.GetNodes();
m_viewModel.Questions = interactionVideoVM.Info.edges.questions;
TopTitle.Text = interactionVideoVM.Select.title;
}
}
Expand Down Expand Up @@ -2329,6 +2335,8 @@ private void Player_PlayStateChanged(object sender, PlayState e)
BottomBtnLoading.Visibility = Visibility.Visible;
BottomBtnPlay.Visibility = Visibility.Collapsed;
BottomBtnPause.Visibility = Visibility.Collapsed;
// 更新画面比例
Player.SetRatioMode(PlayerSettingRatio.SelectedIndex);
break;
case PlayState.Playing:
KeepScreenOn(true);
Expand Down
6 changes: 4 additions & 2 deletions src/BiliLite.UWP/Dialogs/DownloadDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public sealed partial class DownloadDialog : ContentDialog
DownloadItemViewModel downloadItem;
List<DownloadEpisodeItemViewModel> allEpisodes;
private readonly DownloadDialogViewModel m_viewModel;
private readonly DownloadPageViewModel m_downloadPageViewModel;
private readonly IMapper m_mapper;

public DownloadDialog(DownloadItem downloadItem)
Expand All @@ -32,6 +33,7 @@ public DownloadDialog(DownloadItem downloadItem)
playerVM = new PlayerVM(true);

m_viewModel = App.ServiceProvider.GetService<DownloadDialogViewModel>();
m_downloadPageViewModel = App.ServiceProvider.GetService<DownloadPageViewModel>();
m_mapper = App.ServiceProvider.GetService<IMapper>();

var downloadItemViewModel = m_mapper.Map<DownloadItemViewModel>(downloadItem);
Expand Down Expand Up @@ -231,7 +233,7 @@ private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, Conten
item.ErrorMessage = ex.Message;
}
}
DownloadVM.Instance.LoadDownloading();
m_downloadPageViewModel.LoadDownloading();
IsPrimaryButtonEnabled = true;
if (hide)
{
Expand All @@ -247,7 +249,7 @@ private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, Conten

private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
DownloadVM.Instance.LoadDownloading();
m_downloadPageViewModel.LoadDownloading();
this.Hide();
}

Expand Down
27 changes: 21 additions & 6 deletions src/BiliLite.UWP/Extensions/BiliExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using BiliLite.Models.Common;
using BiliLite.Models;
using BiliLite.Models.Common;
using BiliLite.Models.Common.Season;
using BiliLite.Models.Exceptions;
using BiliLite.Models.Requests.Api;
using BiliLite.Models.Responses;
using BiliLite.Services;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.UI.Controls;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -29,12 +31,25 @@ public static async Task<string> BangumiEpidToSid(string epid)
{
try
{
var re = await $"https://bangumi.bilibili.com/view/web_api/season?ep_id={epid}".GetString();
var obj = JObject.Parse(re);
return obj["result"]["season_id"].ToString();
var results = await new SeasonApi().Detail(epid, SeasonIdType.EpId).Request();
if (!results.status)
{
throw new CustomizedErrorException(results.message);
}

//访问番剧详情
var data = await results.GetJson<ApiDataModel<SeasonDetailModel>>();

if (!data.success)
{
throw new CustomizedErrorException(data.message);
}

return data.data.SeasonId.ToString();
}
catch (Exception)
catch (Exception ex)
{
_logger.Error("转换epId到seasonId错误", ex);
return "";
}
}
Expand Down
21 changes: 20 additions & 1 deletion src/BiliLite.UWP/Extensions/MapperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
using Bilibili.App.Dynamic.V2;
using Bilibili.App.Interface.V1;
using Bilibili.Tv.Interfaces.Dm.V1;
using BiliLite.Controls.Dynamic;
using BiliLite.Models.Common;
using BiliLite.Models.Common.Anime;
using BiliLite.Models.Common.Comment;
using BiliLite.Models.Common.Dynamic;
using BiliLite.Models.Common.Home;
using BiliLite.Models.Common.Season;
using BiliLite.Models.Common.User;
using BiliLite.Models.Common.UserDynamic;
Expand Down Expand Up @@ -47,6 +47,7 @@ public static IServiceCollection AddMapper(this IServiceCollection services)
expression.CreateMap<SeasonDetailUserStatusModel, SeasonDetailUserStatusViewModel>();
expression.CreateMap<SeasonDetailModel, SeasonDetailViewModel>();
expression.CreateMap<AnimeFallModel, AnimeFallViewModel>();
expression.CreateMap<HomeNavItem, HomeNavItemViewModel>();

expression.CreateMap<Arc, SubmitVideoItemModel>()
.ForMember(dest => dest.Play, opt => opt.MapFrom(src => src.Archive.Stat.View))
Expand Down Expand Up @@ -132,6 +133,9 @@ public static List<DynamicItemModel> MapToDynamicItemModels(this IEnumerable<Dyn
case DynamicType.Pgc:
type = 512;
break;
case DynamicType.UgcSeason:
type = 4310;
break;
}

var moduleAuthor = src.Modules.FirstOrDefault(x => x.ModuleType == DynModuleType.ModuleAuthor);
Expand Down Expand Up @@ -197,6 +201,21 @@ public static List<DynamicItemModel> MapToDynamicItemModels(this IEnumerable<Dyn
dynItemModel.Season = dynSeason;
break;
}
case 4310:
{
var dynUgcSeason = new DynamicUgcSeasonCardModel()
{
Aid = moduleDynamic.ModuleDynamic
.DynUgcSeason.Avid.ToString(),
Duration = moduleDynamic.ModuleDynamic.DynUgcSeason.Duration,
Pic = moduleDynamic.ModuleDynamic
.DynUgcSeason.Cover,
Title = moduleDynamic.ModuleDynamic.DynUgcSeason.Title,
};

dynItemModel.UgcSeason = dynUgcSeason;
break;
}
}

dynamicItemModels.Add(dynItemModel);
Expand Down
Loading

0 comments on commit 36e5236

Please sign in to comment.