Skip to content

Commit

Permalink
Update update_comic_img_size.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Azumic authored Apr 25, 2024
1 parent 5ded0af commit d65ae05
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions script/update_comic_img_size.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ fs.readFile(detail_file_ori, 'utf8', (err, data1) => {

async function readImgSize(data) {
var oldData = JSON.parse(data);
var newData = oldData
Object.entries(oldData).forEach(async ([key, value]) => {

var imgwidth = []
var imgInfo = {}

let i=0;
value.imglist.forEach((url, index) => {
const matchResult = url.match(pattern);
if (matchResult) {
Expand All @@ -38,23 +40,29 @@ async function readImgSize(data) {
imgInfo[index] = info
imgwidth.push(info.width)

url = url.replace(extractedPart, tuchuang_path)
const newUrl = url.replace(extractedPart, tuchuang_path)
newData[key]["imglist"][i++] = newUrl
}
});

oldData[key].imgwidth = imgwidth
oldData[key].imgInfo = imgInfo

// console.log(value);
newData[key].imgwidth = imgwidth
newData[key].imgInfo = imgInfo

console.log(newData[key]);

});

fs.writeFile(detail_file, JSON.stringify(oldData), (err) => {
fs.writeFile(detail_file, JSON.stringify(newData), (err) => {
if (err) {
console.error('写入文件失败:', err);
return;
}
console.log('JSON 文件已成功生成!');
console.log(newData)
console.log("------------------------------------------")
});
}

Expand Down

0 comments on commit d65ae05

Please sign in to comment.