emusks 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,142 @@
1
+ export default function parseUser(user) {
2
+ if (typeof user?.stats?.followers?.count === "number") {
3
+ // we can safely assume this has already been parsed
4
+ return user;
5
+ }
6
+
7
+ const get = (obj, path, fallback = undefined) =>
8
+ path
9
+ .split(".")
10
+ .reduce((o, k) => (o && o[k] !== undefined ? o[k] : fallback), obj);
11
+ const data = user.data?.user || user;
12
+
13
+ const legacy = data.legacy || data;
14
+ const core = data.core || {};
15
+ const locationObj = data.location || {};
16
+ const verification = data.verification || {};
17
+ const parodyLabel =
18
+ data.parody_commentary_fan_label || legacy.parody_commentary_fan_label;
19
+ const highlightedLabel =
20
+ get(data, "affiliates_highlighted_label.label") || data.highlightedLabel;
21
+
22
+ return {
23
+ id: data.rest_id || legacy.id_str || data.id || data.id_str,
24
+ name: core.name || legacy.name || data.name,
25
+ username:
26
+ core.screen_name ||
27
+ legacy.screen_name ||
28
+ data.screen_name ||
29
+ data.username,
30
+ description: legacy.description || data.description,
31
+ banner:
32
+ legacy.profile_banner_url ||
33
+ legacy.profile_background_image_url ||
34
+ legacy.profile_background_image_url_https ||
35
+ data.profile_banner_url ||
36
+ data.profile_background_image_url ||
37
+ data.profile_background_image_url_https,
38
+ url: legacy.url || data.url,
39
+ location: locationObj.location || legacy.location || data.location || null,
40
+ protected: get(
41
+ data,
42
+ "privacy.protected",
43
+ legacy.protected || data.protected
44
+ ),
45
+ created_at: get(core, "created_at", legacy.created_at || data.created_at),
46
+ backgroundColor:
47
+ legacy.profile_background_color || data.profile_background_color,
48
+
49
+ profile_picture: {
50
+ url:
51
+ get(data, "avatar.image_url") ||
52
+ legacy.profile_image_url_https ||
53
+ data.profile_image_url_https ||
54
+ "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
55
+ shape:
56
+ data.profile_image_shape ||
57
+ data.ext_profile_image_shape ||
58
+ legacy.profile_image_shape ||
59
+ "Circle",
60
+ },
61
+
62
+ stats: {
63
+ followers: {
64
+ count: legacy.followers_count || data.followers_count,
65
+ fast_followers:
66
+ legacy.fast_followers_count || data.fast_followers_count || 0,
67
+ normal_followers:
68
+ legacy.normal_followers_count || data.normal_followers_count,
69
+ },
70
+ following: legacy.friends_count || data.friends_count,
71
+ subscriptions_count:
72
+ data.creator_subscriptions_count ||
73
+ legacy.creator_subscriptions_count ||
74
+ 0,
75
+ likes: legacy.favourites_count || data.favourites_count,
76
+ listed: legacy.listed_count || data.listed_count,
77
+ media: legacy.media_count || data.media_count,
78
+ posts: legacy.statuses_count || data.statuses_count,
79
+ },
80
+ verification: {
81
+ verified: get(verification, "verified", legacy.verified || data.verified),
82
+ premium_verified:
83
+ data.is_blue_verified ||
84
+ data.ext_is_blue_verified ||
85
+ data.premium_verified ||
86
+ data.premium_verified_type ||
87
+ false,
88
+ },
89
+ pinned_tweets:
90
+ legacy.pinned_tweet_ids_str || data.pinned_tweet_ids_str || [],
91
+ birthdate: data.birthdate || {},
92
+ misc: {
93
+ default_profile: legacy.default_profile || data.default_profile,
94
+ default_profile_image:
95
+ legacy.default_profile_image || data.default_profile_image || false,
96
+ entities: legacy.entities || data.entities,
97
+ has_custom_timelines:
98
+ legacy.has_custom_timelines || data.has_custom_timelines,
99
+ is_translator: legacy.is_translator || data.is_translator || false,
100
+ translator_type: legacy.translator_type || data.translator_type,
101
+ is_profile_translatable: data.is_profile_translatable,
102
+ needs_phone_verification: data.needs_phone_verification,
103
+ possibly_sensitive: legacy.possibly_sensitive || data.possibly_sensitive,
104
+ profile_interstitial_type:
105
+ legacy.profile_interstitial_type || data.profile_interstitial_type,
106
+ want_retweets: legacy.want_retweets || data.want_retweets,
107
+ withheld_in_countries:
108
+ legacy.withheld_in_countries || data.withheld_in_countries || [],
109
+ tipjar_settings: data.tipjar_settings || {},
110
+ can_dm: get(data, "dm_permissions.can_dm", data.can_dm),
111
+ can_media_tag: get(
112
+ data,
113
+ "media_permissions.can_media_tag",
114
+ data.can_media_tag
115
+ ),
116
+ blocked_by: get(
117
+ data,
118
+ "relationship_perspectives.followed_by",
119
+ data.blocked_by
120
+ ),
121
+ blocking: data.blocking,
122
+ following: get(
123
+ data,
124
+ "relationship_perspectives.following",
125
+ data.following
126
+ ),
127
+ muting: data.muting,
128
+ has_graduated_access: data.has_graduated_access,
129
+ geo_enabled: data.geo_enabled,
130
+
131
+ advertising: {
132
+ service_levels: data.advertiser_account_service_levels || [],
133
+ account_type: data.advertiser_account_type || "none",
134
+ },
135
+ },
136
+
137
+ labels: {
138
+ parody_commentary_fan_label: parodyLabel || "None",
139
+ highlightedLabel: highlightedLabel,
140
+ },
141
+ };
142
+ }
@@ -0,0 +1,23 @@
1
+ export default {
2
+ "accept-language": "en-US,en;q=0.9",
3
+ "cache-control": "no-cache",
4
+ priority: "u=0, i",
5
+ pragma: "no-cache",
6
+ "sec-ch-ua": '"Chromium";v="137", "Not/A)Brand";v="24"',
7
+ "sec-ch-ua-arch": '"arm"',
8
+ "sec-ch-ua-bitness": '"64"',
9
+ "sec-ch-ua-full-version": '"137.0.7151.104"',
10
+ "sec-ch-ua-full-version-list":
11
+ '"Chromium";v="137.0.7151.104", "Not/A)Brand";v="24.0.0.0"',
12
+ "sec-ch-ua-mobile": "?0",
13
+ "sec-ch-ua-model": '""',
14
+ "sec-ch-ua-platform": '"macOS"',
15
+ "sec-ch-ua-platform-version": '"16.0.0"',
16
+ "sec-fetch-dest": "document",
17
+ "sec-fetch-mode": "navigate",
18
+ "sec-fetch-site": "same-origin",
19
+ "sec-fetch-user": "?1",
20
+ "upgrade-insecure-requests": "1",
21
+ "User-Agent":
22
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
23
+ };