Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 抖音添加获取热点api、获取位置api。小红书添加获取位置api
gaoSira946917c071f
diff --git a/electron/plat/douyin/douyin.type.ts b/electron/plat/douyin/douyin.type.tsindex 66b89486..e0f231d2 100644--- a/electron/plat/douyin/douyin.type.ts+++ b/electron/plat/douyin/douyin.type.ts@@ -23,6 +23,158 @@ interface LogPb {impr_id: string;}+interface AddressInfo {+ ad_code_v2: string;+ addr_with_extra_info: string;+ address: string;+ city: string;+ city_code: string;+ district: string;+ im_addr: string;+ province: string;+ simple_addr: string;+}++interface Cover {+ uri: string;+ url_list: string[];+}++interface Icon {+ uri: string;+ url_list: string[];+}++interface LifeCommerceInfo {+ simple_addr_str: string;+}++interface PoiBackendType {+ code: string;+ content: string;+ l1_name: string;+ l2_name: string;+ l3_name: string;+ name: string;+}++interface PoiFrontendType {+ code: string;+ name: string;+}++interface ShareInfo {+ bool_persist: number;+ share_title: string;+ share_url: string;+ share_weibo_desc: string;+}++interface Poi {+ Staturated_tags: any;+ address_info: AddressInfo;+ anchor_post_ext: {+ is_recommend: boolean;+ };+ business_area_name: string;+ channel_exclusive: any;+ collect_stat: number;+ collected_count: string;+ cost: number;+ cover_hd: Cover;+ cover_item: Cover;+ cover_large: Cover;+ cover_medium: Cover;+ cover_thumb: Cover;+ cps_commission_rate_range: any;+ cps_commission_value_range: any;+ distance: string;+ effect_ids: string[];+ expand_type: number;+ fulfill_task_list: any;+ icon_on_entry: Icon;+ icon_on_info: Icon;+ icon_on_map: Icon;+ icon_service_type_list: any;+ icon_type: number;+ is_admin_area: boolean;+ is_commerce_intention: boolean;+ item_count: number;+ life_commerce_info: LifeCommerceInfo;+ poi_backend_type: PoiBackendType;+ poi_detail_tags: any;+ poi_frontend_type: PoiFrontendType[];+ poi_id: string;+ poi_latitude: number;+ poi_latitude_gcj02: number;+ poi_longitude: number;+ poi_longitude_gcj02: number;+ poi_name: string;+ poi_ranks: any;+ poi_search_tags: any;+ poi_search_tags_v2: any;+ poi_type: number;+ poi_voucher: string;+ service_type_list: any;+ share_info: ShareInfo;+ show_type: number;+ simple_address_str: string;+ type_code: string;+ user_count: number;+ view_count: string;+ voucher_release_areas: any[];+ with_recommend_tag: number;+}++interface ContentTab {+ default_tab: number;+ tab_list: number[];+}++interface GuideInfo {+ guide_text_after: string;+ guide_text_before: string;+ guide_url: string;+}++interface DriftInfo {+ score: number;+ timestamp: number;+}++interface Cover {+ uri: string;+ url_list: string[];+}++interface Sentence {+ aweme_infos: any;+ challenge_id: string;+ display_style: number;+ drift_info: DriftInfo[];+ event_time: number;+ group_id: string;+ hot_value: number;+ hotlist_param: string;+ label: number;+ related_words: any;+ sentence_id: string;+ video_count: number;+ word: string;+ word_cover: Cover;+ word_sub_board: any;+ word_type: number;+}++// 抖音的热点数据+export interface DouyinHotDataResponse {+ extra: Extra;+ log_pb: LogPb;+ sentences: Sentence[];+ status_code: number;+}++// 抖音的话题数据export interface DouyinTopicsSugResponse {sug_list: TopicSug[];status_code: number;@@ -32,3 +184,27 @@ export interface DouyinTopicsSugResponse {extra: Extra;log_pb: LogPb;}++// 抖音的位置数据+export interface DouyinLocationDataResponse {+ ab_param_extra: string;+ content_tab: ContentTab;+ current_locs: any[];+ extra: Extra;+ guide_info: GuideInfo;+ has_keyuser_combo_entrance: boolean;+ has_more: number;+ has_promote_auth: boolean;+ log_pb: LogPb;+ page: number;+ poi_activity: any;+ poi_list: Poi[];+ poi_search_range: number[];+ post_role: number;+ show_filter_option: boolean;+ show_guide: boolean;+ show_new_merchant_guide: boolean;+ status_code: number;+ status_msg: string;+ user_interest_city_code_list: any;+}diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.tsindex 13a9bcaa..f60febd6 100644--- a/electron/plat/douyin/index.ts+++ b/electron/plat/douyin/index.ts@@ -7,8 +7,12 @@ import { v4 as uuidv4 } from 'uuid';// @ts-ignoreimport crc32 from 'crc32';import { getFileContent } from '../utils';-import { DouyinTopicsSugResponse } from './douyin.type';+import {+ DouyinLocationDataResponse,+ DouyinTopicsSugResponse,+} from './douyin.type';import requestNet from '../requestNet';+import { jsonToQueryString } from '../../util';export class DouyinService {private defaultUserAgent =@@ -1993,6 +1997,35 @@ export class DouyinService {method: 'GET',});}++ // 获取位置数据+ async getLocation(params: {+ keywords: string;+ latitude: string;+ longitude: string;+ }) {+ return await requestNet<DouyinLocationDataResponse>({+ url: `${this.loginUrl}aweme/v1/life/video_api/search/poi/?${jsonToQueryString(+ {+ ...params,+ page: 1,+ from_webapp: 1,+ },+ )}`,+ method: 'GET',+ });+ }++ // 获取热点数据+ async getHotspotData(params: { query: string }) {+ return await requestNet<DouyinLocationDataResponse>({+ url: `${this.loginUrl}aweme/v1/hotspot/search/?${jsonToQueryString({+ ...params,+ count: 50,+ })}`,+ method: 'GET',+ });+ }}// 导出服务实例diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.tsindex 5c8466da..364bd7b5 100644--- a/electron/plat/xiaohongshu/index.ts+++ b/electron/plat/xiaohongshu/index.ts@@ -5,7 +5,7 @@ import { CommonUtils } from '../../util/common';import { FileUtils } from '../../util/file';import { getFileContent } from '../utils';import requestNet from '../requestNet';-import { IXHSTopicsResponse } from './xiaohongshu.type';+import { IXHSLocationResponse, IXHSTopicsResponse } from './xiaohongshu.type';export class XiaohongshuService {private defaultUserAgent =@@ -1254,7 +1254,7 @@ export class XiaohongshuService {});}- // 获取话题+ // 获取话题数据async getTopics({keyword,cookies,@@ -1281,6 +1281,26 @@ export class XiaohongshuService {},});}++ // 获取位置数据+ async getLocations(params: {+ latitude: number;+ longitude: number;+ keyword: string;+ page?: number;+ size?: number;+ source: string;+ type: number;+ }) {+ return await requestNet<IXHSLocationResponse>({+ url: 'https://edith.xiaohongshu.com/web_api/sns/v1/local/poi/creator/search',+ body: {+ ...params,+ page: 1,+ size: 50,+ },+ });+ }}// 导出服务实例diff --git a/electron/plat/xiaohongshu/xiaohongshu.type.ts b/electron/plat/xiaohongshu/xiaohongshu.type.tsindex 1c1a5e17..a436b263 100644--- a/electron/plat/xiaohongshu/xiaohongshu.type.ts+++ b/electron/plat/xiaohongshu/xiaohongshu.type.ts@@ -16,10 +16,32 @@ interface TopicsData {result: TopicsResult;}-// 话题接口返回数据-export interface IXHSTopicsResponse {+interface CommonResponse<T> {code: number;success: boolean;msg: string;- data: TopicsData;+ data: T;}++interface Poi {+ poi_id: string;+ poi_type: number;+ city_name: string;+ longitude: number;+ type: string;+ address: string;+ name: string;+ full_address: string;+ latitude: number;+}++interface LocationData {+ poi_list: Poi[];+ search_context: string;+}++// 话题列表返回值+export type IXHSTopicsResponse = CommonResponse<TopicsData>;++// 地点列表返回值+export type IXHSLocationResponse = CommonResponse<LocationData>;diff --git a/electron/util/index.ts b/electron/util/index.tsindex 477ebd2e..784edc7c 100644--- a/electron/util/index.ts+++ b/electron/util/index.ts@@ -43,3 +43,10 @@ export const getAssetPath = (...paths: string[]): string => {return path.join(RESOURCES_PATH, ...paths);};++// json转 a=1&b=2 格式+export function jsonToQueryString(json: Record<string, any>): string {+ return Object.keys(json)+ .map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(json[key]))+ .join('&');+}