Donmai

How to look up for a Twitter post with only the image URL?

Posted under General

Is there a way to reverse search a Twitter image post with just the pbs.twimg.com url?

For example, I got this image url, but not the original post's url:
https://pbs.twimg.com/media/FnSVHKRaMAIUs-2.jpg:orig
I tried using google image search, to no avail. The image is still up, so the Twitter post was not deleted. I tried uploading it here, but I get no fetch source data, nor the post's url. How can I track down the Twitter post?

(Sorry for my bad English)

Updated

Unfortunately there isn't a surefire way to reverse-engineer the twitter post ID from the media link, which is part of the reason the bad link tag exists. Especially with the somewhat nonsense API restrictions under the website’s current "management" it's also difficult to index the content of the site. Not to mention that there's a possibility it's from a restricted account (see protected link), which can't be found normally unless you're following the account.

You can get decode the filename to get the date and time from it, FnSVHKRaMAIUs-2 refers to 2023-01-25T03:03:33.714 and FlmFNTqaEAIYaKW refers to 2023-01-04T02:35:05.259.
You can use Twitter search operators to look for tweets around that time, but since that is the time that the image was processed and not the time that the tweet was sent, there can be a discrepancy of several seconds, which is enough time for many thousands of tweets to get posted.
But if you know the account that posted it, like with the first example (the username is written in the image), the date should be more than enough. I've had some luck even when hunting wild tweets by guessing keywords or just brute force.

Where did you get these image URLs?

viliml said:

You can get decode the filename to get the date and time from it, FnSVHKRaMAIUs-2 refers to 2023-01-25T03:03:33.714 and FlmFNTqaEAIYaKW refers to 2023-01-04T02:35:05.259.

I'm interested in how you decode the filename to get the date and time.

Sunnily_Bright said:

I'm interested in how you decode the filename to get the date and time.

Oh, right, I forgot to explain that, tehepero☆

The fundamental format is explained here: https://en.wikipedia.org/wiki/Snowflake_ID.
Filenames differ only in that they are Base64URL-encoded and have 3 extra bytes at the end, of unknown purpose.
If you decode FnSVHKRaMAIUs-2 you get the bytes 1674951ca45a300214b3ed in base 16, and discarding the last 3 bytes you get the snowflake ID 1674951ca45a3002 in base 16 which is 1618082116381847554 in base 10, from where you proceed as explained in the Wikipedia article.

Manual Method

This is a step by step guide based on @viliml reply.

Step 1: convert file name (Base64URL) to Base64
FnSVHKRaMAIUs-2 -> FnSVHKRaMAIUs+2

Step 2: convert Base64 file name to Hex (Base16) (With tools such as this)
FnSVHKRaMAIUs+2 -> 1674951ca45a300214b3ed

Step 3: cut off 3 bytes (6 characters) at the end, then convert it to decimal (Base10) which is the Twitter snowflake ID (With tools such as this)
1674951ca45a300214b3ed -> 1674951ca45a3002 -> 1618082116381847554

Step 4: convert the snowflake ID to UNIX seconds (With tools such as this)
1618082116381847554 -> 1674615813

Step 5: type since_time:[START] until_time:[END] [KEYWORDS] into the twitter search bar to search for the post you want.
since_time:1674615803 until_time:1674615823 グリムノーツ
The start and end time is 10 seconds earlier/later than the time got from the snowflake ID to account for possible discrepancy, the keywords at the end is usually character name or copyright name and can be omitted for broadest possible search.

Bookmarklet

https://danbooru.donmai.us/comments/2413907

javascript:(()=>{url2mk=u=>u.split('/').pop().replace(/[.?:].*/, "");mk2id=mk=>new DataView(Uint8Array.from(atob(mk.replace(/_/g,'/').replace(/-/g,'+')),m=>m.codePointAt(0)).buffer).getBigUint64();id2date=id=>new Date(Number(1288834974657n+(id>>22n)));prompt("Image date", id2date(mk2id(url2mk(prompt("Image URL or filename", window.location)))).toISOString())})()

The timestamp given is in ISO 8601 format. It can be converted to UNIX by tools such as this then used in search following Manual Method's Step 5.

NOTE

The timestamp doesn't always work as the time derived from the snowflake ID is the time that the image was processed and not the time that the tweet was sent therefore the actual time the tweet was posted can be off by as far as 1 day compared to the time derived from the snowflake ID.

Updated

1