
    VGh                     f    d dl Z d dlZd dlZddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZ  G d de      Zy)    N   )PostProcessor   )PopenPostProcessingErrorcheck_executable
cli_optionencodeArgumentprepend_extensionshell_quotestr_or_nonec                   V    e Zd ZdZdZd	dZd
dZ ej                  d      d        Z	y)SponSkrubPPspons	sponskrubNFc                    t        j                  | |       || _        || _        t	        |      xs d| _        | j                  |      | _        |s| j                  d       |s)| j                  |rt        d| d      t        d      y y )N zyt_dlp.postprocessor.SponSkrubPP support is deprecated and may be removed in a future version. Use yt_dlp.postprocessor.SponsorBlock and yt_dlp.postprocessor.ModifyChaptersPP insteadzsponskrub not found in ""zNsponskrub not found. Please install or provide the path using --sponskrub-path)
r   __init__forcecutoutr   argsget_exepathdeprecation_warningr   )self
downloaderr   r   ignoreerrorcutr   	_from_clis           g/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/yt_dlp/postprocessor/sponskrub.pyr   zSponSkrubPP.__init__   s    tZ0
%+	LL&	$$jk tyy0),DTF!*LMM)*z{{	  1{    c                     |rt        |dg      s8t        j                  j                  || j                        }t        |dg      sy |S )Nz-h)r   osr   join	_exe_name)r   r   s     r!   r   zSponSkrubPP.get_exe)   s=    +D4&977<<dnn5D#D4&1r"   )imagesc                    | j                   g |fS |d   }t        j                   j                  |      sg |fS |d   j                         dk7  r| j	                  d       g |fS | j
                  r3| j                  s'|j                  dd      s| j                  d       g |fS | j	                  d| j
                  rd	nd
z         | j
                  r4| j                  d       |j                  dd      s| j                  d       t        || j                        }t        j                   j                  |      rt        j                  |       | j                   g}| j
                  s|dgz  }|t        | j                  j                  dd      z  }|t        j                   | j"                        z  }|| j%                  | j&                  d      z  }|d|d   ||gz  }|D cg c]  }t)        |       }}| j+                  dt-        |              t/        j0                  |d| j3                  d      rd nt4        j6                        \  }}}|s<t        j8                  ||       | j	                  d| j
                  rdndz         g |fS |dk(  r| j	                  d       g |fS t;        |j=                         j?                         |j=                         j                         jA                  d      rdnd   xs d|       c c}w ) Nfilepathextractor_keyyoutubez2Skipping sponskrub since it is not a YouTube video__real_downloadFzhSkipping sponskrub since the video was already downloaded. Use --sponskrub-force to run sponskrub anywayzTrying to %s sponsor sectionsremovemarkzHCutting out sponsor segments will cause the subtitles to go out of sync.zSIf sponskrub is run multiple times, unintended parts of the video could be cut out.z-chapterz-proxyproxy)
use_compatz--idzsponskrub command line: Tverbose)textstdoutzSponsor sections have been %sremovedmarked   z(No segments in the SponsorBlock databaseunrecognisedr   z!sponskrub failed with error code )!r   r$   existslower	to_screenr   r   getreport_warningr   	_temp_extr-   r	   _downloaderparamsshlexsplitr   _configuration_argsr&   r
   write_debugr   r   run	get_param
subprocessPIPEreplacer   strip
splitlines
startswith)	r   informationfilenametemp_filenamecmdir4   _
returncodes	            r!   rF   zSponSkrubPP.run0   s   99{?"z*ww~~h'{?"'--/9<NNOP{?";;tzz+//BSUZ2[@A {?"6dkk(W]^_;; jk??#4e<##$yz)(DNNC77>>-(IIm$yyk{{J<Cz$**118WEEu{{499%%t''5'IIk$'=AA*-.Q~a ..3K4D3EFG %		#DXaIbhrhwhw x:JJ}h/NN:4;;i\def ; 1_NNEF
 ; &))+1E1E1G1R1RSa1bAhjk D6zlCE E /s   $L
)r   NFFFF)r   )
__name__
__module____qualname__r?   r&   r   r   r   _restrict_torF    r"   r!   r   r      s8    II|$  ]u-0 .0r"   r   )r$   rB   rH   commonr   utilsr   r   r   r	   r
   r   r   r   r   rY   r"   r!   <module>r\      s.    	   !	 	 	N- Nr"   