Skip to content

Commit

Permalink
Add support for user IDs on Twitter with 'user_id:ID'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jun 15, 2022
1 parent 6801927 commit 5855f18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docs/_sources/twitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ The only known working URL for this source is:

## Search syntax

* `Username`: get all media for a given user
* `list:LIST_ID`: get all media for a given list
* `Username`: get all media for a given user handle
* `user_id:ID`: get all media for a given user ID
* `list_id:ID`: get all media for a given list ID
* `retweets:{yes,no}`: whether to also get media from retweets (default: `yes`)
* `replies:{yes,no}`: whether to also get media from replies (default: `yes`)
13 changes: 9 additions & 4 deletions src/sites/Twitter/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ function parseTweet(sc: any, gallery: boolean): IImage {
}

const meta: ISource["meta"] = {
list: {
user_id: {
type: "input",
},
list_id: {
type: "input",
},
retweets: {
Expand Down Expand Up @@ -142,10 +145,10 @@ export const source: ISource = {
];

// List lookup
if (search.list) {
if (search.list_id) {
const params = [
...commonParams,
"list_id=" + search.list,
"list_id=" + search.list_id,
];
return "/1.1/lists/statuses.json?" + params.join("&") + pageUrl;
}
Expand All @@ -154,7 +157,9 @@ export const source: ISource = {
const params = [
...commonParams,
"exclude_replies=" + (!search.replies ? "true" : "false"),
"screen_name=" + encodeURIComponent(search.query),
search.user_id
? "user_id=" + search.user_id
: "screen_name=" + encodeURIComponent(search.query),
];
return "/1.1/statuses/user_timeline.json?" + params.join("&") + pageUrl;
} catch (e: any) {
Expand Down

0 comments on commit 5855f18

Please sign in to comment.