Fix bug in cURL code

Need to get final URL (“effective URL”) that cURL resolves to when downloading media. And to watch out for any appended query strings at the end of the effective URL.