files.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import logger from "#logger";
  2. import {chapter_insert, searchChapterInfoForPath, getChaptersByBookId, getFileBymd5, getBookInfo} from "#db";
  3. import cliProgress from 'cli-progress';
  4. import {EPub} from "epub2";
  5. import path from "node:path";
  6. import fs from "node:fs";
  7. export async function saveAllFiles(epub, zipEpubExtract, file_md5, author_id) {
  8. // const chapterIndex = epub.flow.findIndex(elm => elm.id === fileRow.source_id);
  9. const bookInfo = await getBookInfo(file_md5)
  10. // 图片、css、html
  11. console.log(12, bookInfo)
  12. /*files_insert({
  13. file_id = "",
  14. source_id = "",
  15. md5 = "",
  16. mimetype = "",
  17. size = "",
  18. name = "",
  19. path = "",
  20. content = "",
  21. old_path
  22. book_id = "",
  23. })*/
  24. // console.log("\nSPINE:\n");
  25. // console.log(epub.flow)
  26. for (let i = 0; i < epub.flow.length; i++) {
  27. const elm = epub.flow[i]
  28. const isImage = elm.mediaType.includes('image')
  29. const isCss = elm.mediaType.includes('text/css')
  30. // console.log(15, {
  31. // title: elm.title,
  32. // id: elm.id,
  33. // order: elm.order,
  34. // mediaType: elm.mediaType
  35. // })
  36. console.log(elm)
  37. }
  38. }