Files
witness-fracture/.venv/lib/python3.12/site-packages/internetarchive/__pycache__/item.cpython-312.pyc
T

536 lines
58 KiB
Plaintext
Raw Normal View History

2025-06-23 17:55:02 -05:00
Ë
“»YhÊããóŠ—dZddlmZddlZddlZddlZddlZddlmZddl m Z ddl
m Z ddl m
Z
ddlmZdd lmZmZmZdd
lmZdd lmZdd lmZmZdd
lmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3e
e4«Z5e Gd„d««Z6Gd„de6«Z7Gd„de7«Z8y)z‹
internetarchive.item
~~~~~~~~~~~~~~~~~~~~
:copyright: (C) 2012-2024 by Internet Archive.
:license: AGPL 3, see LICENSE for more details.
é)Ú annotationsN)Údeepcopy)Úfnmatch)Útotal_ordering)Ú getLogger)Úsleep)ÚMappingÚMutableMappingÚOptional)Úquote)Ú
ExpatError)ÚRequestÚResponse)Ú HTTPError)Útqdm)Úcatalog)ÚS3Auth©ÚFile)ÚMetadataRequestÚ S3Request) ÚIdentifierListAsItemsÚIterableToFileAdapterÚchunk_generatorÚ
get_file_sizeÚget_md5Úget_s3_xml_textÚis_dirÚiter_directoryÚjsonÚ
norm_filepathÚrecursive_file_count_and_sizeÚvalidate_s3_identifiercóN—eZdZdZ d d
d„Zd d„Zd d
d„Zdd„Zdd„Zdd„Z y)ÚBaseItem)Úworkable_serversÚserverNcó—||_|xsi|_d|_i|_g|_d|_d|_d|_d|_d|_ d|_
g|_ d|_ d|_
d|_d|_d|_|j#«y)NF)Ú
identifierÚ
item_metadataÚexistsÚmetadataÚfilesÚcreatedÚd1Úd2ÚdirÚ files_countÚ item_sizeÚreviewsr'ÚuniqÚupdatedÚtasksÚis_darkÚload)Úselfr)r*s ú]/mnt/c/fieldcraft/witness-fracture/.venv/lib/python3.12/site-packages/internetarchive/item.pyÚ__init__zBaseItem.__init__Gs�€ð %ˆŒØ*Ò0¨bˆÔ؈Œ ð!ˆŒ
Ø!#ˆŒ
؈Œ ؈ŒØˆŒØˆŒØˆÔ؈ŒØˆŒ ؈Œ ؈Œ ؈Œ ؈Œ
؈Œ ð
� ‰ � ócór—|jsdnd}|jj›d|j›|›d�S)Nz, item_metadata={}Úz (identifier=ú))r+Ú __class__Ú__name__r))r:Ú notloadeds r;Ú__repr__zBaseItem.__repr__ds8€Ø04· ² Ñ(Àˆ Ø—.‘.×)Ñ)Ð*¨,°t·±Ð6IÈ)ÈÐTUÐVÐVr=cóf—|r||_t|j«|_|jD]}t|||j|«Œ|js |j
j
d«|_|j
j
dg«}t||j«|_ y)Nr)Ú
collection)
r*Úboolr+Úsetattrr)r,ÚgetrÚsessionrF)r:r*ÚkeyÚmcs r;r9z
BaseItem.loadhs’€Ù Ø!.ˆDÔ ä˜4×-Ñ-Ó.ˆŒ à×%Ñ%ò 8ˆCÜ �D˜#˜t×1Ñ1°#Ñ6Õ 7ð 8ð�ŠØ"Ÿm™m×/Ñ/° Ó=ˆDŒOà
�]‰]×
Ñ
˜|¨RÓ
0ˆä/°°D·L±LÓAˆ�r=có臇—‰j‰jk(xsV‰jj«‰jj«k(xrtˆˆfd„‰jD««S)Nc3óx•K—|]1}|‰jvr!‰j|‰j|k(–—Œ3y­w©N)ÚEXCLUDED_ITEM_METADATA_KEYSr*)Ú.0ÚxÚotherr:s €€r;ú <genexpr>z"BaseItem.__eq__.<locals>.<genexpr>{sDøèø€òJØ !Ø ¨×(HÑ(HÑHð!×.Ñ.¨qÑ1°U×5HÑ5HÈÑ5KÕKñJùsƒ7:)r*ÚkeysÚall©r:rSs``r;Ú__eq__zBaseItem.__eq__xsmù€Ø×"Ñ" e×&9Ñ&9Ñ9òKØ×&Ñ&×+Ñ+Ó-°×1DÑ1D×1IÑ1IÓ1KÑKòJÜôJØ%)×%7Ñ%7ôJóJð Lr=có4—|j|jkSrO)r)rWs r;Ú__le__zBaseItem.__le__s€Ø�‰ %×"2Ñ"2Ñ2Ð2r=cóÆ—|jj«D��cic]\}}||jvr||“Œ}}}tt j
|dd¬««Scc}}w)NTF)Ú sort_keysÚcheck_circular)r*ÚitemsrPÚhashr Údumps)r:ÚkÚvÚwithout_excluded_keyss r;Ú__hash__zBaseItem.__hash__‚so€à!×/Ñ/×5Ñ5Ó7÷!:Ù�Q˜Ø˜×8Ñ8Ñ8ð
ˆq‰Dð!:Ðñ!:ô”D—J‘JÐ4Ø)-¸eôEóFð Fùó!:sžA©NN)r)ú
str | Noner*úMapping | None©ÚreturnÚstrrO©r*rgriÚNone©rirG)riÚint)
rBÚ
__module__Ú __qualname__rPr<rDr9rXrZrd©r=r;r%r%CsD„à"@Ðð"&Ø(,ðàðð&óó:WôBó Ló3ôFr=r%c󿇗eZdZdZ d d ˆfd„
ZGd„d«Zdd!d„Zd"d„Z d# d$d„Z d# d%d„Z d# d&d „Z
d# d'd
„Z d# d'd „Z d( d)d „Z
d* d+d
„Z d, d-d„Z d. d/d„Zd0d„Zd1d0d„Zd1d0d„Zd1d0d„Zdd0d„Zdd2d„Z d3 d4d„Z d5 d6d„Z d7 d8d„Z d d9d„Z d d9d„Zd0d„Zd0d„Z d: d;d„Z d< d=d„ZˆxZ S)>ÚItemaŸThis class represents an archive.org item. Generally this class
should not be used directly, but rather via the
``internetarchive.get_item()`` function::
>>> from internetarchive import get_item
>>> item = get_item('stairs')
>>> print(item.metadata)
Or to modify the metadata for an item::
>>> metadata = {'title': 'The Stairs'}
>>> item.modify_metadata(metadata)
>>> print(item.metadata['title'])
'The Stairs'
This class also uses IA's S3-like interface to upload files to an
item. You need to supply your IAS3 credentials in environment
variables in order to upload::
>>> item.upload('myfile.tar', access_key='Y6oUrAcCEs4sK8ey',
... secret_key='youRSECRETKEYzZzZ')
True
You can retrieve S3 keys here: `https://archive.org/account/s3.php
<https://archive.org/account/s3.php>`__
có•—||_t‰|� ||«tj |«|_|j jd«r>|j
j}d|›d|j›d|j d›�|_
yy)a‹
:param archive_session: :class:`ArchiveSession <ArchiveSession>`
:param identifier: The globally unique Archive.org identifier for this item.
An identifier is composed of any unique combination of
alphanumeric characters, underscore ( _ ) and dash ( - ). While
there are no official limits it is strongly suggested that they
be between 5 and 80 characters in length. Identifiers must be
unique across the entirety of Internet Archive, not simply
unique within a single collection.
Once defined an identifier can not be changed. It will travel
with the item or object and is involved in every manner of
accessing or referring to the item.
:param item_metadata: The Archive.org item metadata used to initialize
this item. If no item metadata is provided, it will be
retrieved from Archive.org using the provided identifier.
Útitlez* [ú z] -- N) rJÚsuperr<rsÚURLsÚurlsr,rIÚdetailsr)Úwikilink)r:Úarchive_sessionr)r*rzrAs €r;r<z
Item.__init__¦szø€ð4'ˆŒ Ü
‰Ñ˜ ]Ô3ä—I‘I˜d“OˆŒ à �=‰=× Ñ ˜WÔ %à—i‘i×'Ñ'ˆGØ! ' ¨!¨D¯O©OÐ+<¸EÀ$Ç-Á-ÐPWÑBXÐAYÐZˆD�Mð &r=có2—eZdZd„Zdd„ZdZefdd„Zd d„Zy)
ú Item.URLscó¤—||_g|_|jd«|jd«|jd«|jd«|jd«|jd«|jd«|jjj d«d k(r#|j d
«|j d «yy) Nrzr,ÚdownloadÚhistoryÚeditÚeditxmlÚmanageÚ mediatyperFÚabout)Ú_itm_objÚ_pathsÚ _make_URLr,rIÚ
_make_tab_URL)r:Úitm_objs r;r<zItem.URLs.__init__Ës£€Ø#ˆDŒM؈DŒKØ �N‰N˜9Ô %Ø �N‰N˜:Ô &Ø �N‰N˜:Ô &Ø �N‰N˜9Ô %Ø �N‰N˜6Ô "Ø �N‰N˜9Ô %Ø �N‰N˜8Ô $Ø�}‰}×%Ñ%×)Ñ)¨+Ó6¸,ÒFØ×"Ñ" 7Ô+Ø×"Ñ" <Õ0ðGr=cóH—|j||jd|›�z«y)z<Make URLs for the separate tabs of Collections details page.z&tab=N)r‰rz)r:Útabs r;rŠzItem.URLs._make_tab_URLÙs€à �N‰N˜3 § ¡ °°s°e¨}Ñ <Õ =r=z<{0.session.protocol}//{0.session.host}/{path}/{0.identifier}cóŠ—t|||j|j|¬««|jj |«y)N)Úpath)rHÚformatr‡rˆÚappend)r:r�Ú
url_formats r;r‰zItem.URLs._make_URLàs4€Ü �D˜$ 
× 1Ñ 1°$·-±-ÀdÐ 1Ó KÔ LØ �K‰K× Ñ ˜tÕ $r=cól—ddj|j«›d|jj›�S)NzURLs (ú, z) for )Újoinrˆr‡r))r:s r;Ú__str__zItem.URLs.__str__äs.€Ø˜DŸI™I d§k¡kÓ2Ð3°6¸$¿-¹-×:RÑ:RÐ9SÐTÐ Tr=N)r�rjrirl)r�rjr’rjrirlrh)rBrorpr<rŠÚDEFAULT_URL_FORMATr‰r–rqr=r;rxr~Ês%„ò 1ó >ð7Ðð:Lô %ô Ur=rxc óx—|s'|jj|jfi|¤Ž}|j|«yrO)rJÚ get_metadatar)r9)r:r*Úkwargss r;Úrefreshz Item.refreshçs0€ÙØ5˜DŸL™L×5Ñ5°d·o±oÑPÈÑPˆMØ � ‰ �-Õ r=cóê—|jj›d|jj›d�}d|jdœ}|jj ||¬«}|j «d}|dk(S)z¼Check if the item identifier is available for creating a
new item.
:return: `True` if identifier is available, or `False` if it is
not available.
ú//z/services/check_identifier.phpr )Úoutputr))ÚparamsÚcodeÚ available)rJÚprotocolÚhostr)rIr )r:ÚurlrŸÚresponseÚ availabilitys r;Úidentifier_availablezItem.identifier_availableìso€ð—‘×&Ñ&Ð' r¨$¯,©,×*;Ñ*;Ð)<Ð<ZÐ[ˆØ"°$·/±/ÑBˆØ—<‘<×#Ñ# C°Ð#Ó7ˆØ—}‘}“ vÑ.ˆ ؘ{Ñ*Ð*r=cóP—|jj|j||«S)z§Get a summary of the item's pending tasks.
:param params: Params to send with your request.
:returns: A summary of the item's pending tasks.
)rJÚget_tasks_summaryr)©r:rŸÚrequest_kwargss r;Úget_task_summaryzItem.get_task_summaryùs!€ð�|‰|×-Ñ-¨d¯o©o¸vÀ~ÓVÐVr=cób—td„|j||«j«D««S)z¹Check if there is any pending task for the item.
:param params: Params to send with your request.
:returns: `True` if no tasks are pending, otherwise `False`.
c3ó&K—|] }|dk(–—Œ y­w)rNrq)rQrRs r;rTz(Item.no_tasks_pending.<locals>.<genexpr>sèø€ÒZ˜a�1˜•6ÑZùs‚)rVr¬Úvaluesrªs r;Úno_tasks_pendingzItem.no_tasks_pendings+€ôÑZ 4×#8Ñ#8¸ÀÓ#P×#WÑ#WÓ#YÔZÓZÐZr=có„—|xsi}|jdddœ«|jj|j||«S)aÖGet a list of all tasks for the item, pending and complete.
:param params: Query parameters, refer to
`Tasks API
<https://archive.org/services/docs/api/tasks.html>`_
for available parameters.
:param request_kwargs: Keyword arguments that
:py:func:`requests.get` takes.
:returns: A list of all tasks for the item, pending and complete.
é)rr�)ÚupdaterJÚ get_tasksr)rªs r;Úget_all_item_taskszItem.get_all_item_taskss;€ð"’˜2ˆØ�
‰
 !°Ñ2Ô3Ø�|‰|×%Ñ% d§o¡o°v¸~ÓNÐNr=cób—t|jj|j||««S)z¹Get a list of completed catalog tasks for the item.
:param params: Params to send with your request.
:returns: A list of completed catalog tasks for the item.
)ÚlistrJÚ iter_historyr)rªs r;Ú get_historyzItem.get_history(ó&€ô�D—L‘L×-Ñ-¨d¯o©o¸vÀ~ÓVÓWÐWr=cób—t|jj|j||««S)zµGet a list of pending catalog tasks for the item.
:param params: Params to send with your request.
:returns: A list of pending catalog tasks for the item.
)r·rJÚ iter_catalogr)rªs r;Ú get_catalogzItem.get_catalog5rºr=c óì—|xsi}|�/|jd«sd|i|d<n|djd|i«|jj|jd|||||¬«}|j «|S)a…Derive an item.
:param priority: Task priority from 10 to -10 [default: 0]
:param remove_derived: You can use wildcards ("globs")
to only remove *some* prior derivatives.
For example, "*" (typed without the
quotation marks) specifies that all
derivatives (in the item's top directory)
are to be rebuilt. "*.mp4" specifies that
all "*.mp4" deriviatives are to be rebuilt.
"{*.gif,*thumbs/*.jpg}" specifies that all
GIF and thumbs are to be rebuilt.
:param reduced_priority: Submit your derive at a lower priority.
This option is helpful to get around rate-limiting.
Your task will more likely be accepted, but it might
not run for a long time. Note that you still may be
subject to rate-limiting.
:returns: :class:`requests.Response`
ÚargsÚremove_derivedz
derive.php©ÚpriorityÚdataÚheadersÚreduced_priorityr«)rIr³rJÚ submit_taskr)Úraise_for_status)r:rÂrÀrÅrÃrÄr«Úrs r;Úderivez Item.deriveBsŠ€ð:Šz�rˆà Ð %Ø—8‘8˜FÔ#Ø 0°.ÐA��V’ à�V‘ ×#Ñ#Ð%5°~Ð$FÔGà �L‰L× $Ñ $ T§_¡_Ø%1Ø.6Ø*.Ø-4Ø6FØ4Bð
%ó
Dˆð
×ÑÔØˆr=c ó"—|xsi}|xsdg}t|tttf«s|g}|j d«xsi|d<|D]
}d|d|<Œ |j
j
|jd|||||¬«}|j«|S)agSubmit a fixer task on an item.
:param ops: The fixer operation(s) to run on the item
[default: noop].
:param priority: The task priority.
:param reduced_priority: Submit your derive at a lower priority.
This option is helpful to get around rate-limiting.
Your task will more likely be accepted, but it might
not run for a long time. Note that you still may be
subject to rate-limiting. This is different than
``priority`` in that it will allow you to possibly
avoid rate-limiting.
:param data: Additional parameters to submit with
the task.
:returns: :class:`requests.Response`
Únoopr¿Ú1z fixer.phprÁ) Ú
isinstancer·ÚtupleÚsetrIrJrÆr)rÇ) r:ÚopsrÂrÅrÃrÄr«ÚoprÈs r;Úfixerz
Item.fixerqs«€ð6Šz�rˆàŠo�f�XˆÜ˜#¤¤e¬SÐ1Ô2Ø�%ˆCØ—x‘x Ó'Ò-¨2ˆˆV‰ Øò #ˆBØ"ˆD�‰L˜Ò ð #ð
�L‰L× $Ñ $ T§_¡_Ø%0Ø.6Ø*.Ø-4Ø6FØ4Bð
%ó
Dˆð
×ÑÔØˆr=c ó~—|jj|jd|||||¬«}|j«|S)a_Undark the item.
:param comment: The curation comment explaining reason for
undarking item
:param priority: The task priority.
:param reduced_priority: Submit your derive at a lower priority.
This option is helpful to get around rate-limiting.
Your task will more likely be accepted, but it might
not run for a long time. Note that you still may be
subject to rate-limiting. This is different than
``priority`` in that it will allow you to possibly
avoid rate-limiting.
:param data: Additional parameters to submit with
the task.
:returns: :class:`requests.Response`
zmake_undark.php©ÚcommentrÂrÃrÅr«©rJrÆr)rÇ)r:rÕrÂrÅrÃr«rÈs r;Úundarkz Item.undarkŸsI€ð4
�L‰L× $Ñ $ T§_¡_Ø%6Ø-4Ø.6Ø*.Ø6FØ4Bð
%ó
Dˆð
×ÑÔØˆr=c ó~—|jj|jd|||||¬«}|j«|S)a[Dark the item.
:param comment: The curation comment explaining reason for
darking item
:param priority: The task priority.
:param reduced_priority: Submit your derive at a lower priority.
This option is helpful to get around rate-limiting.
Your task will more likely be accepted, but it might
not run for a long time. Note that you still may be
subject to rate-limiting. This is different than
``priority`` in that it will allow you to possibly
avoid rate-limiting.
:param data: Additional parameters to submit with
the task.
:returns: :class:`requests.Response`
z
make_dark.phprÔrÖ)r:rÕrÂrÃrÅr«rÈs r;Údarkz Item.darkÄsI€ð4
�L‰L× $Ñ $ T§_¡_Ø%4Ø-4Ø.6Ø*.Ø6FØ4Bð
%ó
Dˆð
×ÑÔØˆr=cóF—|jj›d|jj›d�}d|ji}t |jj
|jj «}|jj|||¬«}|j«|S)Nr�ú/services/reviews.phpr))rŸÚauth) rJr¢r£r)rÚ
access_keyÚ
secret_keyrIrÇ)r:ÚuÚpÚarÈs r;Ú
get_reviewzItem.get_reviewès…€Ø�|‰|×$Ñ$Ð% R¨¯ © ×(9Ñ(9Ð':Ð:OÐ PˆØ
˜4Ÿ?™?Ð +ˆÜ �4—<‘<×*Ñ*¨D¯L©L×,CÑ,CÓ DˆØ �L‰L× Ñ ˜Q q¨qÐ Ó 1ˆØ ×ÑÔØˆr=có~—|jj›d|jj›d�}d|ji}ddi}|r||d<n|r||d<n|r||d<t |jj
|jj «}|jj||||¬ «}|j«|S)
Nr�rÛr)ÚnoindexÚ0ÚusernameÚ
screennameÚitemname©rŸrÃrÜ© rJr¢r£r)rrÝrÞÚputrÇ© r:rærçrèrßràÚdrárÈs r;Ú index_reviewzItem.index_reviewð󵀨�|‰|×$Ñ$Ð% R¨¯ © ×(9Ñ(9Ð':Ð:OÐ PˆØ
˜4Ÿ?™?Ð +ˆØ
˜Ð ˆÙ Ø$ˆAˆjŠMÙ
Ø(ˆAˆlŠOÙ
Ø$ˆAˆj‰MÜ �4—<‘<×*Ñ*¨D¯L©L×,CÑ,CÓ DˆØ �L‰L× Ñ ˜Q q¨q°qÐ Ó 9ˆØ ×ÑÔØˆr=có~—|jj›d|jj›d�}d|ji}ddi}|r||d<n|r||d<n|r||d<t |jj
|jj «}|jj||||¬ «}|j«|S)
Nr�rÛr)rärÌrærçrèrérêrìs r;Únoindex_reviewzItem.noindex_reviewÿrïr=cót—|jj›d|jj›d�}d|ji}d}|rd|i}n
|rd|i}n|rd|i}t |jj
|jj «}|jj||||¬«}|j«|S)Nr�rÛr)rærçrèré) rJr¢r£r)rrÝrÞÚdeleterÇrìs r;Ú
delete_reviewzItem.delete_reviews³€Ø�|‰|×$Ñ$Ð% R¨¯ © ×(9Ñ(9Ð':Ð:OÐ PˆØ
˜4Ÿ?™?Ð +ˆØ ˆÙ ؘXÐ&‰AÙ
ؘzÐ*‰AÙ
ؘXÐ&ˆAÜ �4—<‘<×*Ñ*¨D¯L©L×,CÑ,CÓ DˆØ �L‰L× Ñ  ¨!°!¸!Ð Ó <ˆØ ×ÑÔØˆr=có†—|jj›d|jj›d�}d|ji}||dœ}|r||d<t |jj
|jj «}|jj||tj|«|¬«}|j«|S)Nr�rÛr))ruÚbodyÚstarsré) rJr¢r£r)rrÝrÞÚpostr r`rÇ) r:rurör÷rßràrírárÈs r;Úreviewz Item.reviews¥€Ø�|‰|×$Ñ$Ð% R¨¯ © ×(9Ñ(9Ð':Ð:OÐ PˆØ
˜4Ÿ?™?Ð +ˆØ TÑ *ˆÙ ؈Aˆg‰JÜ �4—<‘<×*Ñ*¨D¯L©L×,CÑ,CÓ DˆØ �L‰L× Ñ ˜a¨´·
±
¸1³
ÀAÐ Ó FˆØ ×ÑÔØˆr=có—t|||«S)zåGet a :class:`File <File>` object for the named file.
:param file_metadata: a dict of metadata for the
given file.
:returns: An :class:`internetarchive.File <File>` object.
r)r:Ú file_nameÚ
file_metadatas r;Úget_filez
Item.get_file(s€ô�D˜) ]Ó3Ð3r=c #ó®‡
K—|xsg}|xsg}|xsd}t|«}t|tttf«s|g}t|tttf«s|g}t |j «}|rad|j›d�fd|j›d�fd|j›d�fd|j›d �fg}|D]\}} |j| |d
d œ«Œtd „|||fD««s4|D]/Š
|jt‰
jd
««‰
¬«–—Œ1|D�]0Š
‰
jd
«|vr,|jt‰
jd
«««–—ŒC‰
jd«|vr,|jt‰
jd
«««–—Œ‚|sŒ…t|t«s|jd«}
n|}
t|t«s|jd«} n|} |
D]_} t‰
jd
d«| «sŒ tˆ
fd„| D««rŒ5|jt‰
jd
«««–—Œa�Œ3y­w)Nr?ÚEPUBz.epubÚMOBIz.mobiÚDAISYz
_daisy.zipÚMARCXMLz_archive_marc.xmlT)Únamer�Úotfc3ó K—|]}|–—Œy­wrOrq)rQras r;rTz!Item.get_files.<locals>.<genexpr>Nsèø€Ò=˜”1Ñ=ùs‚ r)rür�ú|c3óV•K—|] }t‰jdd«|«–—Œ"y­w)rr?N)rrI)rQÚeÚfs €r;rTz!Item.get_files.<locals>.<genexpr>bs#øèø€Ò"[ÀQ¤7¨1¯5©5°¸Ó+<¸a×#@Ñ"[ùsƒ&))rGrÍr·rÎrÏrr-r)r‘ÚanyrýrjrIÚsplitr)r:r-ÚformatsÚ glob_patternÚexclude_patternÚ
on_the_flyÚ
item_filesÚ otf_filesr�rûÚpatternsÚexclude_patternsràr s @r;Ú get_fileszItem.get_files2s<øèø€ð ’ ˜ˆØ’-˜RˆØ)Ò/¨RˆÜ˜*Ó%ˆ
ä˜%¤$¬¬sÐ!3Ô4Ø�GˆEܘ'¤D¬%´Ð#5Ô6Ø�iˆGä˜dŸj™jÓ)ˆ
á à˜DŸO™OÐ,¨EÐ2Ð3ؘDŸO™OÐ,¨EÐ2Ð3ؘTŸ_™_Ð-¨ZÐ8Ð9ؘtŸ™Ð/Ð/@ÐAÐBð ˆIð &/ò
VÑ!�˜ Ø×!Ñ!¨9ÀÈtÑ"TÕUð
VôÑ=˜u g¨|Ð<Ô=Ô=Øò
I�Ø—m‘m¤C¨¯©¨f«
Ó$6Àa�mÓHÓHð
Iðó DˆAØ�u‰u�V‹} Ñ%Ø—m‘m¤C¨¯©¨f«
Ó$6Ó7Ó7Ø—‘�x“ GÑ+Ø—m‘m¤C¨¯©¨f«
Ó$6Ó7Ó7ÚÜ! ,´Ô5Ø+×1Ñ1°#Ó6‘Hà+�HÜ! /´4Ô8Ø'6×'<Ñ'<¸SÓ'AÑ$à'6Ð$Ø!òD�AܘqŸu™u V¨RÓ0°!Õ4Ü"Ó"[ÐJZÔ"[Õ[Ø"&§-¡-´°A·E±E¸&³MÓ0BÓ"CÓCòDñ DùsƒF!IÆ%A)IÈIÈ$1Icó”‡!—t|«}t|«}t|«}t|«}t|«}t| «} t| «} t|«}t|«}t|«}|xsd}|rt|t«s|g}|rt|t«s|g}|r7tjt
j j«dd¬«}d}nd}|s\|
r.|r,t|j›d|
›d�t
j¬«n,|
€*|r(t|j›d�t
j¬«|jrGd |j›d
�}tj|«|rtd |›�t
j¬«gS|jik(rGd |j›d �}tj|«|rtd |›�t
j¬«gS|r|j||¬
«}n|j|¬
«}|r|j||¬«}|r|j|||¬«}|r t|«}g}d}g}d}|D�](Š!|dur‰!j j#d«rŒ$|rt%ˆ!fd„|D««sŒ;|rt%ˆ!fd„|D««rŒR|dz
}| r
‰!j }n=tj&j)t+|j«‰!j «}|rt‰!j,«Œ»|r|t/|«krd}nd}‰!j1||||| |
| |||||d|||«} |r|j3| «| dur|j3‰!j «�Œ$|dz
}�Œ+|dk(rGd |j›d�}tj5|«|rtd |›�t
j¬«gS|r|S|S)a�
Download files from an item.
:param files: Only download files matching given file names.
:param formats: Only download files matching the given
Formats.
:param glob_pattern: Only download files matching the given
glob pattern.
:param exclude_pattern: Exclude files whose filename matches the given
glob pattern.
:param dry_run: Output download URLs to stdout, don't
download anything.
:param verbose: Turn on verbose output.
:param ignore_existing: Skip files that already exist
locally.
:param checksum: Skip downloading file based on checksum.
:param checksum_archive: Skip downloading file based on checksum, and skip
checksum validation if it already succeeded
(will create and use _checksum_archive.txt).
:param destdir: The directory to download files to.
:param no_directory: Download files to current working
directory rather than creating an item directory.
:param retries: The number of times to retry on failed
requests.
:param item_index: The index of the item for displaying
progress in bulk downloads.
:param ignore_errors: Don't fail if a single file fails to
download, continue to download other files.
:param on_the_fly: Download on-the-fly files (i.e. derivative EPUB,
MOBI, DAISY files).
:param return_responses: Rather than downloading files to disk, return
a list of response objects.
:param no_change_timestamp: If True, leave the time stamp as the
current time instead of changing it to that given in
the original archive.
:param source: Filter files based on their source value in files.xml
(i.e. `original`, `derivative`, `metadata`).
:param exclude_source: Filter files based on their source value in files.xml
(i.e. `original`, `derivative`, `metadata`).
:param params: URL parameters to send with
download request (e.g. `cnt=0`).
:param ignore_history_dir: Do not download any files from the history
dir. This param defaults to ``False``.
:returns: True if if all files have been downloaded successfully.
NÚwbF)Úclosefdz (z):©Úfileú:z skipping z, item is darkrvz, item does not exist.)r)r r)r
rrrTzhistory/c3ó<•K—|]}‰j|k(–—Œy­wrO©Úsource©rQrRr s €r;rTz Item.download.<locals>.<genexpr>søèø€Ò!@°A !§(¡(¨a¥-Ñ!@ùóƒc3ó<•K—|]}‰j|k(–—Œy­wrOrrs €r;rTz Item.download.<locals>.<genexpr>søèø€Ò%L¸ a§h¡h°!¥mÑ%Lùrr²z, no matching files found.)rGrÍr·ÚosÚfdopenÚsysÚstdoutÚfilenoÚprintr)Ústderrr8ÚlogÚwarningr,rrÚ
startswithr
r�r•rjr¤Úlenr€r‘Úinfo)"r:r-r r
rÚdry_runÚverboseÚignore_existingÚchecksumÚchecksum_archiveÚdestdirÚ no_directoryÚretriesÚ
item_indexÚ
ignore_errorsrÚreturn_responsesÚno_change_timestampÚignore_history_dirrÚexclude_sourcer$rŸÚtimeoutÚfileobjÚmsgÚerrorsÚ
downloadedÚ responsesÚ
file_countr�ÚorsrÈr s" @r;r€z
Item.downloades„ø€ôt�w“-ˆÜ�w“-ˆÜ˜Ó/ˆÜ˜]Ó+ˆ
ܘ“>ˆÜÐ 0Ó1ÐܘLÓ)ˆ ÜÐ 0Ó1ÐÜ"Ð#6Ó7ÐÜ!Ð"4Ó5ÐØ’˜4ˆÙ ܘf¤dÔ+Ø ˜�٠ܘn¬dÔ3Ø"0Ð!1�Ù Ü—i‘i¤§
¡
× 1Ñ 1Ó 3°TÀ5ÔIˆG؉GàˆGáÙ™gܘŸ™Ð)¨¨J¨<°rÐ:ÄÇÁÖLØÐ#©Ü˜Ÿ™Ð)¨Ð+´#·*±*Õ=à �<Š<ؘdŸo™oÐ.¨nÐ=ˆCÜ �K‰K˜Ô Ùܘ˜#˜�i¤c§j¡jÕ1؈IØ
�]‰]˜bÒ
ؘdŸo™oÐ.Ð.DÐEˆCÜ �K‰K˜Ô Ùܘ˜#˜�i¤c§j¡jÕ1؈Iá Ø—N‘N 5°Z�NÓ@‰Eà—N‘N¨j�NÓ9ˆEÙ Ø—N‘N¨7¸z�NÓJˆEÙ Ø—N‘NØ)Ø /Ø%ð#óˆEñ
ܘ“KˆEàˆØˆ
؈ ؈
àó ˆAØ! TÑ)Ø—6‘6×$Ñ$ ZÔ0ØÙœcÓ!@¸Ô!@Ô@ØÙ¤#Ó%L¸^Ô%LÔ"LØØ ˜!‰OˆJÙØ—v‘v‘ä—w‘w—|‘|¤C¨¯©Ó$8¸!¿&¹&ÓA�ÙÜ�a—e‘e” ØÙ˜*¤s¨5£zÒ1Ø‘à�Ø—
‘
˜4 ¨/¸8ÐEUØ" G¨]¸GÐEUØ.°¸¸fÀcÈ7óTˆAñ Ø× Ñ  Ô#à�E‰zØ—
‘
˜aŸf™fÖ%à˜a‘’
ð; ð> ˜Š?ؘdŸo™oÐ.Ð.HÐIˆCÜ �H‰H�SŒMÙܘ˜#˜�i¤c§j¡jÕ1؈Iá,ˆyÐ8°&Ð8r=cóœ—t|«}|xs|jj}| xs|jj} t|
«}
| xsi} |xsi}|
xsi}
|rt |«|
d<nd|
d<|jj
j
«}|j| «|jj›d|jj›d|j›�}|j}td|||||||| ||||| ¬«}|j«}|
r|S|jj|fi|
¤Ž}|r|j«|S)a/Modify the metadata of an existing item on Archive.org.
Note: The Metadata Write API does not yet comply with the
latest Json-Patch standard. It currently complies with `version 02
<https://tools.ietf.org/html/draft-ietf-appsawg-json-patch-02>`__.
:param metadata: Metadata used to update the item.
:param target: Set the metadata target to update.
:param priority: Set task priority.
:param append: Append value to an existing multi-value
metadata field.
:param expect: Provide a dict of expectations to be tested
server-side before applying patch to item metadata.
:param append_list: Append values to an existing multi-value
metadata field. No duplicate values will be added.
:param refresh: Refresh the item metadata after the request.
:param reduced_priority: Submit your task at a lower priority.
This option is helpful to get around rate-limiting.
Your task will more likely be accepted, but it might
not run for a long time. Note that you still may be
subject to rate-limiting.
:returns: A Request if debug else a Response.
Usage::
>>> import internetarchive
>>> item = internetarchive.Item('mapi_test_item1')
>>> md = {'new_key': 'new_value', 'foo': ['bar', 'bar2']}
>>> item.modify_metadata(md)
r;é<r�z
/metadata/ÚPOST)Úmethodr¤r,rÄÚsource_metadataÚtargetrÂrÝrÞr‘ÚexpectÚ append_listÚinsertrÅ)rGrJrÝrÞÚfloatrÄÚcopyr³r¢r£r)r*rÚprepareÚsendr›)r:r,rHr‘rIrJrKrÂrÝrÞÚdebugrÄrÅr«r;r›Ú_headersr¤rGÚrequestÚprepared_requestÚresps r;Úmodify_metadatazItem.modify_metadata%sQ€ôl�f“ˆØÒ: 4§<¡<×#:Ñ#:ˆ
ØÒ: 4§<¡<×#:Ñ#:ˆ
Ü�U“ ˆØ’-˜RˆØ’˜2ˆØ'Ò-¨2ˆÙ Ü(-¨g«ˆN˜9Ò %à(*ˆN˜9Ñ %à—<‘<×'Ñ'×,Ñ,Ó.ˆØ�‰˜Ô à—‘×&Ñ&Ð' r¨$¯,©,×*;Ñ*;Ð)<¸JÀtÇÁÐFWÐXˆð×,Ñ,ˆÜ!ØØØØØ+ØØØ!Ø!ØØØ#ØØ-ô/ˆð"#Ÿ?™?Ó,ÐÙ Ø#Ð #Ø ˆt�|‰|× Ñ Ð!1ÑD°^ÑDˆá Ø �L‰LŒN؈ r=có>—|€8d|jjjdi«jd«›�}|jj›d|jj›d�}ddi}|j
||dœ}|jj
|||¬ «}|S©
Nú@Úgeneralrçr�ú/services/flags/admin.phpÚAcceptú text/json)r)ÚcategoryÚuser©rÄrŸ)rJÚconfigrIr¢r£r)ró©r:r]r^r¤rÄrŸrÈs r;Ú delete_flagzItem.delete_flagˆs›€ð
ˆ<Ø�t—|‘|×*Ñ*×.Ñ.¨y¸"Ó=×AÑAÀ,ÓOÐPÐQˆDØ—‘×&Ñ&Ð' r¨$¯,©,×*;Ñ*;Ð)<Ð<UÐVˆØ˜[Ð)ˆØ $§¡¸XÈtÑTˆØ �L‰L× Ñ  ¨W¸VÐ Ó DˆØˆr=có>—|€8d|jjjdi«jd«›�}|jj›d|jj›d�}ddi}|j
||dœ}|jj
|||¬ «}|SrW)rJr`rIr¢r£r)rëras r;Úadd_flagz
Item.add_flag•s›€ð
ˆ<Ø�t—|‘|×*Ñ*×.Ñ.¨y¸"Ó=×AÑAÀ,ÓOÐPÐQˆDØ—‘×&Ñ&Ð' r¨$¯,©,×*;Ñ*;Ð)<Ð<UÐVˆØ˜[Ð)ˆØ $§¡¸XÈtÑTˆØ �L‰L× Ñ ˜S¨'¸&Ð Ó AˆØˆr=cóÆ—|jj›d|jj›d�}ddi}d|ji}|jj |||¬«}|S)Nr�rZr[r\r)r_)rJr¢r£r)rI)r:r¤rÄrŸrÈs r;Ú get_flagszItem.get_flags¢sc€Ø—‘×&Ñ&Ð' r¨$¯,©,×*;Ñ*;Ð)<Ð<UÐVˆØ˜[Ð)ˆØ §¡Ð0ˆØ �L‰L× Ñ ˜S¨'¸&Ð Ó AˆØˆr=có¤—d||dœ}tj|«ddœ}|jj|jj
|¬«}|S)zURemove item from a simplelist.
:returns: :class:`requests.Response`
ró)rÑÚparentr·Ú simplelists)z-patchz-target)rÃ)r r`rJrøryr,)r:rhr·ÚpatchrÃrÈs r;Úremove_from_simplelistzItem.remove_from_simplelistªsV€ð ØØñ
ˆô —j‘j Ó'Ø$ñ
ˆð
�L‰L× Ñ ˜dŸi™i×0Ñ0°tÐ Ó <ˆØˆr=c
ó^ ‡‡‡‡‡‡‡‡‡ ‡‡!‡"‡#—|xsi}‰xsiЉxsiЉxs‰jjЉxs‰jjŠt‰«Št‰ «Š t|
«}
t| «} | xs| } |
xsd}
|xsd}t|«}t|«}|xsi}d|vrd|d<d}|j «Š!t ‰d«s‰}t
‰d«Šn‰xs ‰j}t‰«Š"‰"dk(rd‰!d <‰!jd
«st‰"«‰!d
<|rt‰jxsd «‰€t|«jd «d
n‰Š‰jj›d‰j›�}|›d t!t‰«j#d «j%d««›�Š#| rÝt'‰«}‰j)‰«}‰j*sµ|r³|j,|k(r¤t.j1‰›d‰#›�«‰ rt3d‰›d�t4j6¬«| rMt.j1‰›d‰j›d ‰›d�«‰j9«t;j<|«‰j9«t?«S|
s| r|s t'‰«}|‰!d<ˆ!ˆˆˆˆˆˆˆˆˆˆ"ˆ#ˆ f
d„}|r2‰jjA|««}‰j9«|S d} d|›d|
›d�}|
dkDrg|se ‰jjC‰¬«}|rFtG|«t.j1|«‰ rt3d|›�t4j6¬«|
d z}
Œv|«}|jI«}|jJjd!«d"k(r
|jJd!=‰jjL|fd#di|¤Ž}|jNd$k(rr|
dkDrmd%|jPvrt.j1d&«nnt.j1|«‰ rt3d|›�t4j6¬«tG|«|
d z}
d'}�ŒX|jNd$k(rt.j1d(« |jS«t.j1d)‰›d*‰#›�«| r\|jNd+k(rMt.j1‰›d‰j›d ‰›d�«‰j9«t;j<|«|j9«|‰j9«S#tD$r}d|›d|›d|
›d�}d}Yd}~�Œd}~wwxYw#tT$rÄ} tW|jXjP«} n)#tZ$rd,|jXjN›d-�} YnwxYwd.‰›d*‰j›d/| ›�}t.j]|«‰ r!t3d.‰›d0| ›�t4j6¬«t_|«||jX|j`¬1«‚d}~wwxYw#‰j9«wxYw)2aÔUpload a single file to an item. The item will be created
if it does not exist.
:type body: Filepath or file-like object.
:param body: File or data to be uploaded.
:param key: Remote filename.
:param metadata: Metadata used to create a new item.
:param file_metadata: File-level metadata to add to
the files.xml entry for the file being
uploaded.
:param headers: Add additional IA-S3 headers to request.
:param queue_derive: Set to False to prevent an item from
being derived after upload.
:param verify: Verify local MD5 checksum matches the MD5
checksum of the file received by IAS3.
:param checksum: Skip based on checksum.
:param delete: Delete local file after the upload has been
successfully verified.
:param retries: Number of times to retry the given request
if S3 returns a 503 SlowDown error.
:param retries_sleep: Amount of time to sleep between
``retries``.
:param verbose: Print progress to stdout.
:param debug: Set to True to print headers to stdout, and
exit without sending the upload request.
:param validate_identifier: Set to True to validate the identifier before