
    M@c                         d dl Z d dlZd dlmZ d dlZd dlZd dlmZ  ee	      Z
 G d dej                  j                        Zy)    N)Path)	getLoggerc                   2     e Zd ZdgZdZ fdZ fdZ xZS )ExtractPluginextractzExtract tags from audio files.c                     t         |   |dd       | j                  j                  ddd       | j                  j                  dd	d
d       | j                  j                  dd
d       y )NTF)cache_filestrack_imagesz-oz--output-filez5The the tag is written to this file in native format.)helpz-Hz--hex
store_truezOutput hexadecimal format.)actionr   z--strip-paddingzExclude tag padding, if any.)super__init__	arg_groupadd_argument)self
arg_parser	__class__s     7/usr/lib/python3/dist-packages/eyed3/plugins/extract.pyr   zExtractPlugin.__init__   sw    EJ##D/)` 	$ 	b##D',)E 	$ 	G##$5l)G 	$ 	I    c                    t         |   |       | j                  | j                  j                  y | j                  j                  }t	        |t
        j                  j                        st        dt        j                         yt        |j                  j                  d      5 }|j                  d   dk7  rl|j                  |j                  j                         }| j"                  j$                  rD|j                  j&                  r.|d |j                  j&                    }n|j                         dd  }d d d        | j"                  j(                  rt+        |j                  j                        j-                         t+        | j"                  j(                        j-                         k(  rt        dt        j                         yt        | j"                  j(                  d      5 }|j/                         d d d        y | j"                  j0                  rt3        t5        j6                        d	      }t               y # 1 sw Y   xY w# 1 sw Y   y xY w)
Nz)Only ID3 tags can be extracted currently.)file   rbr   izGInput file overwriting not allowed, choose a different -o/--output-filewbascii)r   
handleFile
audio_filetag
isinstanceeyed3id3Tagprintsysstderropen	file_infonameversionreadtag_sizeargsstrip_paddingtag_padding_sizeoutput_filer   resolvewritehexstrbinasciihexlify)	r   fr-   kwargsr   tag_filetag_dataout_filer   s	           r   r   zExtractPlugin.handleFile   s   1??"doo&9&9&Aoo!!#uyy}}-=CJJO#--$$d+ 		2x{{1~"#==)?)?@99**s}}/M/M'(H#--*H*H)HIH $==?451		2 99   CMM&&'//1T$)):O:O5P5X5X5ZZ_::'dii++T2 )hx() ) yy}}x//97C(O5		2 		2&) )s   *BI1III#)__name__
__module____qualname__NAMESSUMMARYr   r   __classcell__)r   s   @r   r   r      s    KE.GI$ $r   r   )r%   r5   pathlibr   	eyed3.id3r!   eyed3.pluginseyed3.utils.logr   r<   logpluginsLoaderPluginr    r   r   <module>rJ      s7    
     %1EMM.. 1r   