- Home /
Getting A Redirected URL
Hi there!
I have been randomly generating different URLs for sounds on archive.org, such as this fruity little number:
https://archive.org/download/KFJ_2012.10.31_live1.mp3/format=VBR+MP3&ignore=x.ogg
Although this URL plays in the browser, in-game it does not. This is because when put into your browser, it redirects you to another address:
https://ia601200.us.archive.org/34/items/KFJ_2012.10.31_live1.mp3/KFJ_2012.10.31_live1.mp3
Is there anyway I can simulate trying to get to the URL like in a browser, then get the redirected URL?
Really hoping there is a solution, this project has some potential I reckon.
Thanks for your time,
Magnus :)
.
p.s - JS is preferred
Check Bunny83's solution here. As a quick recap, check the WWW's response headers for a location field, and make another request if there is one.
Answer by magnusm · Dec 18, 2013 at 12:23 PM
Working off Bunny's post, this was the solution:
First I had to find out what headers were available for this WWW. They are stored in a dictionary so can be listed like this:
for(var cKey in audioFileWWW.responseHeaders.Keys)
{
Debug.Log("v--new--v");
Debug.Log(cKey);
Debug.Log(audioFileWWW.responseHeaders[cKey]);
}
This printed lots of info, then I found that the redirected URL was contained within the "LOCATION" header.
Finally you just look that up in the responseHeader dict to get you redirected Url:
var redirection = audioFileWWW.responseHeaders["LOCATION"]
Your answer
Follow this Question
Related Questions
Kimmons Dialogue and JS Scripts / Player Inventory 0 Answers
ExternalEval and Url Error 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
WebGL - InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable 1 Answer