-
-
Save ericpauley/4658051 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests | |
from cStringIO import StringIO | |
import string | |
import random | |
import re | |
def randstring(size=24, chars=string.ascii_uppercase + string.digits): | |
return ''.join(random.choice(chars) for x in range(size)) | |
headers = { | |
'User-Agent': 'CurseForge Uploader Script/1.0', | |
'X-API-Key': 'API KEY' | |
} | |
files = {'file': ('TestFile.txt', StringIO(randstring()))} | |
data = { | |
'name': 'Test File', | |
'game_versions': '255', | |
'file_type': 'a', | |
'change_log': 'This is a changelog', | |
'change_markup_type': 'creole', | |
'known_caveats': '', | |
'caveats_markup_type': 'plain', | |
} | |
r = requests.post('http://dev.bukkit.org/server-mods/project-slug/upload-file.json', data = data, headers = headers, files = files) | |
p = requests.get(r.headers['location']).text | |
m = re.search('"(http://dev.bukkit.org/media/files/.*/.*/.*)"', p) | |
url = m.group(1) | |
print(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment