emusks 2.0.3 → 2.0.5

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.
@@ -1,129 +1,127 @@
1
1
  import parseTimeline from "../parsers/timeline.js";
2
2
 
3
- export default (client) => ({
4
- async tweets(query, opts = {}) {
5
- const raw = await client.graphql("SearchTimeline", {
6
- variables: {
7
- rawQuery: query,
8
- count: opts.count || 20,
9
- cursor: opts.cursor,
10
- querySource: opts.querySource || "typed_query",
11
- product: opts.product || "Top",
12
- ...opts.variables,
13
- },
14
- fieldToggles: {
15
- withArticlePlainText: false,
16
- withArticleRichContentState: false,
17
- withAuxiliaryUserLabels: false,
18
- },
19
- });
20
- return parseTimeline(raw);
21
- },
3
+ export async function tweets(query, opts = {}) {
4
+ const raw = await this.graphql("SearchTimeline", {
5
+ variables: {
6
+ rawQuery: query,
7
+ count: opts.count || 20,
8
+ cursor: opts.cursor,
9
+ querySource: opts.querySource || "typed_query",
10
+ product: opts.product || "Top",
11
+ ...opts.variables,
12
+ },
13
+ fieldToggles: {
14
+ withArticlePlainText: false,
15
+ withArticleRichContentState: false,
16
+ withAuxiliaryUserLabels: false,
17
+ },
18
+ });
19
+ return parseTimeline(raw);
20
+ }
22
21
 
23
- async users(query, opts = {}) {
24
- const raw = await client.graphql("SearchTimeline", {
25
- variables: {
26
- rawQuery: query,
27
- count: opts.count || 20,
28
- cursor: opts.cursor,
29
- querySource: opts.querySource || "typed_query",
30
- product: "People",
31
- ...opts.variables,
32
- },
33
- });
34
- return parseTimeline(raw);
35
- },
22
+ export async function users(query, opts = {}) {
23
+ const raw = await this.graphql("SearchTimeline", {
24
+ variables: {
25
+ rawQuery: query,
26
+ count: opts.count || 20,
27
+ cursor: opts.cursor,
28
+ querySource: opts.querySource || "typed_query",
29
+ product: "People",
30
+ ...opts.variables,
31
+ },
32
+ });
33
+ return parseTimeline(raw);
34
+ }
36
35
 
37
- async media(query, opts = {}) {
38
- const raw = await client.graphql("SearchTimeline", {
39
- variables: {
40
- rawQuery: query,
41
- count: opts.count || 20,
42
- cursor: opts.cursor,
43
- querySource: opts.querySource || "typed_query",
44
- product: "Media",
45
- ...opts.variables,
46
- },
47
- });
48
- return parseTimeline(raw);
49
- },
36
+ export async function media(query, opts = {}) {
37
+ const raw = await this.graphql("SearchTimeline", {
38
+ variables: {
39
+ rawQuery: query,
40
+ count: opts.count || 20,
41
+ cursor: opts.cursor,
42
+ querySource: opts.querySource || "typed_query",
43
+ product: "Media",
44
+ ...opts.variables,
45
+ },
46
+ });
47
+ return parseTimeline(raw);
48
+ }
50
49
 
51
- async latest(query, opts = {}) {
52
- const raw = await client.graphql("SearchTimeline", {
53
- variables: {
54
- rawQuery: query,
55
- count: opts.count || 20,
56
- cursor: opts.cursor,
57
- querySource: opts.querySource || "typed_query",
58
- product: "Latest",
59
- ...opts.variables,
60
- },
61
- });
62
- return parseTimeline(raw);
63
- },
50
+ export async function latest(query, opts = {}) {
51
+ const raw = await this.graphql("SearchTimeline", {
52
+ variables: {
53
+ rawQuery: query,
54
+ count: opts.count || 20,
55
+ cursor: opts.cursor,
56
+ querySource: opts.querySource || "typed_query",
57
+ product: "Latest",
58
+ ...opts.variables,
59
+ },
60
+ });
61
+ return parseTimeline(raw);
62
+ }
64
63
 
65
- async lists(query, opts = {}) {
66
- const raw = await client.graphql("SearchTimeline", {
67
- variables: {
68
- rawQuery: query,
69
- count: opts.count || 20,
70
- cursor: opts.cursor,
71
- querySource: opts.querySource || "typed_query",
72
- product: "Lists",
73
- ...opts.variables,
74
- },
75
- });
76
- return parseTimeline(raw);
77
- },
64
+ export async function lists(query, opts = {}) {
65
+ const raw = await this.graphql("SearchTimeline", {
66
+ variables: {
67
+ rawQuery: query,
68
+ count: opts.count || 20,
69
+ cursor: opts.cursor,
70
+ querySource: opts.querySource || "typed_query",
71
+ product: "Lists",
72
+ ...opts.variables,
73
+ },
74
+ });
75
+ return parseTimeline(raw);
76
+ }
78
77
 
79
- async typeahead(query, params = {}) {
80
- const res = await client.v1_1("search/typeahead", {
81
- params: {
82
- q: query,
83
- src: params.src || "search_box",
84
- result_type: params.result_type || "events,users,topics,lists",
85
- ...params,
86
- },
87
- });
88
- return await res.json();
89
- },
78
+ export async function typeahead(query, params = {}) {
79
+ const res = await this.v1_1("search/typeahead", {
80
+ params: {
81
+ q: query,
82
+ src: params.src || "search_box",
83
+ result_type: params.result_type || "events,users,topics,lists",
84
+ ...params,
85
+ },
86
+ });
87
+ return await res.json();
88
+ }
90
89
 
91
- async adaptive(query, params = {}) {
92
- const res = await client.v2("search/adaptive", {
93
- params: {
94
- q: query,
95
- count: params.count || 20,
96
- query_source: params.query_source || "typed_query",
97
- pc: params.pc || 1,
98
- spelling_corrections: params.spelling_corrections || 1,
99
- include_ext_edit_control: true,
100
- ...params,
101
- },
102
- });
103
- return await res.json();
104
- },
90
+ export async function adaptive(query, params = {}) {
91
+ const res = await this.v2("search/adaptive", {
92
+ params: {
93
+ q: query,
94
+ count: params.count || 20,
95
+ query_source: params.query_source || "typed_query",
96
+ pc: params.pc || 1,
97
+ spelling_corrections: params.spelling_corrections || 1,
98
+ include_ext_edit_control: true,
99
+ ...params,
100
+ },
101
+ });
102
+ return await res.json();
103
+ }
105
104
 
106
- async communities(query, opts = {}) {
107
- const raw = await client.graphql("GlobalCommunitiesPostSearchTimeline", {
108
- variables: {
109
- rawQuery: query,
110
- count: opts.count || 20,
111
- cursor: opts.cursor,
112
- ...opts.variables,
113
- },
114
- });
115
- return parseTimeline(raw);
116
- },
105
+ export async function communities(query, opts = {}) {
106
+ const raw = await this.graphql("GlobalCommunitiesPostSearchTimeline", {
107
+ variables: {
108
+ rawQuery: query,
109
+ count: opts.count || 20,
110
+ cursor: opts.cursor,
111
+ ...opts.variables,
112
+ },
113
+ });
114
+ return parseTimeline(raw);
115
+ }
117
116
 
118
- async communitiesLatest(query, opts = {}) {
119
- const raw = await client.graphql("GlobalCommunitiesLatestPostSearchTimeline", {
120
- variables: {
121
- rawQuery: query,
122
- count: opts.count || 20,
123
- cursor: opts.cursor,
124
- ...opts.variables,
125
- },
126
- });
127
- return parseTimeline(raw);
128
- },
129
- });
117
+ export async function communitiesLatest(query, opts = {}) {
118
+ const raw = await this.graphql("GlobalCommunitiesLatestPostSearchTimeline", {
119
+ variables: {
120
+ rawQuery: query,
121
+ count: opts.count || 20,
122
+ cursor: opts.cursor,
123
+ ...opts.variables,
124
+ },
125
+ });
126
+ return parseTimeline(raw);
127
+ }
@@ -1,55 +1,53 @@
1
- export default (client) => ({
2
- async get(spaceId) {
3
- return await client.graphql("AudioSpaceById", {
4
- variables: {
5
- id: spaceId,
6
- isMetatagsQuery: false,
7
- withReplays: true,
8
- withListeners: true,
9
- },
10
- });
11
- },
1
+ export async function get(spaceId) {
2
+ return await this.graphql("AudioSpaceById", {
3
+ variables: {
4
+ id: spaceId,
5
+ isMetatagsQuery: false,
6
+ withReplays: true,
7
+ withListeners: true,
8
+ },
9
+ });
10
+ }
12
11
 
13
- async search(query, opts = {}) {
14
- return await client.graphql("AudioSpaceSearch", {
15
- variables: {
16
- query,
17
- count: opts.count || 20,
18
- cursor: opts.cursor,
19
- ...opts.variables,
20
- },
21
- });
22
- },
12
+ export async function search(query, opts = {}) {
13
+ return await this.graphql("AudioSpaceSearch", {
14
+ variables: {
15
+ query,
16
+ count: opts.count || 20,
17
+ cursor: opts.cursor,
18
+ ...opts.variables,
19
+ },
20
+ });
21
+ }
23
22
 
24
- async browseTopics(opts = {}) {
25
- return await client.graphql("BrowseSpaceTopics", {
26
- variables: {
27
- ...opts.variables,
28
- },
29
- });
30
- },
23
+ export async function browseTopics(opts = {}) {
24
+ return await this.graphql("BrowseSpaceTopics", {
25
+ variables: {
26
+ ...opts.variables,
27
+ },
28
+ });
29
+ }
31
30
 
32
- async subscribe(spaceId) {
33
- return await client.graphql("SubscribeToScheduledSpace", {
34
- body: { variables: { space_id: spaceId } },
35
- });
36
- },
31
+ export async function subscribe(spaceId) {
32
+ return await this.graphql("SubscribeToScheduledSpace", {
33
+ body: { variables: { space_id: spaceId } },
34
+ });
35
+ }
37
36
 
38
- async unsubscribe(spaceId) {
39
- return await client.graphql("UnsubscribeFromScheduledSpace", {
40
- body: { variables: { space_id: spaceId } },
41
- });
42
- },
37
+ export async function unsubscribe(spaceId) {
38
+ return await this.graphql("UnsubscribeFromScheduledSpace", {
39
+ body: { variables: { space_id: spaceId } },
40
+ });
41
+ }
43
42
 
44
- async addSharing(spaceId) {
45
- return await client.graphql("AudioSpaceAddSharing", {
46
- body: { variables: { space_id: spaceId } },
47
- });
48
- },
43
+ export async function addSharing(spaceId) {
44
+ return await this.graphql("AudioSpaceAddSharing", {
45
+ body: { variables: { space_id: spaceId } },
46
+ });
47
+ }
49
48
 
50
- async deleteSharing(spaceId) {
51
- return await client.graphql("AudioSpaceDeleteSharing", {
52
- body: { variables: { space_id: spaceId } },
53
- });
54
- },
55
- });
49
+ export async function deleteSharing(spaceId) {
50
+ return await this.graphql("AudioSpaceDeleteSharing", {
51
+ body: { variables: { space_id: spaceId } },
52
+ });
53
+ }
@@ -1,33 +1,31 @@
1
1
  import getCycleTLS from "../cycletls.js";
2
2
 
3
- export default (client) => ({
4
- async getTweet(tweetId) {
5
- const token = ((Number(tweetId) / 1e15) * Math.PI).toString(36).replace(/(0+|\.)/g, "");
3
+ export async function getTweet(tweetId) {
4
+ const token = ((Number(tweetId) / 1e15) * Math.PI).toString(36).replace(/(0+|\.)/g, "");
6
5
 
7
- const features = `tfw_timeline_list:;tfw_tweet_edit_backend:on;tfw_refsrc_session:on;tfw_fosnr_soft_interventions_enabled:on;tfw_mixed_media_15897:treatment;tfw_experiments_cookie_expiration:1209600;tfw_show_birdwatch_pivots_enabled:on;tfw_duplicate_scribes_to_settings:on;tfw_use_profile_image_shape_enabled:on;tfw_video_hls_dynamic_manifests_15082:true_bitrate;tfw_tweet_edit_frontend:on`;
6
+ const features = "tfw_timeline_list:;tfw_tweet_edit_backend:on;tfw_refsrc_session:on;tfw_fosnr_soft_interventions_enabled:on;tfw_mixed_media_15897:treatment;tfw_experiments_cookie_expiration:1209600;tfw_show_birdwatch_pivots_enabled:on;tfw_duplicate_scribes_to_settings:on;tfw_use_profile_image_shape_enabled:on;tfw_video_hls_dynamic_manifests_15082:true_bitrate;tfw_tweet_edit_frontend:on";
8
7
 
9
- const url = `https://cdn.syndication.twimg.com/tweet-result?id=${tweetId}&lang=en&token=${token}&features=${encodeURIComponent(features)}`;
8
+ const url = `https://cdn.syndication.twimg.com/tweet-result?id=${tweetId}&lang=en&token=${token}&features=${encodeURIComponent(features)}`;
10
9
 
11
- try {
12
- const cycleTLS = await getCycleTLS();
10
+ try {
11
+ const cycleTLS = await getCycleTLS();
13
12
 
14
- const res = await cycleTLS(url, {
15
- headers: {
16
- accept: "application/json, text/plain, */*",
17
- },
18
- userAgent: client.fingerprints?.userAgent,
19
- ja3: client.fingerprints?.ja3,
20
- ja4r: client.fingerprints?.ja4r,
21
- proxy: client.proxy || undefined,
22
- timeout: 3000,
23
- }, "GET");
13
+ const res = await cycleTLS(url, {
14
+ headers: {
15
+ accept: "application/json, text/plain, */*",
16
+ },
17
+ userAgent: this.auth?.client?.fingerprints?.userAgent,
18
+ ja3: this.auth?.client?.fingerprints?.ja3,
19
+ ja4r: this.auth?.client?.fingerprints?.ja4r,
20
+ proxy: this.proxy || undefined,
21
+ timeout: 3000,
22
+ }, "GET");
24
23
 
25
- if (!res || res.status !== 200) return null;
24
+ if (!res || res.status !== 200) return null;
26
25
 
27
- return await res.json();
28
- } catch (e) {
29
- console.warn(e);
30
- return null;
31
- }
32
- },
33
- });
26
+ return await res.json();
27
+ } catch (e) {
28
+ console.warn(e);
29
+ return null;
30
+ }
31
+ }
@@ -1,84 +1,82 @@
1
1
  import parseTimeline from "../parsers/timeline.js";
2
2
 
3
- export default (client) => ({
4
- async home(opts = {}) {
5
- const raw = await client.graphql("HomeTimeline", {
6
- variables: {
7
- count: opts.count || 20,
8
- cursor: opts.cursor,
9
- includePromotedContent: true,
10
- latestControlAvailable: true,
11
- requestContext: "launch",
12
- withCommunity: true,
13
- ...opts.variables,
14
- },
15
- fieldToggles: {
16
- withArticlePlainText: false,
17
- withArticleRichContentState: false,
18
- withAuxiliaryUserLabels: false,
19
- },
20
- });
21
- return parseTimeline(raw);
22
- },
3
+ export async function home(opts = {}) {
4
+ const raw = await this.graphql("HomeTimeline", {
5
+ variables: {
6
+ count: opts.count || 20,
7
+ cursor: opts.cursor,
8
+ includePromotedContent: true,
9
+ latestControlAvailable: true,
10
+ requestContext: "launch",
11
+ withCommunity: true,
12
+ ...opts.variables,
13
+ },
14
+ fieldToggles: {
15
+ withArticlePlainText: false,
16
+ withArticleRichContentState: false,
17
+ withAuxiliaryUserLabels: false,
18
+ },
19
+ });
20
+ return parseTimeline(raw);
21
+ }
23
22
 
24
- async homeLatest(opts = {}) {
25
- const raw = await client.graphql("HomeLatestTimeline", {
26
- variables: {
27
- count: opts.count || 20,
28
- cursor: opts.cursor,
29
- includePromotedContent: true,
30
- latestControlAvailable: true,
31
- requestContext: "launch",
32
- withCommunity: true,
33
- ...opts.variables,
34
- },
35
- fieldToggles: {
36
- withArticlePlainText: false,
37
- withArticleRichContentState: false,
38
- withAuxiliaryUserLabels: false,
39
- },
40
- });
41
- return parseTimeline(raw);
42
- },
23
+ export async function homeLatest(opts = {}) {
24
+ const raw = await this.graphql("HomeLatestTimeline", {
25
+ variables: {
26
+ count: opts.count || 20,
27
+ cursor: opts.cursor,
28
+ includePromotedContent: true,
29
+ latestControlAvailable: true,
30
+ requestContext: "launch",
31
+ withCommunity: true,
32
+ ...opts.variables,
33
+ },
34
+ fieldToggles: {
35
+ withArticlePlainText: false,
36
+ withArticleRichContentState: false,
37
+ withAuxiliaryUserLabels: false,
38
+ },
39
+ });
40
+ return parseTimeline(raw);
41
+ }
43
42
 
44
- async connect(opts = {}) {
45
- const raw = await client.graphql("ConnectTabTimeline", {
46
- variables: {
47
- count: opts.count || 20,
48
- cursor: opts.cursor,
49
- context: "{}",
50
- ...opts.variables,
51
- },
52
- });
53
- return parseTimeline(raw);
54
- },
43
+ export async function connect(opts = {}) {
44
+ const raw = await this.graphql("ConnectTabTimeline", {
45
+ variables: {
46
+ count: opts.count || 20,
47
+ cursor: opts.cursor,
48
+ context: "{}",
49
+ ...opts.variables,
50
+ },
51
+ });
52
+ return parseTimeline(raw);
53
+ }
55
54
 
56
- async moderated(opts = {}) {
57
- const raw = await client.graphql("ModeratedTimeline", {
58
- variables: {
59
- count: opts.count || 20,
60
- cursor: opts.cursor,
61
- includePromotedContent: false,
62
- ...opts.variables,
63
- },
64
- fieldToggles: {
65
- withArticlePlainText: false,
66
- withArticleRichContentState: false,
67
- withAuxiliaryUserLabels: false,
68
- },
69
- });
70
- return parseTimeline(raw);
71
- },
55
+ export async function moderated(opts = {}) {
56
+ const raw = await this.graphql("ModeratedTimeline", {
57
+ variables: {
58
+ count: opts.count || 20,
59
+ cursor: opts.cursor,
60
+ includePromotedContent: false,
61
+ ...opts.variables,
62
+ },
63
+ fieldToggles: {
64
+ withArticlePlainText: false,
65
+ withArticleRichContentState: false,
66
+ withAuxiliaryUserLabels: false,
67
+ },
68
+ });
69
+ return parseTimeline(raw);
70
+ }
72
71
 
73
- async creatorSubscriptions(opts = {}) {
74
- const raw = await client.graphql("CreatorSubscriptionsTimeline", {
75
- variables: {
76
- count: opts.count || 20,
77
- cursor: opts.cursor,
78
- includePromotedContent: false,
79
- ...opts.variables,
80
- },
81
- });
82
- return parseTimeline(raw);
83
- },
84
- });
72
+ export async function creatorSubscriptions(opts = {}) {
73
+ const raw = await this.graphql("CreatorSubscriptionsTimeline", {
74
+ variables: {
75
+ count: opts.count || 20,
76
+ cursor: opts.cursor,
77
+ includePromotedContent: false,
78
+ ...opts.variables,
79
+ },
80
+ });
81
+ return parseTimeline(raw);
82
+ }