Skip to content

Commit

Permalink
sources: fix Twitter details method returning an array
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Mar 26, 2023
1 parent b43e3eb commit c676f94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/sites/Twitter/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function parseTweetMedia(sc: any, original: any, media: any): IImage {
return d;
}

function parseTweet(sc: any, gallery: boolean): IImage {
function parseTweet(sc: any, gallery: boolean): IImage[] | IImage {
const original = sc;
if ("retweeted_status" in sc) {
sc = sc["retweeted_status"];
Expand All @@ -72,7 +72,7 @@ function parseTweet(sc: any, gallery: boolean): IImage {
return { id: original["id_str"] };
}

const medias = entities["media"];
const medias: any[] = entities["media"];
if (!medias || medias.length === 0) {
return { id: original["id_str"] };
}
Expand Down Expand Up @@ -199,9 +199,10 @@ export const source: ISource = {
url: (id: string): string => {
return "/1.1/statuses/show.json?id=" + id + "&tweet_mode=extended";
},
parse: (src: string): IParsedDetails => {
parse: (src: string): IImage => {
const data = JSON.parse(src);
return parseTweet(data, true);
const images = Grabber.makeArray(parseTweet(data, true));
return images[0];
},
},
},
Expand Down

0 comments on commit c676f94

Please sign in to comment.