collect_hy_book.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //执行一个寻找黑岩任务
  2. const CMD = {}
  3. const { head } = require('request')
  4. let hy_search_book = require('../src/api/hy/hy_search_book')
  5. const helper = require('../src/helper')
  6. CMD.runTask = async function(data){
  7. // console.log("执行一个寻找黑岩任务:",data)
  8. let book_info = await hy_search_book.search_id(data.book_id)
  9. if(book_info==undefined||book_info==null){
  10. return null
  11. }
  12. if(book_info.rows==null||book_info.rows==undefined){
  13. return null
  14. }
  15. if(book_info.rows.length<=0){
  16. return null
  17. }
  18. let book_name = book_info.rows[0].name;
  19. let typeDesc = book_info.rows[0].typeDesc; //'中篇',
  20. let words = book_info.rows[0].words; //多少字
  21. data.genre = 0
  22. let gender = 0
  23. if( book_info.rows[0].classify==2){
  24. gender = 2
  25. }else if(book_info.rows[0].classify==1){
  26. gender = 1
  27. }
  28. data.gender = gender
  29. // if(typeDesc=="中篇"){
  30. // data.genre = 2;
  31. // }
  32. if(words>100000){
  33. data.genre = 1;
  34. }else{
  35. data.genre = 3;
  36. }
  37. data.is_c500 = false
  38. if(helper.checkChannel(book_name,'C500')||helper.checkChannel(book_name,'C400')){ //番茄免费短篇
  39. data.is_c500 = true
  40. data.genre = 3;
  41. }
  42. // if(typeDesc=="长篇"){
  43. // data.genre = 1;
  44. // }else{
  45. // data.genre = 3;
  46. // }
  47. // if(typeDesc=="短篇"){
  48. // data.genre = 3;
  49. // }
  50. if(data.genre==0){
  51. console.log("获取黑岩书籍信息错误:",book_info)
  52. }
  53. data.words = words
  54. data.book_name = book_name
  55. return data
  56. }
  57. module.exports = CMD;