|
|
@@ -10,7 +10,7 @@ import { changeMusicCover, findLocalCoverImage, getApiLyric, repairAudioMetadata
|
|
|
import { util } from '@kit.ArkTS';
|
|
|
import { FFMpegTags, Utility } from '../common/util/Utility';
|
|
|
import { DialogHelper } from '@pura/harmony-dialog';
|
|
|
-
|
|
|
+import PermissionUtil from '../common/util/PermissionUtil'
|
|
|
//批量编辑标签
|
|
|
// 批量编辑标签
|
|
|
@Component
|
|
|
@@ -20,8 +20,9 @@ export struct TagsContentCover {
|
|
|
}
|
|
|
@State isLyric:boolean = true
|
|
|
@State isCover:boolean = true
|
|
|
+ @State download_path:string = ''
|
|
|
@Link isOneKeyTags: boolean;
|
|
|
- @State bundleName: string = ''
|
|
|
+ @State packName: string = ''
|
|
|
@State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
|
|
|
@Prop selectedFiles: Array<VideoItem>
|
|
|
@StorageProp('topRectHeight') topRectHeight: number = 0;
|
|
|
@@ -48,7 +49,9 @@ export struct TagsContentCover {
|
|
|
}
|
|
|
|
|
|
async aboutToAppear() {
|
|
|
- this.bundleName = AppUtil.getBundleName()
|
|
|
+ this.download_path = PreferencesUtil.getStringSync('download_path')
|
|
|
+ console.info('onecold download_path:', this.download_path)
|
|
|
+ this.packName = AppUtil.getBundleName()
|
|
|
// 确保 selectedFiles 有默认值后再初始化 dataSource
|
|
|
if (this.selectedFiles && this.selectedFiles.length > 0) {
|
|
|
this.dataSource = new LazyDataSource(this.selectedFiles)
|
|
|
@@ -262,7 +265,7 @@ export struct TagsContentCover {
|
|
|
.margin({ left: 6 })
|
|
|
.onClick(() => {
|
|
|
DialogHelper.closeDialog('vip');
|
|
|
- Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
|
|
|
+ Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.packName)
|
|
|
setTimeout(()=>{
|
|
|
PreferencesUtil.putSync('IS_HAO_PING',true)
|
|
|
},15000)
|
|
|
@@ -321,7 +324,7 @@ export struct TagsContentCover {
|
|
|
|
|
|
|
|
|
let success = true;
|
|
|
-
|
|
|
+ let tempOutPath = ''
|
|
|
// 1. 处理封面 (如果启用且需要处理)
|
|
|
if(this.isCover){
|
|
|
let defaultCover = ''
|
|
|
@@ -345,11 +348,19 @@ export struct TagsContentCover {
|
|
|
if (StrUtil.isNotEmpty(defaultCover)) {
|
|
|
// 确保 filePath 存在
|
|
|
if (item.filePath) {
|
|
|
+ await PermissionUtil.activatePermission(item.filePath)
|
|
|
+ // 如果不是 packName 包下的文件,则直接路径用this.download_path
|
|
|
+ if(!item.filePath.toLowerCase().includes(this.packName)){
|
|
|
+ tempOutPath = item.parentPath+'/'+ item.fileName
|
|
|
+ }
|
|
|
+ console.info('onecold tempOutPath: ' + tempOutPath)
|
|
|
+
|
|
|
+
|
|
|
const result = await changeMusicCover(
|
|
|
this.context,
|
|
|
item.filePath,
|
|
|
defaultCover,
|
|
|
- true // 覆盖原文件
|
|
|
+ true, tempOutPath
|
|
|
);
|
|
|
if (!result) {
|
|
|
success = false;
|
|
|
@@ -404,16 +415,31 @@ export struct TagsContentCover {
|
|
|
// 如果有歌词内容,嵌入到音频文件
|
|
|
if (StrUtil.isNotEmpty(lyricContent) && item.filePath) {
|
|
|
const metadata: FFMpegTags = {};
|
|
|
+ let newInput = item.filePath
|
|
|
+ //内嵌标签歌路径如果不是包含包名,输入newInput要赋值tempOutPath,然后tempOutPath为空
|
|
|
+ if(!item.filePath.toLowerCase().includes(this.packName)){
|
|
|
+ newInput = tempOutPath
|
|
|
+ tempOutPath = ''
|
|
|
+ }
|
|
|
// 修复错误2: 添加非空检查
|
|
|
const result = await repairAudioMetadata(
|
|
|
- item.filePath,
|
|
|
+ newInput,
|
|
|
lyricContent,
|
|
|
metadata,
|
|
|
- true // 覆盖原文件
|
|
|
+ true ,
|
|
|
+ tempOutPath
|
|
|
);
|
|
|
if (!result) {
|
|
|
success = false;
|
|
|
}else{
|
|
|
+ // if(!item.filePath.includes(this.packName)){
|
|
|
+ // //内嵌成功的歌路径如果不是包含包名,则要入库
|
|
|
+ // let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newInput,
|
|
|
+ // CommonConstants.TYPE_LOCAL, true);
|
|
|
+ // this.table.insert(newItem, (id: number) => {
|
|
|
+ //
|
|
|
+ // });
|
|
|
+ // }
|
|
|
//内嵌成功后同步歌词到数据库
|
|
|
syncLyricToDB(this.context,item.filePath,lyricContent)
|
|
|
}
|