Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to improve consistency of direct media links #648

Open
seriaati opened this issue Feb 3, 2024 · 2 comments
Open

Request to improve consistency of direct media links #648

seriaati opened this issue Feb 3, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@seriaati
Copy link

seriaati commented Feb 3, 2024

The problem

The readme says adding /photo/{index} after the post ID allows getting the other medias in the post.
For example, this post https://twitter.com/qiandaiyiyu/status/1753349204380938507 has 3 images, and the following can get all 3 of them:

However, if I request to https://d.fxtwitter.com/qiandaiyiyu/status/1753349204380938507/photo/4, fxtwitter will return the first image for some reason, then https://d.fxtwitter.com/qiandaiyiyu/status/1753349204380938507/photo/5 leads to https://github.com/FixTweet/FxTwitter.
My project uses fxtwitter to extract media (URL)s directly from the post and send them in a Discord channel, but with the current behavior, I can only send the first image URL because I don't have a consistent way of knowing how many medias this post has.

My suggestion

Without considering how fxtwitter works internally (I haven't read the code yet), I have 2 suggestions to resolve this issue:

  1. Return 404 when requesting an invalid media index: With the example above, /photo/4 and beyond should return a 404. This way I can iterate through the indexes from 1 and continue until a 404.
  2. Create a GET API that returns information about a post given the post ID: Maybe something like this:
{
  "id": 12345,
  "content": "something this post says about",
  "medias": [
    "https://pbs.twimg.com/media/GFUk9BRXoAA2zi0",
    "..."
  ]
}
@dangeredwolf dangeredwolf added the enhancement New feature or request label Feb 3, 2024
@dangeredwolf
Copy link
Member

About the 2nd point, we actually have an API for FxTwitter (see api.fxtwitter.com). Not sure if that's helpful in your case. It would probably be a good idea to improve direct media's behavior here cause right now it's handled the same as embeds but it would be probably more useful to actually only return the media if it was found

@seriaati
Copy link
Author

seriaati commented Feb 3, 2024

Nice, the API works for me. It's up to you if you want to fix the direct media links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants