4

How do I get a direct link to a video embedded in a tweet?

For example, the video embedded in this tweet can be watched directly here.

Note: I got the link from the Feedbro extension which can show an RSS-link feed of a twitter account. This is not a general solution, since it would only show the most recent 20 tweets and I need something that will work for an arbitrary twwet. It's just a demonstration that this is possible.

Note 2: This is not about downloading the video (there are multiple tools to do that), just retrieving a link to it.

Alex O
  • 685

4 Answers4

9

youtube-dl is exactly what you need. Don't be fooled by its name, it works with a lot more than just youtube.

If you have youtube-dl installed, you can do it like so:

youtube-dl --get-url <link to media page>

It should print the video's URL in your terminal, and that's it!


Installation docs

5th
  • 91
3

I don't know the Technical anwser but there is a service that you can tag @SaveVidBot under the Video and it sends you a link and on the link you can click view and there is the direct media link.

Note: as per @persons's comment this no longer works

Edit: Now I did a bit of research. If you don't want to use an external service you can use the Chrome Debugger.

  1. Go to the Tweet with the Video for example this again

  2. Right-click anywhere on the page and hit Inspect

  3. Go to the Network Tab and hit F5 to reload the Network traffic from this site

  4. On the debugger search function search for ".mp4?tag"

  5. There should be only one result. Expand it and click it.

  6. Copy the Code from the Response Tab.

  7. In this code there is the direct link to the media in this case here

  8. You can use https://beautifier.io/ to make the code you copied easier to read.

Greenonline
  • 2,390
Tobi-IT
  • 31
  • 2
1

I've been using yt-dlp which is a fork of @5th's answer.

tl;dr Run this: yt-dlp https://twitter.com/[user]/status/[id] --output [user]-[id].mp4

It took a couple of tweaks to get a video to download nicely.

  1. You need to set the output filename otherwise it takes the whole tweet message and gives an error of 'too long filename'
  2. I suggest the 'http' rather than 'hls' format (I'm guessing hls is better for advanced users, but http complained less)

So here's the commands I used:

yt-dlp --list-formats https://twitter.com/omid9/status/1608389855909658626
yt-dlp --format http-2176 https://twitter.com/omid9/status/1608389855909658626 --output omid9-1608389855909658626.mp4
icc97
  • 625
1

I ended up using the "Twitter Media Downloader for new Twitter.com 2019" user script from https://furyutei.github.io/twMediaDownloader/.

Direct link to the script: http://furyutei.github.io/twMediaDownloader/src/js/main_react.user.js

Alex O
  • 685