{"action":"created","issue":{"url":"https://api.github.com/repos/leetreveil/musicmetadata/issues/96","labels_url":"https://api.github.com/repos/leetreveil/musicmetadata/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/leetreveil/musicmetadata/issues/96/comments","events_url":"https://api.github.com/repos/leetreveil/musicmetadata/issues/96/events","html_url":"https://github.com/leetreveil/musicmetadata/pull/96","id":107424145,"number":96,"title":"Requestjs compat","user":{"login":"kf6kjg","id":1157224,"avatar_url":"https://avatars.githubusercontent.com/u/1157224?v=3","gravatar_id":"","url":"https://api.github.com/users/kf6kjg","html_url":"https://github.com/kf6kjg","followers_url":"https://api.github.com/users/kf6kjg/followers","following_url":"https://api.github.com/users/kf6kjg/following{/other_user}","gists_url":"https://api.github.com/users/kf6kjg/gists{/gist_id}","starred_url":"https://api.github.com/users/kf6kjg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kf6kjg/subscriptions","organizations_url":"https://api.github.com/users/kf6kjg/orgs","repos_url":"https://api.github.com/users/kf6kjg/repos","events_url":"https://api.github.com/users/kf6kjg/events{/privacy}","received_events_url":"https://api.github.com/users/kf6kjg/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-20T23:27:47Z","updated_at":"2015-09-25T10:46:13Z","closed_at":"2015-09-24T20:10:46Z","pull_request":{"url":"https://api.github.com/repos/leetreveil/musicmetadata/pulls/96","html_url":"https://github.com/leetreveil/musicmetadata/pull/96","diff_url":"https://github.com/leetreveil/musicmetadata/pull/96.diff","patch_url":"https://github.com/leetreveil/musicmetadata/pull/96.patch"},"body":"Now easy internet streams can determine the duration!\r\n\r\nThus far, after only gentle searching, I've not found any documented way to detect that the stream has what is needed.  So I cheated and used testing for the information I'm looking for.\r\n\r\nI also didn't find documentation on the location of said information.  I simply threw the contents out to console.log and looked for it.\r\n\r\nWhile using undocumented data is a bit risky, I found it to be very useful in my application. YMMV."},"comment":{"url":"https://api.github.com/repos/leetreveil/musicmetadata/issues/comments/143185248","html_url":"https://github.com/leetreveil/musicmetadata/pull/96#issuecomment-143185248","issue_url":"https://api.github.com/repos/leetreveil/musicmetadata/issues/96","id":143185248,"user":{"login":"leetreveil","id":123352,"avatar_url":"https://avatars.githubusercontent.com/u/123352?v=3","gravatar_id":"","url":"https://api.github.com/users/leetreveil","html_url":"https://github.com/leetreveil","followers_url":"https://api.github.com/users/leetreveil/followers","following_url":"https://api.github.com/users/leetreveil/following{/other_user}","gists_url":"https://api.github.com/users/leetreveil/gists{/gist_id}","starred_url":"https://api.github.com/users/leetreveil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leetreveil/subscriptions","organizations_url":"https://api.github.com/users/leetreveil/orgs","repos_url":"https://api.github.com/users/leetreveil/repos","events_url":"https://api.github.com/users/leetreveil/events{/privacy}","received_events_url":"https://api.github.com/users/leetreveil/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T10:46:13Z","updated_at":"2015-09-25T10:46:13Z","body":"Yeah exactly. This would work:\r\n\r\n\r\n```javascript\r\nvar files = [\r\n 'http://www.example.com/some1.mp3',\r\n 'http://www.example.com/some2.mp3',\r\n 'http://www.example.com/some3.mp3',\r\n 'http://www.example.com/some4.mp3',\r\n]\r\n\r\nfiles.forEach(function (url) {\r\n  var webstream = request.get(files[index])\r\n  var parser = mm(webstream, function (err, metadata) {\r\n    if (err) throw err;\r\n    console.log(metadata);\r\n  }, function (cb) {\r\n    cb(webstream.responseContent.headers['content-length'])\r\n  })\r\n})\r\n```\r\n\r\nThe reason? the `forEach` callback captures the url variable making it available to the second callback.\r\n\r\nThe reason your example wouldn't work is because by the time the `musicmetadata` callback has been called the while loop has already exhausted the list."}}