Last active
August 29, 2015 14:05
-
-
Save codersquid/4a5dfe1ea32245f61aca to your computer and use it in GitHub Desktop.
example to show that a subsequent upload of an ia-wrapper Item will show metadata from a previous Item.
This file contains 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import datetime | |
import internetarchive as ia | |
import os | |
from tempfile import NamedTemporaryFile | |
ACCESS_KEY = os.environ.get('IAS3_ACCESS_KEY') | |
SECRET_KEY = os.environ.get('IAS3_SECRET_KEY') | |
now = datetime.datetime.utcnow().strftime('%Y_%m_%d_%H%M%S') | |
item = ia.Item('test_upload_iawrapper_first_%s' % now) | |
item2 = ia.Item('test_upload_iawrapper_second_%s' % now) | |
def upload(item, metadata): | |
with NamedTemporaryFile() as fh: | |
fh.write('testing archive_uploader') | |
item.upload(fh.name, | |
metadata=metadata, | |
access_key=ACCESS_KEY, | |
secret_key=SECRET_KEY | |
) | |
upload(item, | |
metadata={ | |
'collection': 'test_collection', | |
'description': 'not an empty description', | |
}) | |
upload(item2, | |
metadata={ | |
'collection': 'test_collection', | |
'description': '', | |
}) | |
print 'visit https://archive.org/details/{}'.format(item.identifier) | |
print 'visit https://archive.org/details/{}'.format(item2.identifier) |
btw, adding header={} after L23 is a workaround
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this also happens if item2's metadata doesn't have a description item.