redouane59 / twittered

Twitter API client for Java developers
Apache License 2.0
234 stars 64 forks source link

mp4 video doesn't get recognize #281

Open Zakichanu opened 2 years ago

Zakichanu commented 2 years ago

I have this error when i want to upload a mp4 video... [Timer-1] ERROR io.github.redouane59.twitter.helpers.AbstractRequestHelper - (POST) Error calling https://upload.twitter.com/1.1/media/upload.json?media_category=tweet_video {"request":"\/1.1\/media\/upload.json","error":"media type unrecognized."} - 400 Any advice?

redouane59 commented 2 years ago

Hey @Zakichanu , Can you please share your full code here. I'm not expert in media upload but I know that there are several steps to upload something. Thanks !

Zakichanu commented 2 years ago

Yes of course, here it is : so I'm using curl to save a mp4 video locally and then i tweeted it :

// Linux commande that save my mp4 file from the internet
String commande = "curl " + replayPath + " --output "+fileName;
System.out.println(commande);
ProcessBuilder builder = new ProcessBuilder(commande.split(" "));
builder.directory(new File(getPathToDirOfBoardLive() + "/Replay/"));
builder.start();

// Post with video
 File replay = new File(getPathToDirOfBoardLive() + "/Replay/" + fileName);
 UploadMediaResponse vidReplay = twitterClient.uploadMedia(replay, MediaCategory.TWEET_VIDEO);
 Tweet statusWitVid = twitterClient.postTweet("Replay of it: ", entry.getValue(), vidReplay.getMediaId());
redouane59 commented 2 years ago

Ok the issue is related to https://github.com/redouane59/twittered/issues/183 The feature is a little bit hard to implement and I never took the time to do that because it's a V1 endpoint which will be soon replaced. If you have some time you can submit a pull request to fix it. See here

Please note that to upload videos or GIFs (tweet_video, amplify_video, and tweet_gif), you need to use the chunked upload end-point.

Otherwise you'll have to wait for Twitter Team to make the V2 available.

Zakichanu commented 2 years ago

Okay, I see, thank you it helps me a lot, and if i have time I will for sure put some work on this bug! Thx 😊

redouane59 commented 2 years ago

Thanks, as the problem is not solved, please let it opened :)