Skip to content

Customize min wait time between status checks when uploading a media #7

@Micka33

Description

@Micka33

Context

When uploading a media (GIF or Video). Twitter will always process the media.

Currently, in src/api/media.ts#L278, the condition to wait between two upload status checks of an uploaded media is:

// Wait for the recommended time before checking again
const checkAfterSecs = data.processing_info?.check_after_secs || 1;
await new Promise(resolve => setTimeout(resolve, checkAfterSecs * 1000));

If a media takes 30 seconds to be processed by X and X leaves data.processing_info?.check_after_secs empty or always returns 5, then we will make between 6 to 30 additional API calls.

Given:

  • The daily limit on free plan is 85 API calls
  • Twitter limits chunk upload sizes to 4MB
  • For a small 100MB mp4 video it takes 27 API calls to upload all chunks.
    • 1 for INIT
    • 25 for APPEND
    • 1 for FINALIZE

If if takes 15 additional API calls only to check the status, then a user on a free API plan uses almost half of his allowed usage (27+15=42) for one 100MB video.

Goal

Allow user to specify a minimum waiting time between upload status checks.

  • Add optional minWaitingTimeInSeconds: number param to AbstractMedia.upload
  • Update Readme documentation to explain what this param does.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions