title: How to find the mp4 video link from an Instagram link
body: <p>I work on a facebook-like social network and would need to extract the mp4 from an Instagram link.</p>
  
  <p><strong>For photos it was easy:</strong> 
  url_shared = "<a href="http://instagram.com/p/a69ygTTHKq/" rel="noreferrer">http://instagram.com/p/a69ygTTHKq/</a>"
  photo_to_embed = url_shared+"?size=t"</p>
  
  <p><strong>Do you know anything similar to find out a direct link to the mp4?</strong> I tried using their API and changing the extension from ".jpg" to ".mp4" but failed as it doesn't work all the time.</p>
  
  <p>For example:
  <a href="http://api.instagram.com/oembed?url=http://instagram.com/p/bCgbJ2pgCi/" rel="noreferrer">http://api.instagram.com/oembed?url=http://instagram.com/p/bCgbJ2pgCi/</a> returns
  <code>{
  provider_url: "http://instagram.com/",
  media_id: "487094313204187298_9762431",
  title: "So did you download our "Hockey Community" app yet? If you like hockey even just a bit you should do it now!!'",
  url: "http://distilleryimage2.ak.instagram.com/d79af376deb011e2922a22000a1fdc29_7.jpg",
  author_name: "hockeycommunity",
  height: 612,
  width: 612,
  version: "1.0",
  author_url: "http://instagram.com/hockeycommunity",
  author_id: 9762431,
  type: "photo",
  provider_name: "Instagram"
  }</code></p>
  
  <p>data.url = "<a href="http://distilleryimage2.ak.instagram.com/d79af376deb011e2922a22000a1fdc29_" rel="noreferrer">http://distilleryimage2.ak.instagram.com/d79af376deb011e2922a22000a1fdc29_</a><strong>7.jpg</strong>" and the video link is actually "<a href="http://distilleryimage2.ak.instagram.com/d79af376deb011e2922a22000a1fdc29_" rel="noreferrer">http://distilleryimage2.ak.instagram.com/d79af376deb011e2922a22000a1fdc29_</a><strong>101.mp4</strong>"</p>
  
  <p>Only the end of the filename changes but can't figure out what's the rule...</p>
  
  <p>Source: </p>
  
  <ul>
  <li><a href="http://instagram-engineering.tumblr.com/post/53880734833/moving-pictures-capturing-moments-with-video" rel="noreferrer">http://instagram-engineering.tumblr.com/post/53880734833/moving-pictures-capturing-moments-with-video</a></li>
  <li><a href="http://instagram.com/developer/embedding/" rel="noreferrer">http://instagram.com/developer/embedding/</a></li>
  </ul>