feat: add media extraction support for photos, videos, and GIFs
This commit is contained in:
committed by
Peter Steinberger
parent
e537e102e3
commit
067c98c245
@@ -1,5 +1,28 @@
|
||||
import type { TwitterCookies } from './cookies.js';
|
||||
|
||||
// Raw media entity from Twitter API
|
||||
export interface GraphqlMediaEntity {
|
||||
id_str?: string;
|
||||
media_url_https?: string;
|
||||
type?: 'photo' | 'video' | 'animated_gif';
|
||||
url?: string;
|
||||
expanded_url?: string;
|
||||
sizes?: {
|
||||
thumb?: { w: number; h: number; resize: string };
|
||||
small?: { w: number; h: number; resize: string };
|
||||
medium?: { w: number; h: number; resize: string };
|
||||
large?: { w: number; h: number; resize: string };
|
||||
};
|
||||
video_info?: {
|
||||
duration_millis?: number;
|
||||
variants?: Array<{
|
||||
bitrate?: number;
|
||||
content_type?: string;
|
||||
url?: string;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
export type GraphqlTweetResult = {
|
||||
__typename?: string;
|
||||
rest_id?: string;
|
||||
@@ -11,6 +34,12 @@ export type GraphqlTweetResult = {
|
||||
favorite_count?: number;
|
||||
conversation_id_str?: string;
|
||||
in_reply_to_status_id_str?: string | null;
|
||||
entities?: {
|
||||
media?: GraphqlMediaEntity[];
|
||||
};
|
||||
extended_entities?: {
|
||||
media?: GraphqlMediaEntity[];
|
||||
};
|
||||
};
|
||||
core?: {
|
||||
user_results?: {
|
||||
@@ -168,6 +197,18 @@ export interface UploadMediaResult {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// Parsed media item for output
|
||||
export interface TweetMedia {
|
||||
type: 'photo' | 'video' | 'animated_gif';
|
||||
url: string;
|
||||
previewUrl?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
// For video/animated_gif: best quality video URL
|
||||
videoUrl?: string;
|
||||
durationMs?: number;
|
||||
}
|
||||
|
||||
export interface TweetData {
|
||||
id: string;
|
||||
text: string;
|
||||
@@ -184,9 +225,8 @@ export interface TweetData {
|
||||
inReplyToStatusId?: string;
|
||||
// Optional quoted tweet; depth controlled by quoteDepth (default: 1).
|
||||
quotedTweet?: TweetData;
|
||||
// Raw GraphQL response (included when --json-full is used).
|
||||
// Structure may change as Twitter's API evolves.
|
||||
_raw?: GraphqlTweetResult;
|
||||
// Media attachments (photos, videos, GIFs)
|
||||
media?: TweetMedia[];
|
||||
}
|
||||
|
||||
export interface GetTweetResult {
|
||||
@@ -237,27 +277,6 @@ export interface TwitterClientOptions {
|
||||
quoteDepth?: number;
|
||||
}
|
||||
|
||||
export interface TwitterList {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
memberCount?: number;
|
||||
subscriberCount?: number;
|
||||
isPrivate?: boolean;
|
||||
createdAt?: string;
|
||||
owner?: {
|
||||
id: string;
|
||||
username: string;
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ListsResult {
|
||||
success: boolean;
|
||||
lists?: TwitterList[];
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface CreateTweetResponse {
|
||||
data?: {
|
||||
create_tweet?: {
|
||||
|
||||
Reference in New Issue
Block a user