From 4221995928368a67657ab052c83b6a340842919d Mon Sep 17 00:00:00 2001 From: ken Date: Tue, 31 Dec 2024 12:16:18 +0800 Subject: [PATCH 1/3] use correct aspectratio --- src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs b/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs index a56a0dc..e67d657 100644 --- a/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs +++ b/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs @@ -145,7 +145,8 @@ private async Task Parse() [RelayCommand] private void PlayOrPauseVideo() - { + { + MediaPlayer.AspectRatio = null; if (!MediaPlayer.IsPlaying) { MediaPlayer.Play(); From ae24c6b86df793072b42f186e5e83582a24678d9 Mon Sep 17 00:00:00 2001 From: ken Date: Wed, 1 Jan 2025 22:40:36 +0800 Subject: [PATCH 2/3] don't download if it has been already downloaded --- src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs b/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs index e67d657..421c967 100644 --- a/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs +++ b/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs @@ -183,6 +183,10 @@ private async Task DownloadAll() var replaceFilename = filename.ReplaceInvalidCharacters(); + if(File.Exists(filepath+replaceFilename) ){ + throw new ValidationException("文件已存在"); + } + switch (Data.Platform) { case ShortVideoPlatformEnum.DouYin: From 2e1432320d43685c4ec23213bf86278084e47884 Mon Sep 17 00:00:00 2001 From: ken Date: Fri, 3 Jan 2025 16:27:21 +0800 Subject: [PATCH 3/3] add shareId --- src/BlueCatKoKo.Ui/Models/VideoModel.cs | 2 ++ src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BlueCatKoKo.Ui/Models/VideoModel.cs b/src/BlueCatKoKo.Ui/Models/VideoModel.cs index 4747d06..76b3f3b 100644 --- a/src/BlueCatKoKo.Ui/Models/VideoModel.cs +++ b/src/BlueCatKoKo.Ui/Models/VideoModel.cs @@ -57,4 +57,6 @@ public class VideoModel // 视频时长 public string? Duration { get; set; } + + public string? ShareId { get; set; } } \ No newline at end of file diff --git a/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs b/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs index 421c967..631a2a1 100644 --- a/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs +++ b/src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs @@ -111,6 +111,7 @@ private async Task Parse() { var downloadUrl = await _douYinShortVideoService.ExtractUrlAsync(DownloadUrlText); Data = await _douYinShortVideoService.ExtractVideoDataAsync(downloadUrl); + Data.ShareId = downloadUrl.Replace("https://v.douyin.com/", "").Replace("/", ""); } else if (DownloadUrlText.Contains(ShortVideoPlatformEnum.KuaiShou.ToString().ToLower())) { @@ -178,8 +179,8 @@ private async Task DownloadAll() } var filepath = _appConfig.Value.DownloadPath; - var filename = "#" + Data.AuthorName + "#" + Data.UniqueId + "# " + Data.Desc; - filename = filename.Substring(0, Math.Min(250, ("#" + Data.AuthorName + "#" + Data.UniqueId + "# " + Data.Desc).Length))+".mp4"; + var filename = "#" + Data.AuthorName + "#" + Data.UniqueId + "#" + Data.ShareId + "# " + Data.Desc; + filename = filename.Substring(0, Math.Min(200, (filename).Length))+".mp4"; var replaceFilename = filename.ReplaceInvalidCharacters();