How to use the internetarchive.Item function in internetarchive

To help you get started, we’ve selected a few internetarchive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Famicoman / ia-ul-from-youtubedl / ia-ul-from-youtubedl.py View on Github external
## If we have valid JSON, extract some metadata
			if data:
				metadata = {}
				metadata["title"] = str(data["fulltitle"].encode('ascii', 'ignore'))
				metadata["description"] = str(data["description"].encode('ascii', 'ignore')).replace("\n", "<br>")
				metadata["mediatype"] = "movies"
				metadata["collection"] = "opensource_movies"
				metadata["subject"] = myTags
				print("JSON parse successful! Checking identifier...")
				## Check to see if our identifier is in use
				item = ia.get_item(sanitized)
				if not item.exists:
					## Identifier not in use, let's upload
					print("Identifier cleared for use!")
					print("[uploading]")
					item = ia.Item(sanitized)
					response = item.upload(file, metadata=metadata, access_key=access_key, secret_key=secret_key)
					print("Server Response: " + str(response))
					## Check the response. An HTTP 200 is OK
					if "200" in str(response):
						print("Success, adding other items associated with "  + sanitized) 
						for otherFile in os.listdir(workingDirectory):
							if otherFile.startswith(commonFile) and not otherFile.endswith(".info.json"):
								print("Adding file: " + str(otherFile))
								response = item.upload(otherFile, access_key=access_key, secret_key=secret_key)
								print("Server Response: " + str(response))
								if "200" in str(response):
									print("Done adding file: " + str(otherFile) + " to item " + str(sanitized))
								else:
									print(bcolors.FAIL + "[ERROR] Server responded with: " + str(response) + bcolors.ENDC + ". Skipping to next file for item")
						print("Success! Item populating at: " + bcolors.OKGREEN + "https://archive.org/details/" + sanitized + bcolors.ENDC)
                                                print("Moving on to next item in [" + str(timeDelay) +"s]")
github Famicoman / ia-collection-dl / ia-collection-dl.py View on Github external
## Because the internetarchive module won't return us a list
	## we'll have to make our own.
	current_item = 1
	total_item = 0
	collection = []
	for entry in search:
		collection.append(entry)
		total_item += 1

	## Go through all items of the collection and download
	for entry in collection:
		item_id = entry['identifier']
		print('Downloading ' + str(current_item) + '/' + str(total_item) + '\t'\
			+ item_id)

		item = ia.Item(item_id)
		status = item.download()
		print('\t\t Download successful')
		current_item += 1