Skip to content

Instantly share code, notes, and snippets.

@simonmikkelsen
Created January 26, 2018 10:53
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmikkelsen/478accbc7b62c0c7786d6cd95fb09cae to your computer and use it in GitHub Desktop.
Save simonmikkelsen/478accbc7b62c0c7786d6cd95fb09cae to your computer and use it in GitHub Desktop.
Download your own image from Mapillary
#!/bin/bash
if [ $# -lt 3 ]
then
echo "Usage: $0 email password imageKey"
exit
fi
email="$1"
shift
pass="$1"
shift
imageKey="$1"
shift
curl='curl --cookie-jar cookies.txt --cookie cookies.txt --output output.txt'
client_id='MkJKbDA0bnZuZlcxeTJHTmFqN3g1dzo1YTM0NjRkM2EyZGU5MzBh'
$curl "https://a.mapillary.com/v2/ua/login?client_id=$client_id" -H "Host: a.mapillary.com" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0" -H "Accept: application/json" -H "Accept-Language: da,en-US;q=0.7,en;q=0.3" --compressed -H "Referer: https://www.mapillary.com/app/" -H "Content-Type: application/json" -H "Origin: https://www.mapillary.com" -H "Connection: keep-alive" -H "DNT: 1" --data "{\"email\":\"$email\",\"password\":\"$pass\"}"
token="`cat output.txt | tr '"' "\n" | tail -n2 | head -n1`"
paths="%5B%5B%22imageByKey%22%2C%22${imageKey}%22%2C%5B%22key%22%2C%22original_url%22%5D%5D%2C%5B%22blursByImageKey%22%2C%22${imageKey}%22%2C%5B%22applied%22%2C%22pending%22%5D%2C%5B%22blur%22%2C%22key%22%2C%22state%22%2C%22user%22%5D%5D%5D"
$curl "https://a.mapillary.com/v3/model.json?client_id=$client_id&paths=$paths&method=get" -H "Host: a.mapillary.com" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0" -H "Accept: */*" -H "Accept-Language: da,en-US;q=0.7,en;q=0.3" --compressed -H "Referer: https://www.mapillary.com/app/&username" -H "Authorization: Bearer $token" -H "Content-Type: application/x-www-form-urlencoded" -H "Origin: https://www.mapillary.com" -H "Connection: keep-alive" -H "DNT: 1"
url="`cat output.txt | tr '"' "\n" | grep -A8 original_url | tail -n1`"
curl --output image.jpg "$url"
@gitouche-sur-osm
Copy link

Thanks for this. I had a need to download back all my images so I wrote a script for it. https://framagit.org/gitouche/mapillary_takeout

@simonmikkelsen
Copy link
Author

Thanks for this. I had a need to download back all my images so I wrote a script for it. https://framagit.org/gitouche/mapillary_takeout

This is awesome @gitouche-sur-osm . Thanks for putting the idear into action and crediting me for the initial hack.

@simonmikkelsen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment