Skip to content

Instantly share code, notes, and snippets.

@blha303
Created January 22, 2017 08:40
Show Gist options
  • Save blha303/2a8e87d6cfd70d4e56169fc5ffd980e8 to your computer and use it in GitHub Desktop.
Save blha303/2a8e87d6cfd70d4e56169fc5ffd980e8 to your computer and use it in GitHub Desktop.
A script to download images from a krpano. Made for the CNN gigapixel panorama of Trump's inauguration
cubelabels = "fblrud"
levels = ["l"+i for i in range(1,8)]
skipped = 0
for s in cubelabels:
for l in levels:
for v in range(1,999):
for h in range(1,999):
req = requests.get("http://europe.tiles.fanpic.co/749-2017-cnn/mres_{s}/{l}/{v}/{l}_{s}_{v}_{h}.jpg".format(s=s,l=l,v=v,h=h), stream=True)
if req.status_code == 200:
with open("{l}_{s}_{v}_{h}.jpg".format(s=s,l=l,v=v,h=h), "wb") as f:
for chunk in req:
_ = f.write(chunk)
print("Done {l}_{s}_{v}_{h}.jpg".format(s=s,l=l,v=v,h=h))
else:
print("Skipping on {l}_{s}_{v}_{h}.jpg".format(s=s,l=l,v=v,h=h))
skipped += 1
break
if skipped >= 3:
skipped = 0
break
@FistfulOfStars
Copy link

FistfulOfStars commented Jan 22, 2017

Hey, thanks for writing this script.

I can't get this to run.. Not terribly familiar with scripting/python/etc, just a pleb trying to archive this.

If you could provide assistance with running it, it would be appreciated.

Traceback (most recent call last): File "krpanodl.py", line 2, in <module> levels = ["l"+i for i in range(1,8)] TypeError: cannot concatenate 'str' and 'int' objects

Edit:

I resolved that by changing:

"l"+i
on line 2 to:

"l"+str(i)
I am now getting:

Traceback (most recent call last): File "krpanodl.py", line 8, in <module> req = requests.get("http://europe.tiles.fanpic.co/749-2017-cnn/mres_{s}/{l}/{v}/{l}_{s}_{v}_{h}.jpg".format(s=s,l=l,v=v,h=h), stream=True) NameError: name 'requests' is not defined

@parkerlreed
Copy link

@FistfulOfStars All you need is

import requests

Up top.

Now I'm trying to figure out how to combine these into one image.

@MarkDHallewin
Copy link

@parkerlreed did you figure it out? The outputs are hundreds of JPG (a few bytes)

@parkerlreed
Copy link

@parkerlreed did you figure it out? The outputs are hundreds of JPG (a few bytes)

Not in particular. Obviously you could use some stitching software but that would be a bit overkill because they're already aligned perfectly they just need to be put together in the right order. Never figured out a way to do it

@parkerlreed
Copy link

parkerlreed commented Nov 2, 2022

I can't seem to fix line 3 as current Python won't let you concatenate a string (the letter L) and a number.

@parkerlreed
Copy link

Aha derp I got it

levels = ["l"+str(i) for i in range(1,8)]

Downloading now

@parkerlreed
Copy link

Ironic that the original viewer doesn't even work anymore...

https://www.cnn.com/interactive/2017/01/politics/trump-inauguration-gigapixel/

@parkerlreed
Copy link

Figured. The viewer and images don't work due to mixed HTTPS and HTTP

Mixed Content: The page at 'https://edition.cnn.com/interactive/2017/01/politics/trump-inauguration-gigapixel/' was loaded over HTTPS, but requested an insecure script 'http://a.visualrevenue.com/vrs.js'. This request has been blocked; the content must be served over HTTPS.```

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