title: Downloading/storing Periscope live streaming broadcasts
body: <p>I'm crawling tweets and, if available, store information to external resources (e.g., Instagram images). Now poeple start using Periscope where users tweet links to a Periscope live streaming broadcast (also then available for the next 24h). <a href="https://www.periscope.tv/w/VysPPjEzODk3NTZ8OTUxMDA2NpBSD8LFCooHM_t2Z-iSI0h00Hi0CuPMht8ywK1834dj" rel="nofollow">Here</a> is an example link, but it might be invalid/obsolete soon.</p>
  
  <p>Is there any way I can fetch that broadcast, i.e., store it locally as a video file?</p>
  
  <p>When I look at the source code of a Periscope broadcast, I get something like that:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    ...
    &lt;script src="https://assets.periscope.tv/assets/bugsnag-2.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://assets.periscope.tv/js/vendor.a8cd99eb89a488ec6ea465f57d3ad41bcd832eff.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="periscope-app" class="u-fullHeight"&gt;&lt;/div&gt;
    &lt;script src="https://assets.periscope.tv/js/application.min.2a8176c317fb715fd0e6c2728cb04318c5c53941.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>So everything is essentially scripted. I've tried to look into the Javascript file to see if I can somehow at least reconstruct the stream URL or something. But I wasn't successful. I also tried with Google Chrome to inspect the requests made from the side. But this also didn't bring me any further.</p>
  
  <p>EDIT: Here's my current Phantom.js script:</p>
  
  <pre><code>var page = require('webpage').create(),
    system = require('system'),
    t, address;
  
  if (system.args.length === 1) {
    console.log('Usage: periscope.js &lt;periscope-url&gt;');
    phantom.exit();
  }
  
  page.onResourceRequested = function(request) {
    console.log('Request ' + JSON.stringify(request, undefined, 4));
  };
  
  page.onResourceReceived = function(response) {
    console.log('Receive ' + JSON.stringify(response, undefined, 4));
  };
  
  address = system.args[1];
  
  page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36';
  page.open(address, function(status) {
    if (status !== 'success') {
      console.log('FAIL to load the address');
    } else {
  
    }
    //phantom.exit();
  });
  </code></pre>
  
  <p>When I use Google Chrome's Developer Tools I find the <code>application/vnd.apple.mpegurl</code> request, but it never pops up from the Phantom.js script.</p>