Skip to content

Commit

Permalink
Merge pull request SchneeHertz#162 from SchneeHertz/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
SchneeHertz authored Aug 31, 2024
2 parents b6128c2 + 2ba742d commit 98a5416
Show file tree
Hide file tree
Showing 24 changed files with 2,623 additions and 657 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.6.0](https://github.com/SchneeHertz/exhentai-manga-manager/compare/v1.5.17...v1.6.0)

> 26 July 2024
- Development [`#154`](https://github.com/SchneeHertz/exhentai-manga-manager/pull/154)
- Development [`#153`](https://github.com/SchneeHertz/exhentai-manga-manager/pull/153)
- add opds server [`6133e1b`](https://github.com/SchneeHertz/exhentai-manga-manager/commit/6133e1b2ae2de44cca29712d9401ddbb52131a55)
- remove g6 [`399b6d7`](https://github.com/SchneeHertz/exhentai-manga-manager/commit/399b6d7d2b6df467e48ab1f029e07c9ef927a52d)
- update manga server [`d52daf7`](https://github.com/SchneeHertz/exhentai-manga-manager/commit/d52daf7b0918317094200faa749441bd1256d1b8)

#### [v1.5.17](https://github.com/SchneeHertz/exhentai-manga-manager/compare/v1.5.16...v1.5.17)

> 29 June 2024
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

中文介绍 | [English Readme](https://github.com/SchneeHertz/exhentai-manga-manager/blob/master/README_EN.md) | [日本語の説明](https://github.com/SchneeHertz/exhentai-manga-manager/blob/master/README_JA.md)

**[FAQ](https://github.com/SchneeHertz/exhentai-manga-manager/wiki/FAQ)**

</div>

![cover.jpg](https://raw.githubusercontent.com/SchneeHertz/exhentai-manga-manager/master/screenshots/cover.jpg)
Expand Down
18 changes: 18 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import globals from 'globals';
import pluginVue from 'eslint-plugin-vue';


export default [
{ files: ['**/*.{js,mjs,cjs,vue}'] },
{ files: ['**/*.js'], languageOptions: { sourceType: 'commonjs' } },
{ languageOptions: { globals: globals.browser } },
...pluginVue.configs['flat/essential'],
{
rules: {
'no-const-assign': 'error',
'vue/multi-word-component-names': ['error', {
'ignores': ['Setting', 'Graph']
}]
}
},
]
44 changes: 22 additions & 22 deletions fileLoader/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const { getRootPath } = require('../modules/utils.js')

const _7z = path.join(getRootPath(), 'resources/extraResources/7z.exe')

let getArchivelist = async (libraryPath)=>{
let list = globSync('**/*.@(rar|7z|cb7|cbr)', {
const getArchivelist = async (libraryPath) => {
const list = globSync('**/*.@(rar|7z|cb7|cbr)', {
cwd: libraryPath,
nocase: true,
follow: true,
Expand All @@ -19,16 +19,16 @@ let getArchivelist = async (libraryPath)=>{
return list
}

let solveBookTypeArchive = async (filepath, TEMP_PATH, COVER_PATH)=>{
let tempFolder = path.join(TEMP_PATH, nanoid(8))
let output = await spawnPromise(_7z, ['l', filepath, '-slt', '-p123456'])
let pathlist = _.filter(output.split(/\r\n/), s=>_.startsWith(s, 'Path') && !_.includes(s, '__MACOSX'))
pathlist = pathlist.map(p=>{
let match = /(?<== ).*$/.exec(p)
const solveBookTypeArchive = async (filepath, TEMP_PATH, COVER_PATH) => {
const tempFolder = path.join(TEMP_PATH, nanoid(8))
const output = await spawnPromise(_7z, ['l', filepath, '-slt', '-p123456'])
let pathlist = _.filter(output.split(/\r\n/), s => _.startsWith(s, 'Path') && !_.includes(s, '__MACOSX'))
pathlist = pathlist.map(p => {
const match = /(?<== ).*$/.exec(p)
return match ? match[0] : ''
})
let imageList = _.filter(pathlist, p=>['.jpg','.jpeg','.png','.webp','.avif', '.gif'].includes(path.extname(p).toLowerCase()))
imageList = imageList.sort((a,b)=>a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'}))
let imageList = _.filter(pathlist, p => ['.jpg','.jpeg','.png','.webp','.avif', '.gif'].includes(path.extname(p).toLowerCase()))
imageList = imageList.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'}))

let targetFile
let targetFilePath
Expand All @@ -55,42 +55,42 @@ let solveBookTypeArchive = async (filepath, TEMP_PATH, COVER_PATH)=>{

coverPath = path.join(COVER_PATH, nanoid() + '.webp')

let fileStat = await fs.promises.stat(filepath)
const fileStat = await fs.promises.stat(filepath)
return {targetFilePath, tempCoverPath, coverPath, pageCount: imageList.length, bundleSize: fileStat?.size, mtime: fileStat?.mtime}
}

let getImageListFromArchive = async (filepath, VIEWER_PATH)=>{
let tempFolder = path.join(VIEWER_PATH, nanoid(8))
const getImageListFromArchive = async (filepath, VIEWER_PATH) => {
const tempFolder = path.join(VIEWER_PATH, nanoid(8))
await spawnPromise(_7z, ['x', filepath, '-o' + tempFolder, '-p123456'])
let list = globSync('**/*.@(jpg|jpeg|png|webp|avif|gif)', {
cwd: tempFolder,
nocase: true
})
list = _.filter(list, s=>!_.includes(s, '__MACOSX'))
list = list.sort((a,b)=>a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f=>path.join(tempFolder, f))
list = _.filter(list, s => !_.includes(s, '__MACOSX'))
list = list.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f => path.join(tempFolder, f))
return list
}

let deleteImageFromArchive = async (filename, filepath) => {
const deleteImageFromArchive = async (filename, filepath) => {
await spawnPromise(_7z, ['d', filepath, filename, '-p123456'])
return true
}

let spawnPromise = (commmand, argument)=>{
return new Promise((resolve, reject)=>{
const spawnPromise = (commmand, argument) => {
return new Promise((resolve, reject) => {
const spawned = spawn(commmand, argument)
let output = []
spawned.on('error', data=>{
const output = []
spawned.on('error', data => {
reject(data)
})
spawned.on('exit', code=>{
spawned.on('exit', code => {
if (code === 0) {
setTimeout(() => resolve(output.join('\r\n')), 50)
} else {
reject('close code is ' + code)
}
})
spawned.stdout.on('data', data=>{
spawned.stdout.on('data', data => {
output.push(iconv.decode(data, 'gbk'))
})
})
Expand Down
24 changes: 12 additions & 12 deletions fileLoader/folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const dirSize = async dir => {
return (await Promise.all(filesize)).flat(Infinity).reduce((i, size) => i + size, 0)
}

let getFolderlist = async (libraryPath)=>{
let imageList = globIterate('**/*.@(jpg|jpeg|png|webp|avif|gif)', {
const getFolderlist = async (libraryPath) => {
const imageList = globIterate('**/*.@(jpg|jpeg|png|webp|avif|gif)', {
cwd: libraryPath,
nocase: true,
follow: true,
Expand All @@ -32,36 +32,36 @@ let getFolderlist = async (libraryPath)=>{
return list
}

let solveBookTypeFolder = async (folderpath, TEMP_PATH, COVER_PATH)=>{
const solveBookTypeFolder = async (folderpath, TEMP_PATH, COVER_PATH) => {
let list = globSync('*.@(jpg|jpeg|png|webp|avif|gif)', {
cwd: folderpath,
nocase: true
})
list = list.sort((a,b)=>a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f=>path.join(folderpath, f))
list = list.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f => path.join(folderpath, f))
let targetFilePath
if (list.length > 8) {
targetFilePath = list[7]
} else {
targetFilePath = list[0]
}
let tempCoverPath = list[0]
let coverPath = path.join(COVER_PATH, nanoid() + '.webp')
let fileStat = await stat(folderpath)
let bundleSize = await dirSize(folderpath)
const tempCoverPath = list[0]
const coverPath = path.join(COVER_PATH, nanoid() + '.webp')
const fileStat = await stat(folderpath)
const bundleSize = await dirSize(folderpath)
return {targetFilePath, tempCoverPath, coverPath, pageCount: list.length, bundleSize, mtime: fileStat?.mtime}
}

let getImageListFromFolder = async (folderpath, VIEWER_PATH)=>{
const getImageListFromFolder = async (folderpath, VIEWER_PATH) => {
let list = globSync('*.@(jpg|jpeg|png|webp|avif|gif)', {
cwd: folderpath,
nocase: true
})
list = list.sort((a,b)=>a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f=>path.join(folderpath, f))
list = list.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f => path.join(folderpath, f))
return list
}

let deleteImageFromFolder = async (filename, folderpath) => {
let filepath = path.join(folderpath, filename)
const deleteImageFromFolder = async (filename, folderpath) => {
const filepath = path.join(folderpath, filename)
await shell.trashItem(filepath)
return true
}
Expand Down
14 changes: 7 additions & 7 deletions fileLoader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ const { getArchivelist, solveBookTypeArchive, getImageListFromArchive, deleteIma
const { getZipFilelist, solveBookTypeZip } = require('./zip.js')
const { TEMP_PATH, COVER_PATH, VIEWER_PATH } = require('../modules/init_folder_setting.js')

let getBookFilelist = async (library) => {
let folderList = await getFolderlist(library)
let archiveList = await getArchivelist(library)
let zipList = await getZipFilelist(library)
const getBookFilelist = async (library) => {
const folderList = await getFolderlist(library)
const archiveList = await getArchivelist(library)
const zipList = await getZipFilelist(library)
return [
...folderList.map(filepath => ({ filepath, type: 'folder' })),
...archiveList.map(filepath => ({ filepath, type: 'archive' })),
...zipList.map(filepath => ({ filepath, type: 'zip' })),
]
}

let geneCover = async (filepath, type) => {
const geneCover = async (filepath, type) => {
let targetFilePath, coverPath, tempCoverPath, pageCount, bundleSize, mtime
switch (type) {
case 'folder':
Expand All @@ -39,8 +39,8 @@ let geneCover = async (filepath, type) => {
break
}

let coverHash = createHash('sha1').update(fs.readFileSync(tempCoverPath)).digest('hex')
let copyTempCoverPath = path.join(TEMP_PATH, nanoid(8) + path.extname(tempCoverPath))
const coverHash = createHash('sha1').update(fs.readFileSync(tempCoverPath)).digest('hex')
const copyTempCoverPath = path.join(TEMP_PATH, nanoid(8) + path.extname(tempCoverPath))
await fs.promises.copyFile(tempCoverPath, copyTempCoverPath)
await sharp(copyTempCoverPath, { failOnError: false })
.resize(500, 707, {
Expand Down
34 changes: 17 additions & 17 deletions fileLoader/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const AdmZip = require('adm-zip')
const { nanoid } = require('nanoid')
const _ = require('lodash')

let getZipFilelist = async (libraryPath)=>{
let list = globSync('**/*.@(zip|cbz)', {
const getZipFilelist = async (libraryPath) => {
const list = globSync('**/*.@(zip|cbz)', {
cwd: libraryPath,
nocase: true,
follow: true,
Expand All @@ -15,16 +15,16 @@ let getZipFilelist = async (libraryPath)=>{
return list
}

let solveBookTypeZip = async (filepath, TEMP_PATH, COVER_PATH)=>{
let tempFolder = path.join(TEMP_PATH, nanoid(8))
let zip = new AdmZip(filepath)
let zipFileList = zip.getEntries()
let findZFile = (entryName)=>{
return _.find(zipFileList, zFile=>zFile.entryName == entryName)
const solveBookTypeZip = async (filepath, TEMP_PATH, COVER_PATH) => {
const tempFolder = path.join(TEMP_PATH, nanoid(8))
const zip = new AdmZip(filepath)
const zipFileList = zip.getEntries()
const findZFile = (entryName) => {
return _.find(zipFileList, zFile => zFile.entryName == entryName)
}
let fileList = zipFileList.map(zFile=>zFile.entryName)
let imageList = _.filter(fileList, filepath=>_.includes(['.jpg', ',jpeg', '.png', '.webp', '.avif', '.gif'], path.extname(filepath).toLowerCase()))
imageList = imageList.sort((a,b)=>a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'}))
const fileList = zipFileList.map(zFile => zFile.entryName)
let imageList = _.filter(fileList, filepath => _.includes(['.jpg', ',jpeg', '.png', '.webp', '.avif', '.gif'], path.extname(filepath).toLowerCase()))
imageList = imageList.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'}))

let targetFile
let targetFilePath
Expand Down Expand Up @@ -52,20 +52,20 @@ let solveBookTypeZip = async (filepath, TEMP_PATH, COVER_PATH)=>{

coverPath = path.join(COVER_PATH, nanoid() + '.webp')

let fileStat = await fs.promises.stat(filepath)
const fileStat = await fs.promises.stat(filepath)
return {targetFilePath, tempCoverPath, coverPath, pageCount: imageList.length, bundleSize: fileStat?.size, mtime: fileStat?.mtime}
}

let getImageListFromZip = async (filepath, VIEWER_PATH)=>{
let zip = new AdmZip(filepath)
let tempFolder = path.join(VIEWER_PATH, nanoid(8))
const getImageListFromZip = async (filepath, VIEWER_PATH) => {
const zip = new AdmZip(filepath)
const tempFolder = path.join(VIEWER_PATH, nanoid(8))
zip.extractAllTo(tempFolder, true)
let list = globSync('**/*.@(jpg|jpeg|png|webp|avif|gif)', {
cwd: tempFolder,
nocase: true
})
list = _.filter(list, s=>!_.includes(s, '__MACOSX'))
list = list.sort((a,b)=>a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f=>path.join(tempFolder, f))
list = _.filter(list, s => !_.includes(s, '__MACOSX'))
list = list.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})).map(f => path.join(tempFolder, f))
return list
}

Expand Down
Loading

0 comments on commit 98a5416

Please sign in to comment.