Posted: . At: 9:06 AM. This was 6 months ago. Post ID: 18709
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



Download Twitter videos with yt-dlp very easily.


Downloading Twitter videos easily can be done with yt-dlp, this is the best way on Linux to get a copy of an interesting Twitter video.

List all video formats on a Twitter post.

(jcartwright@localhost) 192.168.1.5 Videos  $ yt-dlp -F https://twitter.com/DashCamOwnersAu/status/1720730266770321661
[twitter] Extracting URL: https://twitter.com/DashCamOwnersAu/status/1720730266770321661
[twitter] 1720730266770321661: Downloading guest token
[twitter] 1720730266770321661: Downloading GraphQL JSON
[twitter] 1720730266770321661: Downloading m3u8 information
[info] Available formats for 1720730188290600960:
ID        EXT RESOLUTION  FILESIZE   TBR PROTO  VCODEC      ACODEC
───────────────────────────────────────────────────────────────────────
hls-365   mp4 320x568     ~1.64MiB  365k m3u8   avc1.4d001f mp4a.40.2
http-632  mp4 320x568     ≈2.84MiB  632k https  unknown     unknown
hls-705   mp4 480x852     ~3.18MiB  706k m3u8   avc1.4d001f mp4a.40.2
http-950  mp4 480x852     ≈4.28MiB  950k https  unknown     unknown
hls-1415  mp4 720x1280    ~6.37MiB 1416k m3u8   avc1.640020 mp4a.40.2
http-2176 mp4 720x1280    ≈9.79MiB 2176k https  unknown     unknown

And then download the video you wish to save.

(jcartwright@localhost) 192.168.1.5 Videos  $ yt-dlp https://twitter.com/meanwhileinau/status/1721080083484746225
[twitter] Extracting URL: https://twitter.com/meanwhileinau/status/1721080083484746225
[twitter] 1721080083484746225: Downloading guest token
[twitter] 1721080083484746225: Downloading GraphQL JSON
[twitter] 1721080083484746225: Downloading m3u8 information
[info] 1721080009518100480: Downloading 1 format(s): http-950
[download] Destination: Meanwhile in Melbourne - A group of men doing NOTHING [1721080009518100480].mp4
[download] 100% of    3.33MiB in 00:00:00 at 3.66MiB/s

This is how easy it is to download a Twitter video using the Linux command line and a very nice Python script.

To download the thumbnail of a Twitter video, use this example. Listing the thumbnails does not work, but the downloading part does. This is very nice.

(jcartwright@localhost) 192.168.1.5 Videos  $ yt-dlp -f hls-483 -i --no-warnings --get-thumbnail https://twitter.com/meanwhileinau/status/1721080083484746225 | wget -i -
--2023-11-06 15:23:32--  https://pbs.twimg.com/amplify_video_thumb/1721080009518100480/img/TaQVLvK8t99mArhk.jpg?name=small
Resolving pbs.twimg.com (pbs.twimg.com)... 117.18.237.70, 2606:2800:248:1347:709:24f:182c:618
Connecting to pbs.twimg.com (pbs.twimg.com)|117.18.237.70|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22634 (22K) [image/jpeg]
Saving to: ‘TaQVLvK8t99mArhk.jpg?name=small’

TaQVLvK8t99mArhk.jpg?name=small                   100%[===========================================================================================================>]  22.10K  --.-KB/s    in 0.003s  

2023-11-06 15:23:32 (6.30 MB/s) - ‘TaQVLvK8t99mArhk.jpg?name=small’ saved [22634/22634]

FINISHED --2023-11-06 15:23:32--
Total wall clock time: 2.1s
Downloaded: 1 files, 22K in 0.003s (6.30 MB/s)

This is a good alternative though. This will list all thumbnails in a Twitter post.

(jcartwright@localhost) 192.168.1.5 Videos  $ yt-dlp -f hls-483 -i --no-warnings --list-thumbnails https://twitter.com/9NewsQueensland/status/1721077312689431039
[twitter] Extracting URL: https://twitter.com/9NewsQueensland/status/1721077312689431039
[twitter] 1721077312689431039: Downloading guest token
[twitter] 1721077312689431039: Downloading GraphQL JSON
[twitter] 1721077312689431039: Downloading m3u8 information
[info] Available thumbnails for 1721077191868362752:
ID     Width Height URL
thumb  150   150    https://pbs.twimg.com/media/F-J-laOWMAA22b5.jpg?name=thumb
small  680   383    https://pbs.twimg.com/media/F-J-laOWMAA22b5.jpg?name=small
medium 1200  675    https://pbs.twimg.com/media/F-J-laOWMAA22b5.jpg?name=medium
large  1280  720    https://pbs.twimg.com/media/F-J-laOWMAA22b5.jpg?name=large
orig   1280  720    https://pbs.twimg.com/media/F-J-laOWMAA22b5.jpg?name=orig

This does not work if there is an embedded URL that Twitter makes the thumbnail from, but this does work with a normal Twitter post. This is a very nice trick indeed, this could be useful to someone out there who likes to use Twitter on Linux.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.