Skip to content

Instantly share code, notes, and snippets.

@ericpauley
Forked from Jaliborc/Upload to Curse.py
Last active December 11, 2015 20:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ericpauley/4658051 to your computer and use it in GitHub Desktop.
Save ericpauley/4658051 to your computer and use it in GitHub Desktop.
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