Warning, /multimedia/kid3/src/qml/script/EmbedAlbumArt.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * \file EmbedAlbumArt.qml 0003 * Embed cover art found in image files into audio files in the same folder. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 08 Mar 2015 0008 * 0009 * Copyright (C) 2015-2017 Urs Fleisch 0010 * 0011 * This program is free software; you can redistribute it and/or modify 0012 * it under the terms of the GNU Lesser General Public License as published by 0013 * the Free Software Foundation; version 3. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Lesser General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Lesser General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 */ 0023 0024 import Kid3 1.1 0025 0026 Kid3Script { 0027 onRun: { 0028 var lastDir, picName, picData 0029 var baseName = configs.fileConfig().defaultCoverFileName 0030 0031 function doWork() { 0032 if (app.selectionInfo.tag(Frame.Tag_2).tagFormat || 0033 app.selectionInfo.tag(Frame.Tag_1).tagFormat) { 0034 var fileName = app.selectionInfo.fileName 0035 var dirName = app.selectionInfo.filePath 0036 dirName = dirName.substring(0, dirName.length - fileName.length) 0037 if (dirName !== lastDir) { 0038 lastDir = dirName 0039 var existingImageFiles = script.listDir(dirName, ["*.png", "*.jpg", "*.webp"]) 0040 picName = "" 0041 picData = null 0042 if (existingImageFiles.indexOf(baseName) !== -1) { 0043 picName = baseName 0044 } else if (existingImageFiles.length > 0) { 0045 picName = existingImageFiles[0] 0046 } 0047 if (picName) { 0048 picName = dirName + picName 0049 picData = script.readFile(picName) 0050 if (script.getDataSize(picData) === 0) { 0051 picData = null 0052 } 0053 } 0054 } 0055 if (picData) { 0056 if (script.getDataSize(app.getPictureData()) === 0) { 0057 app.setPictureData(picData) 0058 console.log("%1: Embedding picture from %2". 0059 arg(fileName).arg(picName)) 0060 } else { 0061 console.log(fileName + ": Already contains picture") 0062 } 0063 } 0064 } 0065 if (!nextFile()) { 0066 if (isStandalone()) { 0067 // Save the changes if the script is started stand-alone, not from Kid3. 0068 app.saveDirectory() 0069 } 0070 Qt.quit() 0071 } else { 0072 setTimeout(doWork, 1) 0073 } 0074 } 0075 0076 firstFile() 0077 doWork() 0078 } 0079 }