Skip to content

Instantly share code, notes, and snippets.

@Centzilius
Created March 22, 2014 16:48
Show Gist options
  • Save Centzilius/9710255 to your computer and use it in GitHub Desktop.
Save Centzilius/9710255 to your computer and use it in GitHub Desktop.
#Written by X41
#Modified by Centzilius
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
import json
import urllib.request
import sys
links= []
page = 0
pic = 0
key = "ENTERYOURAPIKEYHERE"
tag = ' '.join(sys.argv[1:])
if len(sys.argv) == 1:
print("Usage: DerpibooruDownloader.py [tag1], [tag2], [tag3], [tag4].....")
exit()
data = ""
while True:
page += 1
url = "http://derpibooru.org/search.json?q=" + str(tag) + "&page=" + str(page) + "&key=" + str(key)
print("downloading data page " + str(page))
json_data = urllib.request.urlopen(url).read().decode("utf-8")
if json_data == "[]":
break
data = json.loads(json_data)
for entry in data:
links.append("http:" + entry['image'])
if len(links) == 0:
print("No pics with that tag found")
exit()
for link in links:
pic +=1
print("downloading pic " + str(pic) + " of " + str(len(links)))
try:
urllib.request.urlretrieve(link,link.split("/")[-1])
except:
print("Something went wrong with picture " + str(pic) +". Continuing with other pics.")
print("All done. May Celestia be with you.")
exit()
@Brawl345
Copy link

Brawl345 commented Jun 2, 2014

Die Lizenz ist geil :D
Räumt aber auch extrem viele Rechte ein.

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