5

I'm trying to get the Video URL of ( https://twitter.com/i/videos/823649890379120640?embed_source=facebook )

I tried going over the source code but it give the same URL link

<meta  property="og:video:url" content="https://twitter.com/i/videos/823649890379120640?embed_source=facebook">

Is there any trick to get the URL of the videos or their locations ?

Nordwald
  • 2,896
  • 13
  • 25
Sarah19953
  • 51
  • 1
  • 1
  • 2

3 Answers3

4

youtube-dl is a nice program to download media content from a lot of websites, including twitter (and despites program name). It is open source, studying it can help understand how to retrieve the correct URLs and various other stuff (media quality, etc…)

Patrick Mevzek
  • 155
  • 1
  • 1
  • 10
  • so cool, but youtube/short not okay yet. – kangear Feb 01 '22 at 12:52
  • @kangear I don't know what you mean precisely, but you may want to look at yt-dlp too which is a fork of youtube-dl with added features and more recent releases. If you have a new separate question you need to post a new one with all details. – Patrick Mevzek Feb 01 '22 at 12:54
  • sorry about my poor english. I just tried this tool, twitter ok, youtube ok, but youtube/short video not okay. I will do more test. – kangear Feb 01 '22 at 13:22
  • @kangear Post a new separate question, do not create a thread in comments here. – Patrick Mevzek Feb 01 '22 at 14:09
  • okay, got it. I will post new question if I need indeed. – kangear Feb 01 '22 at 14:25
3

You were looking at the wrong piece of code. Twitter features lightly obfuscated javscript. Bring it to order and you'll receive something like this:

{
"duration": 55322,
"scribe_widget_origin": true,
"heartbeatEnabled": false,
"video_url": "https:\/\/video.twimg.com\/ext_tw_video\/823648834102272000\/pu\/pl\/BZiFV49f1BCX2JkK.m3u8",
"disable_embed": "0",
"videoInfo": {
    "title": null,
    "description": null,
    "publisher": {
        "screen_name": "VinePhilly",
        "name": "Global",
        "profile_image_url": "https:\/\/pbs.twimg.com\/profile_images\/822579605177532418\/ZS3emkF8_normal.jpg"
    }
},
"cardUrl": "https:\/\/t.co\/dpfYidciVZ",
"content_type": "application\/x-mpegURL",
"owner_id": "2495729384",
"looping_enabled": true,
"show_cookie_override_en": true,
"visit_cta_url": null,
"scribe_playlist_url": "https:\/\/twitter.com\/VinePhilly\/status\/823649890379120640\/video\/1",
"source_type": "consumer",
"image_src": "https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/823648834102272000\/pu\/img\/XgQjj1Y0_Sclf2SY.jpg",
"heartbeatIntervalInMs": 5000.0,
"use_tfw_live_heartbeat_event_category": true,
"video_loading_timeout": 45000.0,
"status": {
    "created_at": "Mon Jan 23 21:53:31 +0000 2017",
    "id": 823649890379120640,
    "id_str": "823649890379120640",
    "text": "Bro They Had A Picnic In Walmart \ud83d\ude2d https:\/\/t.co\/dpfYidciVZ",
    "truncated": false,
    "entities": {
        "hashtags": [],
        "symbols": [],
        "user_mentions": [],
        "urls": [],
        "media": [{
            "id": 823648834102272000,
            "id_str": "823648834102272000",
            "indices": [35, 58],
            "media_url": "http:\/\/pbs.twimg.com\/ext_tw_video_thumb\/823648834102272000\/pu\/img\/XgQjj1Y0_Sclf2SY.jpg",
            "media_url_https": "https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/823648834102272000\/pu\/img\/XgQjj1Y0_Sclf2SY.jpg",
            "url": "https:\/\/t.co\/dpfYidciVZ",
            "display_url": "pic.twitter.com\/dpfYidciVZ",
            "expanded_url": "https:\/\/twitter.com\/VinePhilly\/status\/823649890379120640\/video\/1",
            "type": "photo",
            "sizes": {
                "small": {
                    "w": 340,
                    "h": 425,
                    "resize": "fit"
                },
                "large": {
                    "w": 480,
                    "h": 600,
                    "resize": "fit"
                },
                "thumb": {
                    "w": 150,
                    "h": 150,
                    "resize": "crop"
                },
                "medium": {
                    "w": 480,
                    "h": 600,
                    "resize": "fit"
                }
            }
        }]
    },
    "source": "\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "retweet_count": 0,
    "favorite_count": 0,
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "lang": "en"
},
"show_cookie_override_all": true,
"video_session_enabled": false,
"media_id": "823648834102272000",
"view_counts": null,
"statusTimestamp": {
    "local": "1:53 PM - 23 Jan 2017"
},
"media_type": 1,
"user": {
    "screen_name": "VinePhilly",
    "name": "Global",
    "profile_image_url": "https:\/\/pbs.twimg.com\/profile_images\/822579605177532418\/ZS3emkF8_bigger.jpg"
},
"watch_now_cta_url": null,
"tweet_id": "823649890379120640"
}

You should be able to get to the video url from here. One more tip: the 'video_url' points to a playlist file. I'm not going to do this due to legal obligations.

I hope this helps

Nordwald
  • 2,896
  • 13
  • 25
  • 2
    Written originally by @reversalmushroom and posted as a comment by me since they doesn't have enough reputation to comment: "I still can't find the video URL from there. How do I find it? I'm looking for something that ends in something like '.mp4' or some other video format." – Megabeets Oct 31 '17 at 07:16
1

Yes you can. Original post is here.

Explication :

In your link : https://twitter.com/i/videos/823649890379120640?embed_source=facebook

You can see a JSON with some informations.

  • "statusTimestamp":{"local":"21:53 - 23 janv. 2017"}
  • "user":{"screen_name":"VinePhilly" ...}
  • "tweet_id":"823649890379120640"

So you can access to the profile of the owner with https://twitter.com/VinePhilly and craft the url to access the original post with https://twitter.com/VinePhilly/status/823649890379120640.

Pattern is: https://twitter.com/user/status/tweet_id

Pyvonix
  • 111
  • 3