diff --git a/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs b/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs
index 77083a4..dd1b5fa 100644
--- a/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs
+++ b/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs
@@ -16,7 +16,10 @@ namespace DownKyi.Core.Aria2cNet.Client
public static class AriaClient
{
private static readonly string JSONRPC = "2.0";
- private static readonly string TOKEN = "downkyi";
+ private const string LOCAL_HOST = "http://localhost";
+ private const string TOKEN = "downkyi";
+ private static string host = LOCAL_HOST;
+ private static string token = TOKEN;
///
/// This method adds a new download.
@@ -41,7 +44,7 @@ namespace DownKyi.Core.Aria2cNet.Client
{
List
private void ExecuteVideoQualitySelectedCommand()
{
- // 杜比视界
- string dolby = string.Empty;
- try
- {
- var qualities = Constant.GetAudioQualities();
- dolby = qualities[3].Name;
- }
- catch (Exception e)
- {
- Core.Utils.Debugging.Console.PrintLine("ExecuteVideoQualitySelectedCommand()发生异常: {0}", e);
- LogManager.Error("ExecuteVideoQualitySelectedCommand", e);
- }
-
- if (VideoQuality != null && VideoQuality.Quality == 126 && PlayUrl != null && PlayUrl.Dash != null && PlayUrl.Dash.Dolby != null)
- {
- ListHelper.AddUnique(AudioQualityFormatList, dolby);
- AudioQualityFormat = dolby;
- }
- else
- {
- if (AudioQualityFormatList.Contains(dolby))
- {
- AudioQualityFormatList.Remove(dolby);
- AudioQualityFormat = AudioQualityFormatList[0];
- }
- }
+ //// 杜比视界
+ //string dolby = string.Empty;
+ //try
+ //{
+ // var qualities = Constant.GetAudioQualities();
+ // dolby = qualities[3].Name;
+ //}
+ //catch (Exception e)
+ //{
+ // Core.Utils.Debugging.Console.PrintLine("ExecuteVideoQualitySelectedCommand()发生异常: {0}", e);
+ // LogManager.Error("ExecuteVideoQualitySelectedCommand", e);
+ //}
+
+ //if (VideoQuality != null && VideoQuality.Quality == 126 && PlayUrl != null && PlayUrl.Dash != null && PlayUrl.Dash.Dolby != null)
+ //{
+ // ListHelper.AddUnique(AudioQualityFormatList, dolby);
+ // AudioQualityFormat = dolby;
+ //}
+ //else
+ //{
+ // if (AudioQualityFormatList.Contains(dolby))
+ // {
+ // AudioQualityFormatList.Remove(dolby);
+ // AudioQualityFormat = AudioQualityFormatList[0];
+ // }
+ //}
}
#endregion
diff --git a/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs b/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs
index a46ce58..98c40c3 100644
--- a/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs
+++ b/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs
@@ -41,6 +41,13 @@ namespace DownKyi.ViewModels.Settings
set => SetProperty(ref aria2c, value);
}
+ private bool customAria2c;
+ public bool CustomAria2c
+ {
+ get => customAria2c;
+ set => SetProperty(ref customAria2c, value);
+ }
+
private List maxCurrentDownloads;
public List MaxCurrentDownloads
{
@@ -90,6 +97,13 @@ namespace DownKyi.ViewModels.Settings
set => SetProperty(ref httpProxyPort, value);
}
+ private string ariaHost;
+ public string AriaHost
+ {
+ get => ariaHost;
+ set => SetProperty(ref ariaHost, value);
+ }
+
private int ariaListenPort;
public int AriaListenPort
{
@@ -97,6 +111,13 @@ namespace DownKyi.ViewModels.Settings
set => SetProperty(ref ariaListenPort, value);
}
+ private string ariaToken;
+ public string AriaToken
+ {
+ get => ariaToken;
+ set => SetProperty(ref ariaToken, value);
+ }
+
private List ariaLogLevels;
public List AriaLogLevels
{
@@ -259,6 +280,9 @@ namespace DownKyi.ViewModels.Settings
case Downloader.ARIA:
Aria2c = true;
break;
+ case Downloader.CUSTOM_ARIA:
+ CustomAria2c = true;
+ break;
}
// builtin同时下载数
@@ -277,9 +301,15 @@ namespace DownKyi.ViewModels.Settings
// builtin的http代理的端口
HttpProxyPort = SettingsManager.GetInstance().GetHttpProxyListenPort();
+ // Aria服务器host
+ AriaHost = SettingsManager.GetInstance().GetAriaHost();
+
// Aria服务器端口
AriaListenPort = SettingsManager.GetInstance().GetAriaListenPort();
+ // Aria服务器Token
+ AriaToken = SettingsManager.GetInstance().GetAriaToken();
+
// Aria的日志等级
AriaConfigLogLevel ariaLogLevel = SettingsManager.GetInstance().GetAriaLogLevel();
SelectedAriaLogLevel = ariaLogLevel.ToString("G");
@@ -349,6 +379,9 @@ namespace DownKyi.ViewModels.Settings
case "Aria2c":
downloader = Downloader.ARIA;
break;
+ case "CustomAria2c":
+ downloader = Downloader.CUSTOM_ARIA;
+ break;
default:
downloader = SettingsManager.GetInstance().GetDownloader();
break;
@@ -444,6 +477,21 @@ namespace DownKyi.ViewModels.Settings
PublishTip(isSucceed);
}
+ // Aria服务器host事件
+ private DelegateCommand ariaHostCommand;
+ public DelegateCommand AriaHostCommand => ariaHostCommand ?? (ariaHostCommand = new DelegateCommand(ExecuteAriaHostCommand));
+
+ ///
+ /// Aria服务器host事件
+ ///
+ ///
+ private void ExecuteAriaHostCommand(string parameter)
+ {
+ AriaHost = parameter;
+ bool isSucceed = SettingsManager.GetInstance().SetAriaHost(AriaHost);
+ PublishTip(isSucceed);
+ }
+
// Aria服务器端口事件
private DelegateCommand ariaListenPortCommand;
public DelegateCommand AriaListenPortCommand => ariaListenPortCommand ?? (ariaListenPortCommand = new DelegateCommand(ExecuteAriaListenPortCommand));
@@ -461,6 +509,21 @@ namespace DownKyi.ViewModels.Settings
PublishTip(isSucceed);
}
+ // Aria服务器token事件
+ private DelegateCommand ariaTokenCommand;
+ public DelegateCommand AriaTokenCommand => ariaTokenCommand ?? (ariaTokenCommand = new DelegateCommand(ExecuteAriaTokenCommand));
+
+ ///
+ /// Aria服务器token事件
+ ///
+ ///
+ private void ExecuteAriaTokenCommand(string parameter)
+ {
+ AriaToken = parameter;
+ bool isSucceed = SettingsManager.GetInstance().SetAriaToken(AriaToken);
+ PublishTip(isSucceed);
+ }
+
// Aria的日志等级事件
private DelegateCommand ariaLogLevelsCommand;
public DelegateCommand AriaLogLevelsCommand => ariaLogLevelsCommand ?? (ariaLogLevelsCommand = new DelegateCommand(ExecuteAriaLogLevelsCommand));
diff --git a/src/DownKyi/ViewModels/UserSpace/SeasonsSeries.cs b/src/DownKyi/ViewModels/UserSpace/SeasonsSeries.cs
new file mode 100644
index 0000000..0641112
--- /dev/null
+++ b/src/DownKyi/ViewModels/UserSpace/SeasonsSeries.cs
@@ -0,0 +1,47 @@
+using DownKyi.Images;
+using Prism.Mvvm;
+using System.Windows.Media;
+
+namespace DownKyi.ViewModels.UserSpace
+{
+ public class SeasonsSeries : BindableBase
+ {
+ public long Id { get; set; }
+
+ private ImageSource cover;
+ public ImageSource Cover
+ {
+ get => cover;
+ set => SetProperty(ref cover, value);
+ }
+
+ private VectorImage typeImage;
+ public VectorImage TypeImage
+ {
+ get => typeImage;
+ set => SetProperty(ref typeImage, value);
+ }
+
+ private string name;
+ public string Name
+ {
+ get => name;
+ set => SetProperty(ref name, value);
+ }
+
+ private int count;
+ public int Count
+ {
+ get => count;
+ set => SetProperty(ref count, value);
+ }
+
+ private string ctime;
+ public string Ctime
+ {
+ get => ctime;
+ set => SetProperty(ref ctime, value);
+ }
+
+ }
+}
diff --git a/src/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs b/src/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs
new file mode 100644
index 0000000..b8f783b
--- /dev/null
+++ b/src/DownKyi/ViewModels/UserSpace/ViewSeasonsSeriesViewModel.cs
@@ -0,0 +1,199 @@
+using DownKyi.Core.BiliApi.Users.Models;
+using DownKyi.Core.Storage;
+using DownKyi.Events;
+using DownKyi.Images;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+
+namespace DownKyi.ViewModels.UserSpace
+{
+ public class ViewSeasonsSeriesViewModel : BaseViewModel
+ {
+ public const string Tag = "PageUserSpaceSeasonsSeries";
+
+ private long mid = -1;
+
+ #region 页面属性申明
+
+ private ObservableCollection seasonsSeries;
+ public ObservableCollection SeasonsSeries
+ {
+ get => seasonsSeries;
+ set => SetProperty(ref seasonsSeries, value);
+ }
+
+ private int selectedItem;
+ public int SelectedItem
+ {
+ get => selectedItem;
+ set => SetProperty(ref selectedItem, value);
+ }
+
+ #endregion
+
+ public ViewSeasonsSeriesViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
+ {
+ #region 属性初始化
+
+ SeasonsSeries = new ObservableCollection();
+
+ #endregion
+ }
+
+ #region 命令申明
+
+ // 视频选择事件
+ private DelegateCommand seasonsSeriesCommand;
+ public DelegateCommand SeasonsSeriesCommand => seasonsSeriesCommand ?? (seasonsSeriesCommand = new DelegateCommand(ExecuteSeasonsSeriesCommand));
+
+ ///
+ /// 视频选择事件
+ ///
+ ///
+ private void ExecuteSeasonsSeriesCommand(object parameter)
+ {
+ if (!(parameter is SeasonsSeries seasonsSeries)) { return; }
+
+ // 应该用枚举的,偷懒直接用数字
+ int type = 0;
+ if (seasonsSeries.TypeImage == NormalIcon.Instance().SeasonsSeries)
+ {
+ type = 1;
+ }
+ else if (seasonsSeries.TypeImage == NormalIcon.Instance().Channel1)
+ {
+ type = 2;
+ }
+ Dictionary data = new Dictionary
+ {
+ { "mid", mid },
+ { "id", seasonsSeries.Id },
+ { "name", seasonsSeries.Name },
+ { "count", seasonsSeries.Count },
+ { "type", type }
+ };
+
+ // 进入视频页面
+ NavigationParam param = new NavigationParam
+ {
+ ViewName = ViewModels.ViewSeasonsSeriesViewModel.Tag,
+ ParentViewName = ViewUserSpaceViewModel.Tag,
+ Parameter = data
+ };
+ eventAggregator.GetEvent().Publish(param);
+
+ SelectedItem = -1;
+ }
+
+ #endregion
+
+ public override void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+ base.OnNavigatedFrom(navigationContext);
+
+ SeasonsSeries.Clear();
+ SelectedItem = -1;
+ }
+
+ ///
+ /// 接收mid参数
+ ///
+ ///
+ public async override void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ base.OnNavigatedTo(navigationContext);
+
+ SeasonsSeries.Clear();
+ SelectedItem = -1;
+
+ // 根据传入参数不同执行不同任务
+ var parameter = navigationContext.Parameters.GetValue("object");
+ if (parameter == null)
+ {
+ return;
+ }
+
+ // 传入mid
+ mid = navigationContext.Parameters.GetValue("mid");
+
+ foreach (var item in parameter.SeasonsList)
+ {
+ if (item.Meta.Total <= 0) { continue; }
+
+ BitmapImage image = null;
+ if (item.Meta.Cover == null || item.Meta.Cover == "")
+ {
+ image = new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png"));
+ }
+ else
+ {
+ StorageCover storageCover = new StorageCover();
+ string cover = null;
+ await Task.Run(() =>
+ {
+ cover = storageCover.GetCover(item.Meta.Cover);
+ });
+ image = storageCover.GetCoverThumbnail(cover, 190, 190);
+ }
+
+ // 当地时区
+ DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
+ DateTime dateCTime = startTime.AddSeconds(item.Meta.Ptime);
+ string mtime = dateCTime.ToString("yyyy-MM-dd");
+
+ SeasonsSeries.Add(new SeasonsSeries
+ {
+ Id = item.Meta.SeasonId,
+ Cover = image,
+ TypeImage = NormalIcon.Instance().SeasonsSeries,
+ Name = item.Meta.Name,
+ Count = item.Meta.Total,
+ Ctime = mtime
+ });
+ }
+
+ foreach (var item in parameter.SeriesList)
+ {
+ if (item.Meta.Total <= 0) { continue; }
+
+ BitmapImage image = null;
+ if (item.Meta.Cover == null || item.Meta.Cover == "")
+ {
+ image = new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png"));
+ }
+ else
+ {
+ StorageCover storageCover = new StorageCover();
+ string cover = null;
+ await Task.Run(() =>
+ {
+ cover = storageCover.GetCover(item.Meta.Cover);
+ });
+ image = storageCover.GetCoverThumbnail(cover, 190, 190);
+ }
+
+ // 当地时区
+ DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
+ DateTime dateCTime = startTime.AddSeconds(item.Meta.Mtime);
+ string mtime = dateCTime.ToString("yyyy-MM-dd");
+
+ SeasonsSeries.Add(new SeasonsSeries
+ {
+ Id = item.Meta.SeriesId,
+ Cover = image,
+ TypeImage = NormalIcon.Instance().Channel1,
+ Name = item.Meta.Name,
+ Count = item.Meta.Total,
+ Ctime = mtime
+ });
+ }
+
+ }
+ }
+}
diff --git a/src/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs b/src/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs
new file mode 100644
index 0000000..0c4377f
--- /dev/null
+++ b/src/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs
@@ -0,0 +1,672 @@
+using DownKyi.Core.BiliApi.VideoStream;
+using DownKyi.Core.Storage;
+using DownKyi.Core.Utils;
+using DownKyi.CustomControl;
+using DownKyi.Events;
+using DownKyi.Images;
+using DownKyi.Services;
+using DownKyi.Services.Download;
+using DownKyi.Utils;
+using DownKyi.ViewModels.PageViewModels;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace DownKyi.ViewModels
+{
+ public class ViewSeasonsSeriesViewModel : BaseViewModel
+ {
+ public const string Tag = "PageSeasonsSeries";
+
+ private readonly IDialogService dialogService;
+
+ private CancellationTokenSource tokenSource;
+
+ private long mid = -1;
+ private long id = -1;
+ private int type = 0;
+
+ // 每页视频数量,暂时在此写死,以后在设置中增加选项
+ private readonly int VideoNumberInPage = 30;
+
+ #region 页面属性申明
+
+ private string pageName = Tag;
+ public string PageName
+ {
+ get => pageName;
+ set => SetProperty(ref pageName, value);
+ }
+
+ private GifImage loading;
+ public GifImage Loading
+ {
+ get => loading;
+ set => SetProperty(ref loading, value);
+ }
+
+ private Visibility loadingVisibility;
+ public Visibility LoadingVisibility
+ {
+ get => loadingVisibility;
+ set => SetProperty(ref loadingVisibility, value);
+ }
+
+ private Visibility noDataVisibility;
+ public Visibility NoDataVisibility
+ {
+ get => noDataVisibility;
+ set => SetProperty(ref noDataVisibility, value);
+ }
+
+ private VectorImage arrowBack;
+ public VectorImage ArrowBack
+ {
+ get => arrowBack;
+ set => SetProperty(ref arrowBack, value);
+ }
+
+ private VectorImage downloadManage;
+ public VectorImage DownloadManage
+ {
+ get => downloadManage;
+ set => SetProperty(ref downloadManage, value);
+ }
+
+ private string title;
+ public string Title
+ {
+ get => title;
+ set => SetProperty(ref title, value);
+ }
+
+ private bool isEnabled = true;
+ public bool IsEnabled
+ {
+ get => isEnabled;
+ set => SetProperty(ref isEnabled, value);
+ }
+
+ private CustomPagerViewModel pager;
+ public CustomPagerViewModel Pager
+ {
+ get => pager;
+ set => SetProperty(ref pager, value);
+ }
+
+ private ObservableCollection medias;
+ public ObservableCollection Medias
+ {
+ get => medias;
+ set => SetProperty(ref medias, value);
+ }
+
+ private bool isSelectAll;
+ public bool IsSelectAll
+ {
+ get => isSelectAll;
+ set => SetProperty(ref isSelectAll, value);
+ }
+
+ #endregion
+
+ public ViewSeasonsSeriesViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base(eventAggregator)
+ {
+ this.dialogService = dialogService;
+
+ #region 属性初始化
+
+ // 初始化loading gif
+ Loading = new GifImage(Properties.Resources.loading);
+ Loading.StartAnimate();
+ LoadingVisibility = Visibility.Collapsed;
+ NoDataVisibility = Visibility.Collapsed;
+
+ ArrowBack = NavigationIcon.Instance().ArrowBack;
+ ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");
+
+ // 下载管理按钮
+ DownloadManage = ButtonIcon.Instance().DownloadManage;
+ DownloadManage.Height = 24;
+ DownloadManage.Width = 24;
+ DownloadManage.Fill = DictionaryResource.GetColor("ColorPrimary");
+
+ Medias = new ObservableCollection();
+
+ #endregion
+ }
+
+ #region 命令申明
+
+ // 返回事件
+ private DelegateCommand backSpaceCommand;
+ public DelegateCommand BackSpaceCommand => backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace));
+
+ ///
+ /// 返回事件
+ ///
+ private void ExecuteBackSpace()
+ {
+ ArrowBack.Fill = DictionaryResource.GetColor("ColorText");
+
+ // 结束任务
+ tokenSource?.Cancel();
+
+ NavigationParam parameter = new NavigationParam
+ {
+ ViewName = ParentView,
+ ParentViewName = null,
+ Parameter = null
+ };
+ eventAggregator.GetEvent().Publish(parameter);
+ }
+
+ // 前往下载管理页面
+ private DelegateCommand downloadManagerCommand;
+ public DelegateCommand DownloadManagerCommand => downloadManagerCommand ?? (downloadManagerCommand = new DelegateCommand(ExecuteDownloadManagerCommand));
+
+ ///
+ /// 前往下载管理页面
+ ///
+ private void ExecuteDownloadManagerCommand()
+ {
+ NavigationParam parameter = new NavigationParam
+ {
+ ViewName = ViewDownloadManagerViewModel.Tag,
+ ParentViewName = Tag,
+ Parameter = null
+ };
+ eventAggregator.GetEvent().Publish(parameter);
+ }
+
+ // 全选按钮点击事件
+ private DelegateCommand selectAllCommand;
+ public DelegateCommand SelectAllCommand => selectAllCommand ?? (selectAllCommand = new DelegateCommand(ExecuteSelectAllCommand));
+
+ ///
+ /// 全选按钮点击事件
+ ///
+ ///
+ private void ExecuteSelectAllCommand(object parameter)
+ {
+ if (IsSelectAll)
+ {
+ foreach (var item in Medias)
+ {
+ item.IsSelected = true;
+ }
+ }
+ else
+ {
+ foreach (var item in Medias)
+ {
+ item.IsSelected = false;
+ }
+ }
+ }
+
+ // 列表选择事件
+ private DelegateCommand mediasCommand;
+ public DelegateCommand MediasCommand => mediasCommand ?? (mediasCommand = new DelegateCommand(ExecuteMediasCommand));
+
+ ///
+ /// 列表选择事件
+ ///
+ ///
+ private void ExecuteMediasCommand(object parameter)
+ {
+ if (!(parameter is IList selectedMedia)) { return; }
+
+ if (selectedMedia.Count == Medias.Count)
+ {
+ IsSelectAll = true;
+ }
+ else
+ {
+ IsSelectAll = false;
+ }
+ }
+
+ // 添加选中项到下载列表事件
+ private DelegateCommand addToDownloadCommand;
+ public DelegateCommand AddToDownloadCommand => addToDownloadCommand ?? (addToDownloadCommand = new DelegateCommand(ExecuteAddToDownloadCommand));
+
+ ///
+ /// 添加选中项到下载列表事件
+ ///
+ private void ExecuteAddToDownloadCommand()
+ {
+ AddToDownload(true);
+ }
+
+ // 添加所有视频到下载列表事件
+ private DelegateCommand addAllToDownloadCommand;
+ public DelegateCommand AddAllToDownloadCommand => addAllToDownloadCommand ?? (addAllToDownloadCommand = new DelegateCommand(ExecuteAddAllToDownloadCommand));
+
+ ///
+ /// 添加所有视频到下载列表事件
+ ///
+ private void ExecuteAddAllToDownloadCommand()
+ {
+ AddToDownload(false);
+ }
+
+ #endregion
+
+ ///
+ /// 添加到下载
+ ///
+ ///
+ private async void AddToDownload(bool isOnlySelected)
+ {
+ // 频道里只有视频
+ AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
+
+ // 选择文件夹
+ string directory = addToDownloadService.SetDirectory(dialogService);
+
+ // 视频计数
+ int i = 0;
+ await Task.Run(() =>
+ {
+ // 为了避免执行其他操作时,
+ // Medias变化导致的异常
+ var list = Medias.ToList();
+
+ // 添加到下载
+ foreach (var media in list)
+ {
+ // 只下载选中项,跳过未选中项
+ if (isOnlySelected && !media.IsSelected) { continue; }
+
+ /// 有分P的就下载全部
+
+ // 开启服务
+ VideoInfoService videoInfoService = new VideoInfoService(media.Bvid);
+
+ addToDownloadService.SetVideoInfoService(videoInfoService);
+ addToDownloadService.GetVideo();
+ addToDownloadService.ParseVideo(videoInfoService);
+ // 下载
+ i += addToDownloadService.AddToDownload(eventAggregator, directory);
+ }
+ });
+
+ if (directory == null)
+ {
+ return;
+ }
+
+ // 通知用户添加到下载列表的结果
+ if (i <= 0)
+ {
+ eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
+ }
+ else
+ {
+ eventAggregator.GetEvent().Publish($"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
+ }
+ }
+
+ private void OnCountChanged_Pager(int count) { }
+
+ private bool OnCurrentChanged_Pager(int old, int current)
+ {
+ if (!IsEnabled)
+ {
+ //Pager.Current = old;
+ return false;
+ }
+
+ Medias.Clear();
+ IsSelectAll = false;
+ LoadingVisibility = Visibility.Visible;
+ NoDataVisibility = Visibility.Collapsed;
+
+ //UpdateChannel(current);
+
+ if (type == 1) { UpdateSeasons(current); }
+ if (type == 2) { UpdateSeries(current); }
+
+ return true;
+ }
+
+ //private async void UpdateChannel(int current)
+ //{
+ // // 是否正在获取数据
+ // // 在所有的退出分支中都需要设为true
+ // IsEnabled = false;
+
+ // await Task.Run(() =>
+ // {
+ // CancellationToken cancellationToken = tokenSource.Token;
+
+ // var channels = Core.BiliApi.Users.UserSpace.GetChannelVideoList(mid, cid, current, VideoNumberInPage);
+ // if (channels == null || channels.Count == 0)
+ // {
+ // // 没有数据,UI提示
+ // LoadingVisibility = Visibility.Collapsed;
+ // NoDataVisibility = Visibility.Visible;
+ // return;
+ // }
+
+ // foreach (var video in channels)
+ // {
+ // if (video.Cid == 0)
+ // {
+ // continue;
+ // }
+
+ // // 查询、保存封面
+ // string coverUrl = video.Pic;
+ // BitmapImage cover;
+ // if (coverUrl == null || coverUrl == "")
+ // {
+ // cover = null; // new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png"));
+ // }
+ // else
+ // {
+ // if (!coverUrl.ToLower().StartsWith("http"))
+ // {
+ // coverUrl = $"https:{video.Pic}";
+ // }
+
+ // StorageCover storageCover = new StorageCover();
+ // cover = storageCover.GetCoverThumbnail(video.Aid, video.Bvid, -1, coverUrl, 200, 125);
+ // }
+
+ // // 播放数
+ // string play = string.Empty;
+ // if (video.Stat != null)
+ // {
+ // if (video.Stat.View > 0)
+ // {
+ // play = Format.FormatNumber(video.Stat.View);
+ // }
+ // else
+ // {
+ // play = "--";
+ // }
+ // }
+ // else
+ // {
+ // play = "--";
+ // }
+
+ // DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
+ // DateTime dateCTime = startTime.AddSeconds(video.Ctime);
+ // string ctime = dateCTime.ToString("yyyy-MM-dd");
+
+ // App.PropertyChangeAsync(new Action(() =>
+ // {
+ // ChannelMedia media = new ChannelMedia(eventAggregator)
+ // {
+ // Avid = video.Aid,
+ // Bvid = video.Bvid,
+ // Cover = cover ?? new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png")),
+ // Duration = Format.FormatDuration3(video.Duration),
+ // Title = video.Title,
+ // PlayNumber = play,
+ // CreateTime = ctime
+ // };
+ // Medias.Add(media);
+
+ // LoadingVisibility = Visibility.Collapsed;
+ // NoDataVisibility = Visibility.Collapsed;
+ // }));
+
+ // // 判断是否该结束线程,若为true,跳出循环
+ // if (cancellationToken.IsCancellationRequested)
+ // {
+ // break;
+ // }
+ // }
+
+ // }, (tokenSource = new CancellationTokenSource()).Token);
+
+ // IsEnabled = true;
+ //}
+
+ private async void UpdateSeasons(int current)
+ {
+ // 是否正在获取数据
+ // 在所有的退出分支中都需要设为true
+ IsEnabled = false;
+
+ await Task.Run(() =>
+ {
+ CancellationToken cancellationToken = tokenSource.Token;
+
+ var seasons = Core.BiliApi.Users.UserSpace.GetSeasonsDetail(mid, id, current, VideoNumberInPage);
+ if (seasons == null || seasons.Meta.Total == 0)
+ {
+ // 没有数据,UI提示
+ LoadingVisibility = Visibility.Collapsed;
+ NoDataVisibility = Visibility.Visible;
+ return;
+ }
+
+ foreach (var video in seasons.Archives)
+ {
+ //if (video.Cid == 0)
+ //{
+ // continue;
+ //}
+
+ // 查询、保存封面
+ string coverUrl = video.Pic;
+ BitmapImage cover;
+ if (coverUrl == null || coverUrl == "")
+ {
+ cover = null; // new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png"));
+ }
+ else
+ {
+ if (!coverUrl.ToLower().StartsWith("http"))
+ {
+ coverUrl = $"https:{video.Pic}";
+ }
+
+ StorageCover storageCover = new StorageCover();
+ cover = storageCover.GetCoverThumbnail(video.Aid, video.Bvid, -1, coverUrl, 200, 125);
+ }
+
+ // 播放数
+ string play = string.Empty;
+ if (video.Stat != null)
+ {
+ if (video.Stat.View > 0)
+ {
+ play = Format.FormatNumber(video.Stat.View);
+ }
+ else
+ {
+ play = "--";
+ }
+ }
+ else
+ {
+ play = "--";
+ }
+
+ DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
+ DateTime dateCTime = startTime.AddSeconds(video.Ctime);
+ string ctime = dateCTime.ToString("yyyy-MM-dd");
+
+ App.PropertyChangeAsync(new Action(() =>
+ {
+ ChannelMedia media = new ChannelMedia(eventAggregator)
+ {
+ Avid = video.Aid,
+ Bvid = video.Bvid,
+ Cover = cover ?? new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png")),
+ Duration = Format.FormatDuration3(video.Duration),
+ Title = video.Title,
+ PlayNumber = play,
+ CreateTime = ctime
+ };
+ Medias.Add(media);
+
+ LoadingVisibility = Visibility.Collapsed;
+ NoDataVisibility = Visibility.Collapsed;
+ }));
+
+ // 判断是否该结束线程,若为true,跳出循环
+ if (cancellationToken.IsCancellationRequested)
+ {
+ break;
+ }
+ }
+
+ }, (tokenSource = new CancellationTokenSource()).Token);
+
+ IsEnabled = true;
+ }
+
+ private async void UpdateSeries(int current)
+ {
+ // 是否正在获取数据
+ // 在所有的退出分支中都需要设为true
+ IsEnabled = false;
+
+ await Task.Run(() =>
+ {
+ CancellationToken cancellationToken = tokenSource.Token;
+
+ var meta = Core.BiliApi.Users.UserSpace.GetSeriesMeta(id);
+ var series = Core.BiliApi.Users.UserSpace.GetSeriesDetail(mid, id, current, VideoNumberInPage);
+ if (series == null || meta.Meta.Total == 0)
+ {
+ // 没有数据,UI提示
+ LoadingVisibility = Visibility.Collapsed;
+ NoDataVisibility = Visibility.Visible;
+ return;
+ }
+
+ foreach (var video in series.Archives)
+ {
+ //if (video.Cid == 0)
+ //{
+ // continue;
+ //}
+
+ // 查询、保存封面
+ string coverUrl = video.Pic;
+ BitmapImage cover;
+ if (coverUrl == null || coverUrl == "")
+ {
+ cover = null; // new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png"));
+ }
+ else
+ {
+ if (!coverUrl.ToLower().StartsWith("http"))
+ {
+ coverUrl = $"https:{video.Pic}";
+ }
+
+ StorageCover storageCover = new StorageCover();
+ cover = storageCover.GetCoverThumbnail(video.Aid, video.Bvid, -1, coverUrl, 200, 125);
+ }
+
+ // 播放数
+ string play = string.Empty;
+ if (video.Stat != null)
+ {
+ if (video.Stat.View > 0)
+ {
+ play = Format.FormatNumber(video.Stat.View);
+ }
+ else
+ {
+ play = "--";
+ }
+ }
+ else
+ {
+ play = "--";
+ }
+
+ DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
+ DateTime dateCTime = startTime.AddSeconds(video.Ctime);
+ string ctime = dateCTime.ToString("yyyy-MM-dd");
+
+ App.PropertyChangeAsync(new Action(() =>
+ {
+ ChannelMedia media = new ChannelMedia(eventAggregator)
+ {
+ Avid = video.Aid,
+ Bvid = video.Bvid,
+ Cover = cover ?? new BitmapImage(new Uri($"pack://application:,,,/Resources/video-placeholder.png")),
+ Duration = Format.FormatDuration3(video.Duration),
+ Title = video.Title,
+ PlayNumber = play,
+ CreateTime = ctime
+ };
+ Medias.Add(media);
+
+ LoadingVisibility = Visibility.Collapsed;
+ NoDataVisibility = Visibility.Collapsed;
+ }));
+
+ // 判断是否该结束线程,若为true,跳出循环
+ if (cancellationToken.IsCancellationRequested)
+ {
+ break;
+ }
+ }
+
+ }, (tokenSource = new CancellationTokenSource()).Token);
+
+ IsEnabled = true;
+ }
+
+ ///
+ /// 导航到VideoDetail页面时执行
+ ///
+ ///
+ public override void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ base.OnNavigatedTo(navigationContext);
+
+ ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");
+
+ DownloadManage = ButtonIcon.Instance().DownloadManage;
+ DownloadManage.Height = 24;
+ DownloadManage.Width = 24;
+ DownloadManage.Fill = DictionaryResource.GetColor("ColorPrimary");
+
+ // 根据传入参数不同执行不同任务
+ var parameter = navigationContext.Parameters.GetValue>("Parameter");
+ if (parameter == null)
+ {
+ return;
+ }
+
+ Medias.Clear();
+ IsSelectAll = false;
+
+ mid = (long)parameter["mid"];
+ id = (long)parameter["id"];
+ type = (int)parameter["type"];
+ Title = (string)parameter["name"];
+ int count = (int)parameter["count"];
+
+ // 页面选择
+ Pager = new CustomPagerViewModel(1, (int)Math.Ceiling((double)count / VideoNumberInPage));
+ Pager.CurrentChanged += OnCurrentChanged_Pager;
+ Pager.CountChanged += OnCountChanged_Pager;
+ Pager.Current = 1;
+ }
+
+ }
+}
diff --git a/src/DownKyi/ViewModels/ViewUserSpaceViewModel.cs b/src/DownKyi/ViewModels/ViewUserSpaceViewModel.cs
index 96511b7..764cd38 100644
--- a/src/DownKyi/ViewModels/ViewUserSpaceViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewUserSpaceViewModel.cs
@@ -220,12 +220,15 @@ namespace DownKyi.ViewModels
switch (banner.Id)
{
- case 0:
+ case 0: // 投稿
regionManager.RequestNavigate("UserSpaceContentRegion", ViewArchiveViewModel.Tag, param);
break;
- case 1:
+ case 1: // 频道(弃用)
regionManager.RequestNavigate("UserSpaceContentRegion", UserSpace.ViewChannelViewModel.Tag, param);
break;
+ case 2: // 合集和列表
+ regionManager.RequestNavigate("UserSpaceContentRegion", UserSpace.ViewSeasonsSeriesViewModel.Tag, param);
+ break;
}
}
@@ -385,20 +388,38 @@ namespace DownKyi.ViewModels
}
// 频道
- List channelList = null;
+ //List channelList = null;
+ //await Task.Run(() =>
+ //{
+ // channelList = Core.BiliApi.Users.UserSpace.GetChannelList(mid);
+ //});
+ //if (channelList != null && channelList.Count > 0)
+ //{
+ // TabLeftBanners.Add(new TabLeftBanner
+ // {
+ // Object = channelList,
+ // Id = 1,
+ // Icon = NormalIcon.Instance().Channel,
+ // IconColor = "#FF23C9ED",
+ // Title = DictionaryResource.GetString("Channel")
+ // });
+ //}
+
+ // 合集和列表
+ SpaceSeasonsSeries seasonsSeries = null;
await Task.Run(() =>
{
- channelList = Core.BiliApi.Users.UserSpace.GetChannelList(mid);
+ seasonsSeries = Core.BiliApi.Users.UserSpace.GetSeasonsSeries(mid, 1, 20);
});
- if (channelList != null && channelList.Count > 0)
+ if (seasonsSeries != null && seasonsSeries.Page.Total > 0)
{
TabLeftBanners.Add(new TabLeftBanner
{
- Object = channelList,
- Id = 1,
+ Object = seasonsSeries,
+ Id = 2,
Icon = NormalIcon.Instance().Channel,
IconColor = "#FF23C9ED",
- Title = DictionaryResource.GetString("Channel")
+ Title = DictionaryResource.GetString("SeasonsSeries")
});
}
diff --git a/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
index 1ed6c46..b5c170f 100644
--- a/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
@@ -18,6 +18,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
@@ -184,7 +185,7 @@ namespace DownKyi.ViewModels
if (InputText == null || InputText == string.Empty) { return; }
LogManager.Debug(Tag, $"InputText: {InputText}");
-
+ InputText = Regex.Replace(InputText, @"[【]*[^【]*[^】]*[】 ]", "");
input = InputText;
// 更新页面
diff --git a/src/DownKyi/Views/Settings/ViewNetwork.xaml b/src/DownKyi/Views/Settings/ViewNetwork.xaml
index 23a3e49..884df8e 100644
--- a/src/DownKyi/Views/Settings/ViewNetwork.xaml
+++ b/src/DownKyi/Views/Settings/ViewNetwork.xaml
@@ -56,6 +56,15 @@
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding Aria2c}"
Style="{StaticResource RadioStyle}" />
+
@@ -208,6 +217,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/DownKyi/Views/UserSpace/ViewSeasonsSeries.xaml b/src/DownKyi/Views/UserSpace/ViewSeasonsSeries.xaml
new file mode 100644
index 0000000..28ba580
--- /dev/null
+++ b/src/DownKyi/Views/UserSpace/ViewSeasonsSeries.xaml
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/DownKyi/Views/UserSpace/ViewSeasonsSeries.xaml.cs b/src/DownKyi/Views/UserSpace/ViewSeasonsSeries.xaml.cs
new file mode 100644
index 0000000..426cd10
--- /dev/null
+++ b/src/DownKyi/Views/UserSpace/ViewSeasonsSeries.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DownKyi.Views.UserSpace
+{
+ ///
+ /// ViewChannel.xaml 的交互逻辑
+ ///
+ public partial class ViewSeasonsSeries : UserControl
+ {
+ public ViewSeasonsSeries()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/DownKyi/Views/ViewSeasonsSeries.xaml b/src/DownKyi/Views/ViewSeasonsSeries.xaml
new file mode 100644
index 0000000..00070e6
--- /dev/null
+++ b/src/DownKyi/Views/ViewSeasonsSeries.xaml
@@ -0,0 +1,331 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/DownKyi/Views/ViewSeasonsSeries.xaml.cs b/src/DownKyi/Views/ViewSeasonsSeries.xaml.cs
new file mode 100644
index 0000000..17b0b79
--- /dev/null
+++ b/src/DownKyi/Views/ViewSeasonsSeries.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DownKyi.Views
+{
+ ///
+ /// ViewChannel.xaml 的交互逻辑
+ ///
+ public partial class ViewSeasonsSeries : UserControl
+ {
+ public ViewSeasonsSeries()
+ {
+ InitializeComponent();
+ }
+ }
+}