Twitter videos?

Ask questions and have them answered!
Kainyusanagi

Re: Twitter videos?

Post by Kainyusanagi » Mon Apr 24, 2017 2:58 am

Squidy wrote:
Fri Apr 21, 2017 11:32 pm
Kainyusanagi wrote:
Fri Apr 21, 2017 8:14 pm
Yeah but then the page info directly links to the video, does it not? I get, under media, "blob:https://twitter.com/a05abb4a-7065-4605- ... a4335afbc9" and that should be the video url on Twitter, no? It's grayed out, because they've disabled direct media download for videos, afaik, but you can get around that, ne? Or am I completely barking up the wrong tree here?
That link 404s, so I can't say whether it's valid or not. When you say "under media", are you using your browser's developer tools? The video will show up there, but it's loaded from the playlist through JavaScript; it's not directly accessible through the HTML.

If you go to this URL, there's some json containing a "video_url" key which points to this playlist: https://video.twimg.com/ext_tw_video/85 ... -f-WA.m3u8

Opening that file gets you a list of resolutions and a playlist containing the video at those resolutions:

Code: Select all

#EXTM3U
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=256000,RESOLUTION=320x180,CODECS="mp4a.40.2,avc1.420015"
/ext_tw_video/854677437300559875/pu/pl/320x180/LAqKcnavryNiDYzQ.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=832000,RESOLUTION=640x360,CODECS="mp4a.40.2,avc1.42001f"
/ext_tw_video/854677437300559875/pu/pl/640x360/m9RPHHkuOzDTS_Rm.m3u8
Opening the second playlist listed above gets you a bunch of .ts files which need to be merged together to get the full video, which I assume is what their player does.

Anyway, I did find a quick way to get the direct .mp4 URL, as it looks like the mobile site still uses it. You just need to load the tweet using the mobile version of Twitter, and then it makes an API call that returns a .json file containing a direct link to the video. So, all I need to do is simulate that API call. Obviously they don't want you doing that, so I'm not sure how much of a struggle it'll be, but I can figure it out.
Oooh, I see. See, this is why I acknowledge I have a very limited knowledge base when it comes to coding, and leave that shit to the professionals like yourself. :D

User avatar
Squidy
Site Admin
Posts: 1270
Joined: Fri Mar 10, 2017 9:28 pm
Contact:

Re: Twitter videos?

Post by Squidy » Fri Apr 28, 2017 6:02 pm

This has now been partially addressed in Release 232. Some videos will download successfully, along with all "gifs" (which are actually .mp4 files in disguise). Depending on what accounts you're downloading from, this may be sufficient to solve the problem for now.

Certain videos are harder to get at, and will currently be skipped. These ones will need to be downloaded as separate .ts files (using the process mentioned earlier) and then combined with ffmpeg. This will be the next step.
I'm the admin and developer of HDoujin Downloader.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 14 guests