Skip to content

Instantly share code, notes, and snippets.

@jjjake
Created January 16, 2013 20:58
Show Gist options
  • Select an option

  • Save jjjake/4550890 to your computer and use it in GitHub Desktop.

Select an option

Save jjjake/4550890 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""Update a single items record in metamgr.
Usage:
./update_metamgr.py $identifier
Using parallel:
parallel ./update_metamgr.py < itemlist.txt
"""
import os
import sys
import re
import requests
def update_metamgr(identifier):
log_in_cookies = {'logged-in-sig': os.environ['LOGGED_IN_SIG'],
'logged-in-user': os.environ['LOGGED_IN_USER']}
u = 'http://www.us.archive.org/metamgr.php'
params = {'f': 'update', 'w_identifier': identifier, 'id[]': identifier}
r = requests.get(u, params=params, cookies=log_in_cookies)
if r.status_code != 200:
return False
#result = re.findall('</a> - updated OK<br />', r.content)
result = re.findall('updated OK', r.content)
if len(result) != 1:
return False
return True
if __name__ == '__main__':
identifier = sys.argv[1]
updated = update_metamgr(identifier)
if updated is True:
print '%s\t%s' % ('SUCCESS', identifier)
if updated is False:
print '%s\t%s' % ('ERROR', identifier)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment