AlttiRi / twitter-click-and-save

[userscript] Adds buttons to save images and videos in Twitter, also does some other enhancements. (Twitter image and video downloader)
https://greasyfork.org/en/scripts/430132
GNU General Public License v3.0
103 stars 11 forks source link

doesn't work after 3-July-2023 since Twitter is using new API now. #26

Open 656229093 opened 1 year ago

656229093 commented 1 year ago

doesn't work after 3-July-2023 since Twitter is using new API now.

honbit commented 1 year ago

The original API has been deleted, The new API is to obtain 20 pieces of information in batches. I don’t have the ability to update this. I look forward to your update. Thank you

AlttiRi commented 1 year ago

Oh, fuck, the video downloading do not work.

https://twitter.com/i/api/2/timeline/conversation/${tweetId}.json?tweet_mode=extended

returns 404 now

{"errors":[{"message":"Sorry, that page does not exist","code":34}]}
honbit commented 1 year ago

Twitter delete individual media files API, You can get information in bulk through this interface(return a huge JSON). eg: "/i/api/graphql/Az0-KW6F-FyYTc2OJmvUhg/UserMedia"

I don’t know if this message is useful to you. Look forward to your good news.

AlttiRi commented 1 year ago

Yeah, I curently figure out how to parse the data from https://twitter.com/i/api/graphql/${API.queryId}/TweetDetail?....

For example, mp4 url for a tweet with a single video:

data.threaded_conversation_with_injections_v2.instructions[0].entries[0]
    .content.itemContent.tweet_results.result.legacy
    .extended_entities.media
    ...

Also, ideally, it would require to automatically get queryId (Az0-KW6F-FyYTc2OJmvUhg from your example) from https://abs.twimg.com/responsive-web/client-web-legacy/api.7d71e8ca.js file.

Since it can expire.


BTW, here is the updated versions of them: https://github.com/fa0311/TwitterInternalAPIDocument/blob/master/docs/json/API.json


@mikf changes them once per some months: https://github.com/search?q=repo:mikf/gallery-dl+twitter+update+query+hashes&type=commits

AlttiRi commented 1 year ago

https://github.com/AlttiRi/twitter-click-and-save/commit/42b3daab30649db9f585ae61548f9a36853adc19

const instruction = json.data.threaded_conversation_with_injections_v2.instructions.find(ins => ins.type === "TimelineAddEntries"); 
const tweetObject = instruction.entries.find(ins => ins.entryId === "tweet-" + tweetId) 
const tweetData = tweetObject.content.itemContent.tweet_results.result.legacy; 

Possibly, fixed, but I need to test it with different tweet types. I only tested it with a tweet with one video.

For example, I need to fix it again: https://github.com/AlttiRi/twitter-click-and-save/issues/7


OK, the main bug is fixed, I will continue a bit later.

honbit commented 1 year ago

Great!

biggestsonicfan commented 1 year ago

Possibly related tweet, gif (video) isn't downloading.

AlttiRi commented 1 year ago

Possibly related tweet, gif (video) isn't downloading.

image

It's "Embedded video". ~I see it first time.~* Seems it's possible to get the URL even without using API, just from HTML.

Currently, I made the simple fix with using API: https://github.com/AlttiRi/twitter-click-and-save/commit/c66f6cf8506f6dced65fd22c201100cf71f8ca53. However, it's better do not use API at all if it's possible.