# This endpoint redirects to the server storing the item under ia######.s3dns.us.archive.org, but those servers present an invalid TLS certificate for *.us.archive.org.
class IAS3CertificateFixHTTPAdapter(requests.adapters.HTTPAdapter):
def init_poolmanager(self, *args, **kwargs):
kwargs['assert_hostname'] = 's3.us.archive.org'
return super().init_poolmanager(*args, **kwargs)
for attempt in range(1, tries + 1):
r = requests.get(url, allow_redirects = False)
if r.status_code == 307 and '.s3dns.us.archive.org' in r.headers['Location']:
parser.add_argument('--upload-id', dest = 'uploadId', help = 'upload ID when resuming or aborting an upload')
parser.add_argument('--parts', type = parts, help = 'previous parts data for resumption; can only be used with --upload-id')
parser.add_argument('--abort', action = 'store_true', help = 'aborts an upload; can only be used with --upload-id; most other options are ignored when this is used')
parser.add_argument('--list', action = 'store_true', help = 'list in-progress uploads for item; most other options are ignored when this is used')
parser.add_argument('item', help = 'identifier of the target item')
parser.add_argument('filename', help = 'filename to store the data to')
parser.add_argument('filename', nargs = '?', help = 'filename to store the data to')
parser.add_argument('metadata', nargs = '*', type = metadata, help = "metadata for the item in the form 'key:value'; only has an effect if the item doesn't exist yet")
args = parser.parse_args()
if (args.parts or args.abort) and not args.uploadId:
parser.error('--parts and --abort can only be used together with --upload-id')
if args.uploadId and (args.parts is not None) == bool(args.abort):
parser.error('--upload-id requires exactly one of --parts and --abort')
if args.abort and args.list:
parser.error('--abort and --list cannot be used together')
if not args.list and not args.filename:
parser.error('filename is required when not using --list')