Skip to content

Instantly share code, notes, and snippets.

@codersquid
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codersquid/4a5dfe1ea32245f61aca to your computer and use it in GitHub Desktop.
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.
#! /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)
@codersquid
Copy link
Author

I found this also happens if item2's metadata doesn't have a description item.

@codersquid
Copy link
Author

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