-
-
Save fwenzel/254549 to your computer and use it in GitHub Desktop.
Create a new, random add-on through the AMO add-on builder
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 httplib | |
import urllib | |
import uuid | |
ROOT = 'addons.mozilla.org' | |
BUILDER_URL = '/en-US/developers/tools/builder/' | |
params_ = { | |
'name': 'unst unst', | |
'description': 'stephend ftw', | |
'version': '1.0', | |
'id': '{%s}' % uuid.uuid4(), | |
'package': 'stephend', | |
'author': 'Stephen Donner', | |
'applications[]': 'firefox', | |
'firefox_min': '3.5b4', | |
'firefox_max': '3.7a1pre', | |
'ui[]': 'about', | |
'contributors': '', | |
} | |
# Have to fill these out or the form looks invalid. | |
for app in ('thunderbird', 'sunbird', 'mobile'): | |
params_[app + '_min'] = params_[app + '_max'] = '0.7' | |
# seamonkey is *always* a fucking special case. | |
params_['seamonkey_min'] = params_['seamonkey_max'] = '1.0' | |
def main(): | |
params = urllib.urlencode(params_) | |
headers = {'Content-type': 'application/x-www-form-urlencoded'} | |
conn = httplib.HTTPSConnection(ROOT) | |
conn.request('POST', BUILDER_URL, params, headers) | |
response = conn.getresponse() | |
hash = response.getheader('location').rsplit('/', 1)[1] | |
response.close() | |
conn.request('GET', '%s/downloads/%s' % (BUILDER_URL, hash)) | |
response = conn.getresponse() | |
open('stephen.xpi', 'w').write(response.read()) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment