diff --git a/pugongying/xhs-pgy-export.user.js b/pugongying/xhs-pgy-export.user.js index 218bc4a..0d0806b 100644 --- a/pugongying/xhs-pgy-export.user.js +++ b/pugongying/xhs-pgy-export.user.js @@ -31,7 +31,11 @@ const FIELD_LABEL_MAP = { id: "ID", fansProfile: "粉丝画像", - "fansProfile.ages": "粉丝年龄分布", + "fansProfile.ages.<18": "18岁以下粉丝占比", + "fansProfile.ages.18-24": "18-24岁粉丝占比", + "fansProfile.ages.25-34": "25-34岁粉丝占比", + "fansProfile.ages.35-44": "35-44岁粉丝占比", + "fansProfile.ages.>44": "44岁以上粉丝占比", "fansProfile.gender.male": "粉丝男性占比", "fansProfile.gender.female": "粉丝女性占比", userId: "达人ID", @@ -142,7 +146,19 @@ const value = record[key]; if (Array.isArray(value)) { - baseTarget[nextPath] = summarizeArray(value); + if ( + value.length && + value.every( + (item) => + isPlainObject(item) && "group" in item && "percent" in item, + ) + ) { + for (const item of value) { + baseTarget[`${nextPath}.${item.group}`] = item.percent; + } + } else { + baseTarget[nextPath] = summarizeArray(value); + } continue; }