|
@@ -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;
|