Created
September 14, 2018 23:40
-
-
Save noskla/379b00353b7a4fa47c2980f5ce4affc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import requests, sys, os | |
zorde_flash_url = 'https://z0r.de/L/z0r-de_{}.swf' | |
flashes_count = 7911 # as of 07.08.2018 | |
request_headers = { | |
'User-Agent': 'NotABot/1.0 (Just archiving on my disk don\'t ban me thanks.)' | |
} | |
def download_file(url, headers): | |
local_filename = 'z0rde/' + url.split('/')[-1] | |
if os.path.isfile(local_filename): | |
return | |
if not os.path.exists('./z0rde'): | |
os.makedirs('./z0rde') | |
r = requests.get(url, stream=True, headers=headers) | |
total_length = r.headers.get('content-length') | |
with open(local_filename, 'wb') as f: | |
dl = 0 | |
for chunk in r.iter_content(chunk_size=4096): | |
if chunk: | |
f.write(chunk) | |
if total_length != None: | |
dl += len(chunk) | |
done = int(50 * dl / int(total_length)) | |
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50 - done))) | |
sys.stdout.flush() | |
return local_filename | |
for current_flash in range(flashes_count): | |
download_url = zorde_flash_url.format(str(current_flash)) | |
print( | |
'\n\nDownloading ' + download_url.split('/')[-1] + | |
' ({} out of {} remaining)'.format(str(flashes_count - current_flash), str(flashes_count)) + | |
' [{}% complete]'.format(str(round( (current_flash / flashes_count) * 100.0 ))) | |
) | |
local_name = download_file(download_url, request_headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment