|
@@ -4,6 +4,7 @@ const redis_help = require('../src/use_redis');
|
|
const origin_data_controllers = require('../src/data_manager/Controllers/origin_data_controllers');
|
|
const origin_data_controllers = require('../src/data_manager/Controllers/origin_data_controllers');
|
|
const filter_data_controllers = require('../src/data_manager/Controllers/filter_data_controllers');
|
|
const filter_data_controllers = require('../src/data_manager/Controllers/filter_data_controllers');
|
|
const helper = require('../src/helper');
|
|
const helper = require('../src/helper');
|
|
|
|
+const config = require('../etc/config.json')
|
|
async function createFilterData(result,FilterConfig) {
|
|
async function createFilterData(result,FilterConfig) {
|
|
|
|
|
|
let PlatformConfig = await redis_help.getKeyValue("PlatformConfig")
|
|
let PlatformConfig = await redis_help.getKeyValue("PlatformConfig")
|
|
@@ -12,6 +13,7 @@ async function createFilterData(result,FilterConfig) {
|
|
|
|
|
|
let filter_data = filter_and_insert(result.data,FilterConfig,PlatformConfig)
|
|
let filter_data = filter_and_insert(result.data,FilterConfig,PlatformConfig)
|
|
if(filter_data!=null){
|
|
if(filter_data!=null){
|
|
|
|
+ console.log("filter_data:",filter_data)
|
|
filter_data.status = 0; //设置筛选的这个状态未定义
|
|
filter_data.status = 0; //设置筛选的这个状态未定义
|
|
let res = await filter_data_controllers.createFilterData({
|
|
let res = await filter_data_controllers.createFilterData({
|
|
video_id:filter_data.video_id,
|
|
video_id:filter_data.video_id,
|
|
@@ -56,6 +58,7 @@ async function processTask(){
|
|
for (let index = 0; index < origin_data_list.length; index++) {
|
|
for (let index = 0; index < origin_data_list.length; index++) {
|
|
const origin_data_item = origin_data_list[index];
|
|
const origin_data_item = origin_data_list[index];
|
|
videoDataList[origin_data_item.video_id] = origin_data_item
|
|
videoDataList[origin_data_item.video_id] = origin_data_item
|
|
|
|
+ console.log("origin_data_item:",origin_data_item)
|
|
if(helper.checkChannel(origin_data_item.guajian_link,"https://api.amemv.com/insights/lynx_web/anchor/preview?")){
|
|
if(helper.checkChannel(origin_data_item.guajian_link,"https://api.amemv.com/insights/lynx_web/anchor/preview?")){
|
|
wxIds.push(origin_data_item.id)
|
|
wxIds.push(origin_data_item.id)
|
|
}else{
|
|
}else{
|
|
@@ -81,11 +84,17 @@ async function processTask(){
|
|
}
|
|
}
|
|
console.log("nonExistentIds:",nonExistentIds)
|
|
console.log("nonExistentIds:",nonExistentIds)
|
|
}
|
|
}
|
|
- let update_result = await origin_data_controllers.updateOriginDataByIds({ids:Ids},{status:1})
|
|
|
|
- if(update_result.success){
|
|
|
|
- console.log(update_result.message)
|
|
|
|
|
|
+ let update_result
|
|
|
|
+ if(Ids.length>0){
|
|
|
|
+ update_result = await origin_data_controllers.updateOriginDataByIds({ids:Ids},{status:1})
|
|
|
|
+ if(update_result.success){
|
|
|
|
+ console.log(update_result.message)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(wxIds.length>0){
|
|
|
|
+ update_result = await origin_data_controllers.updateOriginDataByIds({ids:wxIds},{status:3,is_wx_guajian:1})
|
|
}
|
|
}
|
|
- update_result = await origin_data_controllers.updateOriginDataByIds({ids:wxIds},{status:3,is_wx_guajian:1})
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}catch(e){
|
|
}catch(e){
|
|
console.log("筛选数据错误:",e)
|
|
console.log("筛选数据错误:",e)
|
|
@@ -100,13 +109,80 @@ CMD.init = function(){
|
|
})
|
|
})
|
|
processTask()
|
|
processTask()
|
|
}
|
|
}
|
|
|
|
+function getBookId(url) {
|
|
|
|
+ try {
|
|
|
|
+ if (!url.includes('bookId=')) {
|
|
|
|
+ return null; // 或者返回其他你想要的默认值
|
|
|
|
+ }
|
|
|
|
+ const bookId = url.split('bookId=')[1].split('&')[0];
|
|
|
|
+ return bookId;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ return null; // 出现任何错误都返回null
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function getKey(url) {
|
|
|
|
+ try {
|
|
|
|
+ if (!url.includes('key=')) {
|
|
|
|
+ return null; // 或者返回其他你想要的默认值
|
|
|
|
+ }
|
|
|
|
+ const bookId = url.split('key=')[1].split('&')[0];
|
|
|
|
+ return bookId;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ return null; // 出现任何错误都返回null
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
|
|
+function getName(url) {
|
|
|
|
+ try {
|
|
|
|
+ if (!url.includes('name=')) {
|
|
|
|
+ return null; // 或者返回其他你想要的默认值
|
|
|
|
+ }
|
|
|
|
+ const bookId = url.split('name=')[1].split('&')[0];
|
|
|
|
+ return bookId;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ return null; // 出现任何错误都返回null
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function getId(url) {
|
|
|
|
+ try {
|
|
|
|
+ if (!url.includes('id=')) {
|
|
|
|
+ return null; // 或者返回其他你想要的默认值
|
|
|
|
+ }
|
|
|
|
+ const bookId = url.split('id=')[1].split('&')[0];
|
|
|
|
+ return bookId;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ return null; // 出现任何错误都返回null
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
function filter_and_insert(origin_data,tg_config,PlatformConfig){
|
|
function filter_and_insert(origin_data,tg_config,PlatformConfig){
|
|
if(origin_data.guajian_link.length<=0){
|
|
if(origin_data.guajian_link.length<=0){
|
|
return null
|
|
return null
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(helper.checkChannel(origin_data.guajian_link,"wx_gua_jian=1")){
|
|
|
|
+ PlatformConfig = getWxPlatformConfig(PlatformConfig)
|
|
|
|
+ let parent_platform_id = getWxChannel(tg_config.platform_select,origin_data.guajian_link,PlatformConfig)
|
|
|
|
+ if(parent_platform_id==null){
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
|
|
+ let params = {}
|
|
|
|
+ let url = origin_data.guajian_link
|
|
|
|
+ params['bookId'] = getBookId(url);
|
|
|
|
+ params['name'] = getName(url);
|
|
|
|
+
|
|
|
|
+ if(parent_platform_id==config.platform_fanqie){
|
|
|
|
+ params['bookId'] = getKey(url);
|
|
|
|
+ }else if(parent_platform_id==config.platform_qimao){
|
|
|
|
+ params['bookId'] = getId(url);
|
|
|
|
+ }
|
|
|
|
+ let obj = {video_id:origin_data.video_id,book_id:params['bookId'],source:params['name'],video_link:origin_data.video_link,
|
|
|
|
+ like_num:origin_data.like_num,kepp_num:origin_data.kepp_num ,shared_num:origin_data.shared_num,comment_num:origin_data.comment_num,tg_platform_id:parent_platform_id}
|
|
|
|
+ // console.log("obj:",obj)
|
|
|
|
+ return obj
|
|
|
|
+ }
|
|
let obj = parsePromotion(origin_data.guajian_link,tg_config.source_filter,tg_config.platform_select,PlatformConfig)
|
|
let obj = parsePromotion(origin_data.guajian_link,tg_config.source_filter,tg_config.platform_select,PlatformConfig)
|
|
// console.log("obj::",obj)
|
|
// console.log("obj::",obj)
|
|
if(obj==null){
|
|
if(obj==null){
|
|
@@ -138,24 +214,82 @@ function filter_and_insert(origin_data,tg_config,PlatformConfig){
|
|
tg_platform_id = 1
|
|
tg_platform_id = 1
|
|
}else if(obj.channel==3){ //"七猫"
|
|
}else if(obj.channel==3){ //"七猫"
|
|
tg_platform_id = 3
|
|
tg_platform_id = 3
|
|
|
|
+ if(obj.id==undefined||obj.id==null){
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
obj.book_id = obj.id
|
|
obj.book_id = obj.id
|
|
}else if(obj.channel==4){ //"点众"
|
|
}else if(obj.channel==4){ //"点众"
|
|
tg_platform_id = 4
|
|
tg_platform_id = 4
|
|
obj.book_id = obj.book_id
|
|
obj.book_id = obj.book_id
|
|
|
|
+ }else if(obj.channel==5){ //"书旗-"
|
|
|
|
+ tg_platform_id = 5
|
|
|
|
+ obj.book_id = obj.book_id
|
|
|
|
+ }else if(obj.channel==6){ //"阅文"
|
|
|
|
+ tg_platform_id = 6
|
|
|
|
+ obj.book_id = obj.cbid
|
|
|
|
+ }else if(obj.channel==7){ //"番茄免費"
|
|
|
|
+ tg_platform_id = 7
|
|
|
|
+ obj.book_id = obj.code
|
|
}
|
|
}
|
|
// console.log("评论数正确")
|
|
// console.log("评论数正确")
|
|
return {video_id:origin_data.video_id,book_id:obj.book_id,channel:obj.channel,source:obj.source,key:obj.key,video_link:origin_data.video_link,
|
|
return {video_id:origin_data.video_id,book_id:obj.book_id,channel:obj.channel,source:obj.source,key:obj.key,video_link:origin_data.video_link,
|
|
like_num:origin_data.like_num,kepp_num:origin_data.kepp_num ,shared_num:origin_data.shared_num,comment_num:origin_data.comment_num,tg_platform_id:tg_platform_id}
|
|
like_num:origin_data.like_num,kepp_num:origin_data.kepp_num ,shared_num:origin_data.shared_num,comment_num:origin_data.comment_num,tg_platform_id:tg_platform_id}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function getWxPlatformConfig(PlatformConfig){
|
|
|
|
+ let list = []
|
|
|
|
+ for (let index = 0; index < PlatformConfig.length; index++) {
|
|
|
|
+ const element = PlatformConfig[index];
|
|
|
|
+ if(element.mini_program_platform_id==2){
|
|
|
|
+ list.push(element)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function getDyPlatformConfig(PlatformConfig){
|
|
|
|
+ let list = []
|
|
|
|
+ for (let index = 0; index < PlatformConfig.length; index++) {
|
|
|
|
+ const element = PlatformConfig[index];
|
|
|
|
+ if(element.mini_program_platform_id==1){
|
|
|
|
+ list.push(element)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function getIsOpen(platform_select,tg_platform_id){
|
|
|
|
+ for (let index = 0; index < platform_select.length; index++) {
|
|
|
|
+ const id = platform_select[index];
|
|
|
|
+ if(tg_platform_id==id){
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function getWxChannel(platform_select,promotion,PlatformConfig){
|
|
|
|
+ for (let index = 0; index < PlatformConfig.length; index++) {
|
|
|
|
+ const platform_info = PlatformConfig[index];
|
|
|
|
+ let filter_guajian_logic_list = JSON.parse(platform_info.filter_guajian_logic_list)
|
|
|
|
+ if(getIsOpen(platform_select,platform_info.tg_platform_id)){
|
|
|
|
+ if(helper.checkChannelListKey(promotion,filter_guajian_logic_list)){
|
|
|
|
+ return platform_info.parent_platform_id
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
function getChannel(start_page,platform_select,promotion,PlatformConfig){
|
|
function getChannel(start_page,platform_select,promotion,PlatformConfig){
|
|
let isOpenHeiYan = false
|
|
let isOpenHeiYan = false
|
|
let isOpenFanQie = false
|
|
let isOpenFanQie = false
|
|
let isOpenQiMao = false
|
|
let isOpenQiMao = false
|
|
let isOpenDianZhong = false
|
|
let isOpenDianZhong = false
|
|
let kv = new Map()
|
|
let kv = new Map()
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ PlatformConfig = getDyPlatformConfig(PlatformConfig)
|
|
|
|
+ console.log("PlatformConfig:",PlatformConfig)
|
|
for (let index = 0; index < PlatformConfig.length; index++) {
|
|
for (let index = 0; index < PlatformConfig.length; index++) {
|
|
const platform_info = PlatformConfig[index];
|
|
const platform_info = PlatformConfig[index];
|
|
kv.set(platform_info.tg_platform_id,false)
|
|
kv.set(platform_info.tg_platform_id,false)
|
|
@@ -181,12 +315,18 @@ function getChannel(start_page,platform_select,promotion,PlatformConfig){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
// console.log("PlatformConfig:",PlatformConfig,kv)
|
|
// console.log("PlatformConfig:",PlatformConfig,kv)
|
|
for (let index = 0; index < PlatformConfig.length; index++) {
|
|
for (let index = 0; index < PlatformConfig.length; index++) {
|
|
const platform_info = PlatformConfig[index];
|
|
const platform_info = PlatformConfig[index];
|
|
- if(helper.checkChannel(promotion,platform_info.filter_guajian_logic)&&kv.get(platform_info.tg_platform_id)){
|
|
|
|
- return platform_info.tg_platform_id
|
|
|
|
|
|
+ let filter_guajian_logic_list = JSON.parse(platform_info.filter_guajian_logic_list)
|
|
|
|
+ if(kv.get(platform_info.tg_platform_id)==true){
|
|
|
|
+ console.log("filter_guajian_logic_list:",promotion,filter_guajian_logic_list)
|
|
|
|
+ if(helper.checkChannelListKey(promotion,filter_guajian_logic_list)){
|
|
|
|
+ return platform_info.tg_platform_id
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
return null
|
|
return null
|
|
// console.log("start_page:",isOpenHeiYan,isOpenFanQie,start_page)
|
|
// console.log("start_page:",isOpenHeiYan,isOpenFanQie,start_page)
|
|
@@ -219,13 +359,15 @@ function parsePromotion(promotion,source_list,platform_select,PlatformConfig){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let channel = getChannel(params['start_page'],platform_select,promotion,PlatformConfig)
|
|
let channel = getChannel(params['start_page'],platform_select,promotion,PlatformConfig)
|
|
- // console.log("source_list:",source_list,platform_select,channel,params['start_page'])
|
|
|
|
|
|
+ console.log("source_list:",source_list,platform_select,channel,params['start_page'])
|
|
if(channel!=null){
|
|
if(channel!=null){
|
|
|
|
+ console.log("channel:",channel,promotion)
|
|
let item_info = {}
|
|
let item_info = {}
|
|
item_info['book_id'] = params['bookId'];
|
|
item_info['book_id'] = params['bookId'];
|
|
item_info['channel'] = channel;
|
|
item_info['channel'] = channel;
|
|
item_info['id'] = params['id']
|
|
item_info['id'] = params['id']
|
|
-
|
|
|
|
|
|
+ item_info['cbid'] = params['cbid']
|
|
|
|
+ item_info['code'] = params['code']
|
|
const str = params['x-signature']
|
|
const str = params['x-signature']
|
|
const regex = /"name":"([^"]+)"/;
|
|
const regex = /"name":"([^"]+)"/;
|
|
const match = str.match(regex);
|
|
const match = str.match(regex);
|