904118851 1 month ago
parent
commit
1d1a8c3f7e

+ 4 - 2
etc/config.json

@@ -38,7 +38,8 @@
         "secretKey": "CN6KQ8Bauo8JXg5fFPk86EHdRFIUVnyV",
         "get_fq_package_list":"https://www.changdunovel.com/novelsale/openapi/wx/get_package_list/v2",
         "get_bound_package_list":"https://www.changdunovel.com/novelsale/openapi/wx/get_bound_package_list/v1"
-        ,"find_child_book_host":"http://8.155.24.245:8989/getid2/api.php?type=fanqie&id="
+        ,"find_child_book_host":"http://8.155.24.245:8989/getid2/api.php?type=fanqie&id=",
+        "search_id":"http://8.155.24.245:8989/getid2/api.php?type=fanqie&id="
     },
     "dianzhong_config": {
         "clientId": 10003204,
@@ -87,7 +88,8 @@
         "create_link_host": "https://www.changdunovel.com/novelsale/openapi/promotion/create/v1",
         "distributorId": 1819222136130603,
         "secretKey": "CN6KQ8Bauo8JXg5fFPk86EHdRFIUVnyV",
-        "find_parent_book_host":"http://8.155.24.245:8989/getid/api.php?type=fanqie&id="
+        "find_parent_book_host":"http://8.155.24.245:8989/getid/api.php?type=fanqie&id=",
+        "search_id":"http://8.155.24.245:8989/getid/api.php?type=fanqie&id="
     },
     "zhihu_conifg":{
         "app_secret":"7tdk5g3l9m2n0p8q1r4s6t0u9v8w7x6y",

+ 42 - 96
src/api/fq/fq_search_book.js

@@ -131,113 +131,59 @@ CMD.search_name = function(keyword){
 }
 
 CMD.search_new_id = async function(bookId,call_back){
-
-    const url = `https://www.changdunovel.com/novelsale/distributor/content/book/list/v1?permission_statuses=3%2C4&search_type=5&query=${bookId}&page_index=0&page_size=10`;
-    
-    const headers = {
-      'accept': 'application/json, text/plain, */*',
-      'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
-      'appid': '40013175',
-      'apptype': '8',
-      'distributorid': '1826185708850233',
-      'x-secsdk-csrf-token': '00010000000179433e83b8ea90a50d951e7970ba1e3d033b905c0c5632cc41a67aceb1535f5d184ebb06050effa9',
-      'cookie': temp_cookie,
-    };
-    
+    const url = `${config.fanqie_config.search_id}${bookId}&t=1`
     try{
         let client =  tools.getOneNewClinet()
-        let response = await client.get(url,{headers})
-        let data = response.data
-        if(data.code!=0){
-            throw data
+        let response = await client.get(url)
+        if(response.data["code"]==401){
+            throw response.data["msg"]
+        }
+        let book_info = response.data
+        let info = {}
+        info.words = book_info.word_count
+        info.book_name =  book_info.book_name
+        info.book_id =  book_info.book_id
+        info.publish_time = book_info.on_shelf_time
+        info.author = book_info.author
+        if(book_info.genre==8){
+            info.genre = 3;
+        }else{
+            info.genre = 1;
         }
-        return data.data[0]
+        return info;
     }catch(e){
         console.error("search_new_id error:",e)
-        return ""
+        return null
     }
-
-  
 }
 
 
 CMD.search_mf_new_id = async function(bookId){
-  return new Promise((resolve, reject) => {
-    const options = {
-        hostname: 'www.changdunovel.com',
-        path: '/novelsale/distributor/content/book/list/v1',
-        method: 'GET',
-        headers: {
-            'accept': 'application/json, text/plain, */*',
-            'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
-            'agw-js-conv': 'str',
-            'appid': '40017687',
-            'apptype': '15',
-            'distributorid': '1819222136130603',
-            'priority': 'u=1, i',
-            'sec-ch-ua': '"Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
-            'sec-ch-ua-mobile': '?1',
-            'sec-ch-ua-platform': '"Android"',
-            'sec-fetch-dest': 'empty',
-            'sec-fetch-mode': 'cors',
-            'sec-fetch-site': 'same-origin',
-            'x-secsdk-csrf-token': '000100000001914e91f95f8129843d7ae581c2ae522b975d3994a1f71be6a7a9e478964baf7a183ba7abea3a9c09',
-            'cookie': temp_cookie
+    const url = `${config.fanqie_mf_config.search_id}${bookId}&t=1`
+    try{
+        let client =  tools.getOneNewClinet()
+        let response = await client.get(url)
+        if(response.data["code"]==401){
+            throw response.data["msg"]
         }
-    };
-
-    // 构建查询参数
-    const params = new URLSearchParams({
-        permission_statuses: '3,4',
-        search_type: '6',
-        query: `${bookId}`,
-        page_index: '0',
-        page_size: '1',
-        msToken: 'QtOXD1IEPGNjuwS8Lzzew68qWnqxmVU10gPxOLcbijTXMmshIe_toySxUmiovwVBez7c8O3QcscyRES2_uC',
-        a_bogus: 'mf0RheSEOx/nKpltmKsUeUHUEy2MrzuyDBTKRijyeNxpTZMaA8eeNOc9rxumZFaaeYpNZSMHUn-AznrcOcwwZ7HpKskvui7RtG9I98so8ZH3bBJg9r6MCGGoqkke/cWE85ltx9011UfO1nclk3dKMp3Jo/4qQODdRJ9zfPvax1q6640a7s8='
-    });
-
-    options.path += `?${params.toString()}`;
-
-    const req = https.request(options, (res) => {
-        let data = '';
-
-        res.on('data', (chunk) => {
-            data += chunk;
-        });
-
-        res.on('end', () => {
-            try {
-                const parsedData = JSON.parse(data);
-                if(parsedData.code!=0){
-                 resolve("");
-                 return
-                }
-                if(parsedData.data.length<=0){
-                  resolve(null);
-                  return
-                }
-                resolve(parsedData.data[0]);
-            } catch (e) {
-                console.error('JSON parsing error:', e);
-                reject(e);
-            }
-        });
-    });
-
-    req.on('error', (error) => {
-        console.error('Request error:', error);
-        reject(error);
-    });
-
-    // 设置请求超时
-    req.setTimeout(10000, () => {
-        req.destroy();
-        reject(new Error('Request timeout'));
-    });
-
-    req.end();
-});
+        let book_info = response.data
+        let info = {}
+        // console.log("book_info:",book_info)
+        info.words = book_info.word_count
+        info.book_name =  book_info.book_name
+        info.book_id =  book_info.book_id
+        info.publish_time = book_info.on_shelf_time
+        info.author = book_info.author
+        if(book_info.genre==8){
+            info.genre = 3;
+        }else{
+            info.genre = 1;
+        }
+        return info;
+    }catch(e){
+        console.error("search_new_id error:",e)
+        return null
+    }
 }
 
 module.exports = CMD;

+ 1 - 1
task_script/sync_author_fq.js

@@ -27,7 +27,7 @@ async function processTask(){
         for (let index = 0; index < rows.length; index++) {
             let video_product_info = rows[index]
             let data =  await require('../src/api/fq/fq_search_book').search_new_id(video_product_info.product_id)
-            if(data!=null&&data!=""){
+            if(data!=null){
                 let author = data.author
                 await connection.execute(
                     ` UPDATE video_product SET  author = '${author}' WHERE id = ${video_product_info.id}  `

+ 1 - 1
task_script/sync_author_fq_mf.js

@@ -28,7 +28,7 @@ async function processTask(){
         for (let index = 0; index < rows.length; index++) {
             let video_product_info = rows[index]
             let data =  await require('../src/api/fq/fq_search_book').search_mf_new_id(video_product_info.product_id)
-            if(data!=null&&data!=""){
+            if(data!=null){
                 let author = data.author
                 await connection.execute(
                     ` UPDATE video_product SET  author = '${author}' WHERE id = ${video_product_info.id}  `

+ 10 - 18
task_script/sync_publish_time_fq.js

@@ -26,29 +26,21 @@ async function processTask(){
         for (let index = 0; index < rows.length; index++) {
             let video_product_info = rows[index]
             let data =  await require('../src/api/fq/fq_search_book').search_new_id(video_product_info.product_id)
-            if(data==""){
-                console.error("接口失效")
+            if(data!=null){
+                let publish_time = data.publish_time
+                await connection.execute(
+                    `UPDATE video_product SET publish_time = "${publish_time}"  WHERE id = ${video_product_info.id} `
+                );
+                await new Promise(resolve => setTimeout(resolve,1000));
             }else{
-                if(data!=null){
-                    let publish_time = data.on_shelf_time
-                    if(data.on_shelf_time==""){
-                        publish_time = data.latest_update_time
-                    }
-                    await connection.execute(
-                        `UPDATE video_product SET publish_time = "${publish_time}"  WHERE id = ${video_product_info.id} `
-                    );
-                    await new Promise(resolve => setTimeout(resolve,1000));
-                }else{
-                    await connection.execute(
-                        ` UPDATE video_product SET status = 0 , publish_time = '2000-01-01 01:01:01' WHERE id = ${video_product_info.id}  `
-                    );
-                    console.error("查无此书:",video_product_info)
-                }
+                await connection.execute(
+                    ` UPDATE video_product SET status = 0 , publish_time = '2000-01-01 01:01:01' WHERE id = ${video_product_info.id}  `
+                );
+                console.error("查无此书:",video_product_info)
             }
 
         }
 
-
     }catch(e){
         if(e==0){
             right_status = false

+ 3 - 6
task_script/sync_publish_time_fq_mf.js

@@ -44,12 +44,9 @@ async function processTask(){
                 }else{
                     //添加到番茄付费里
                     let data =  await require('../src/api/fq/fq_search_book').search_new_id(video_product_info.product_parent_id)
-                    if(data!=null&&data!=""){
-                        let publish_time = data.on_shelf_time
-                        if(publish_time==""){
-                            publish_time = data.latest_update_time
-                        }
-                        let words = data.word_count
+                    if(data!=null){
+                        let publish_time = data.publish_time
+                        let words = data.words
                         let book_name = data.book_name;
                         let genre = 1
                         if(words>100000){

+ 5 - 2
tg_factory_main.js

@@ -28,10 +28,13 @@ function getMainInfoById(MainConfig,main_id){
 }
 let isInit = false
 // config.isDebug
-if(!config.isDebug){
+if(config.isDebug){
     redis_help.connect( async (results)=>{
         if(results){
-            // let data = await require('./src/api/fq/fq_search_book').search_new_id('7521692514667990026',"1814786227164169")
+            // let data = await require('./src/api/fq/fq_search_book').search_new_id('7519449070331497522')
+            // console.log("data:",data)
+
+            // let data = await require('./src/api/fq/fq_search_book').search_mf_new_id('7515001057554992190')
             // console.log("data:",data)
             // await makeRequest()
             // let uuid =  tools.generateCryptoNumericUUID(5)