当前位置: 首页>>代码示例>>Python>>正文


Python internetarchive.get_item方法代码示例

本文整理汇总了Python中internetarchive.get_item方法的典型用法代码示例。如果您正苦于以下问题:Python internetarchive.get_item方法的具体用法?Python internetarchive.get_item怎么用?Python internetarchive.get_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在internetarchive的用法示例。


在下文中一共展示了internetarchive.get_item方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def main(args, root='root'):
    item = internetarchive.get_item('johns_hopkins_costar_dataset')

    path = os.path.expanduser(args['path'])
    if not os.path.exists(path):
        os.makedirs(path)
        print("{} created.".format(path))

    dryrun = args['dryrun']

    r = item.download(
            destdir=path,  # The directory to download files to
            ignore_existing=True,  # Skip files that already exist locally
            checksum=True,  # Skip files based on checksum
            verbose=True,  # Print progress to stdout
            retries=100,  # The number of times to retry on failed requests
            no_directory=True,  # Download withtout the identifier
            # Set to true to print headers to stdout, and exit without downloading
            dry_run=dryrun) 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:21,代码来源:costar_block_stacking_internet_archive_download.py

示例2: update_image_metadata

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def update_image_metadata(self, man_obj, json_ld=None, item=None):
        """ updates an items metadata """
        meta_ok = False
        if json_ld is None:
            json_ld = self.make_oc_item(man_obj)
        if isinstance(json_ld, dict):
            # cache the remote file locally to upload it
            item_id = self.id_prefix + '-' + json_ld['slug']
            if item is None:
                s = self.start_ia_session()
                # get or make an item
                item = get_item(item_id,
                                archive_session=s,
                                debug=True)
            # now add the metadata
            print('Update metadata for ' + item_id)
            meta_ok = self.update_item_metadata(json_ld,
                                                man_obj,
                                                item_id,
                                                item)
        return meta_ok 
开发者ID:ekansa,项目名称:open-context-py,代码行数:23,代码来源:internetarchive.py

示例3: update_item_metadata

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def update_item_metadata(self, json_ld, man_obj, item_id, item=None):
        """ creates and updates the item metadata """
        ok = False
        metadata = self.make_metadata_dict(json_ld, man_obj)
        if item is None:
            s = self.start_ia_session()
            item = get_item(item_id,
                            archive_session=s,
                            debug=True)
        r = item.modify_metadata(metadata)
        print(str(r))
        if r.status_code == requests.codes.ok:
            ok = True
        else:
            ok = False
            error_msg = 'UUID: ' + man_obj.uuid + ' item_id: ' + item_id
            error_msg += ' Metadata update error: ' + str(r.status_code)
            self.errors.append(error_msg)
        return ok 
开发者ID:ekansa,项目名称:open-context-py,代码行数:21,代码来源:internetarchive.py

示例4: mk_mirror

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def mk_mirror(target):
	'''Make the mirror'''
	session = ArchiveSession()
	target = 'collection:' + target
	print("Attempting to download collection: " + target)
	search = ia.Search(session, target)

	## 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 = get_item(item_id)
		status = item.download()
		print('\t\t Download successful')
		current_item += 1 
开发者ID:Famicoman,项目名称:ia-collection-dl,代码行数:28,代码来源:ia-collection-dl.py

示例5: add_file_to_archive

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def add_file_to_archive(self, man_obj, file_name, cache_dir=None):
        """ adds another file to an existing archive item. No metadata modification
        """
        self.prep_bin_file_obj()
        ia_file_uri = None
        json_ld = self.make_oc_item(man_obj)
        if isinstance(json_ld, dict):
            # cache the remote file locally to upload it
            item_id = self.id_prefix + '-' + json_ld['slug']
            if not isinstance(cache_dir, str):
                cache_dir = self.cache_file_dir
            dir_file = self.bin_file_obj.join_dir_filename(file_name,
                                                           cache_dir)
            if not os.path.exists(dir_file):
                print('Cannot find the cached file: ' +  dir_file + ' !')
            else:
                sleep(self.delay_before_request)
                print('Ready to upload: ' + file_name)
                # start an internet archive session
                s = self.start_ia_session()
                # get or make an item
                item = get_item(item_id,
                                archive_session=s,
                                debug=True)
                # now upload file
                try:
                    # sometimes the connect fails with an uncaught exception, so
                    # catch it here.
                    r = item.upload_file(dir_file,
                                         key=file_name,
                                         metadata=metadata)
                    # set the uri for the media item just uploaded
                    if r.status_code == requests.codes.ok or self.save_db:
                        ia_file_uri = self.make_ia_image_uri(item_id, file_name)
                except:
                    print('Upload failure for:'  + file_name + ' uuid: ' + man_obj.uuid)
                    ia_file_uri = None
        return ia_file_uri 
开发者ID:ekansa,项目名称:open-context-py,代码行数:40,代码来源:internetarchive.py

示例6: make_oc_item

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def make_oc_item(self, man_obj):
        """ makes an open context item for the image,
            so as to gather up all the needed metadata
        """
        ocitem = OCitem()
        ocitem.get_item(man_obj.uuid)
        json_ld = ocitem.json_ld
        return json_ld 
开发者ID:ekansa,项目名称:open-context-py,代码行数:10,代码来源:internetarchive.py

示例7: test_upload

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def test_upload(self):
        s = self.start_ia_session()
        item = get_item('opencontext-test-item',
                        archive_session=s,
                        debug=True)
        r = item.upload('https://artiraq.org/static/opencontext/abydos-looting/full/fig001.jpg')
        return r 
开发者ID:ekansa,项目名称:open-context-py,代码行数:9,代码来源:internetarchive.py

示例8: download_text_data

# 需要导入模块: import internetarchive [as 别名]
# 或者: from internetarchive import get_item [as 别名]
def download_text_data(textID, outDir):

    item = get_item(textID)
    namesFile = []
    for data in item.files:
        name = data['name']
        if os.path.splitext(name)[1] == ".txt":
            namesFile.append(name)

    if len(namesFile) == 0:
        return False, []

    return download(textID, files=namesFile, destdir=outDir), namesFile 
开发者ID:facebookresearch,项目名称:libri-light,代码行数:15,代码来源:archive_org.py


注:本文中的internetarchive.get_item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。