
    Eg                         d dl Z d dlmZ d dlZd dlZd dlmZ d dlZdddZ e j                    Z	e	j
                            e            G d d          ZdS )    N)HTTPAdapter)datetimezapplication/json)zContent-TypeAcceptc                   V   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Zd Zd Z d,d
Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d Z5d Z6d  Z7d! Z8d" Z9d# Z:d$ Z;d% Z<d& Z=d' Z>d( Z?d) Z@d-d+ZAdS ).antiNetworking r   NhttpFc                 \    |                      dd| j        i          }|dk    r|d         S dS )N
getBalance	clientKeyr   balancemake_request
client_keyselfresults     W/var/www/sysmax/venv/lib/python3.11/site-packages/anticaptchaofficial/antinetworking.pyget_balancezantiNetworking.get_balance.   s7    ""<+t1OPPQ;;)$$2    c                 d    |                      dd| j        i          }|dk    rd|v r|d         S dS )Nr   r   r   captchaCreditsr   r   r   s     r   get_credits_balancez"antiNetworking.get_credits_balance5   sC    ""<+t1OPPQ;;+v55*++2r   c                     |                      d|          }|dk    rdS |d         dk    r|d         | _        dS |d         | _        d|d         z   dz   |d	         z   | _        dS )
N
createTaskr   errorIdtaskId   	errorCode
API error : errorDescription)r   task_id
error_code
err_string)r   	post_datanew_tasks      r   create_taskzantiNetworking.create_task<   sx    $$\9==q==1	"a'''1q"*;"7".x/D"Dt"KHUgLh"hqr   ,  c                    ||k    r	d| _         dS t          j        d           |                     d| j        | j        d          }|dk    rdS |d         dk    r_|d         dk    r.|                     d	           |                     ||dz             S |d         d
k    r|                     d           |S d S |d         | _        d|d         z   dz   |d         z   | _         |                     | j                    dS )Nztask solution expiredr   r   getTaskResultr   r   r   status
processingztask is still processingreadyztask solvedr    r!   r"   r#   )	r&   timesleepr   r   r$   logwait_for_resultr%   )r   max_secondscurrent_second
task_checks       r   r4   zantiNetworking.wait_for_resultI   s'   [((5DO1
1&&l9
 9
  
 ??1)$))h'<77HH7888//^A=MNNNh'722HH]+++%% 32 #-["9".z+/F"F"MjYkNl"l)))qr   c                 H    |                      d| j        | j        d          S )NreportIncorrectImageCaptchar-   r   r   r$   r   s    r   report_incorrect_image_captchaz-antiNetworking.report_incorrect_image_captchad   s3      !>lA
 A
   	r   c                 H    |                      d| j        | j        d          S )NreportIncorrectRecaptchar-   r:   r;   s    r   report_incorrect_recaptchaz)antiNetworking.report_incorrect_recaptchaj   s1      !;l>
 >
   	r   c                 H    |                      d| j        | j        d          S )NreportCorrectRecaptchar-   r:   r;   s    r   report_correct_recaptchaz'antiNetworking.report_correct_recaptchap   s1      !9l<
 <
   	r   c                 H    |                      d| j        | j        d          S )NreportIncorrectHcaptchar-   r:   r;   s    r   report_incorrect_hcaptchaz(antiNetworking.report_incorrect_hcaptchav   s1      !:l=
 =
   	r   c                 "   |                      d|z              	 t                              d|z   t          j        |                    }n0# t
          j        j        $ ry}|                      d|j        |j	        |j
        |j                   d| _        |j
        D ]2}dt          |          v rd| _        dt          |          v rd| _        3Y d }~dS d }~wt
          j        j        $ r d	| _        Y dS t          j        j        $ r d	| _        Y dS t
          j        j        $ r d
| _        Y dS t          j        j        $ r}d|j        z   | _        Y d }~dS d }~wt
          j        j        $ r d| _        Y dS w xY w|                                S )Nzmaking request to zhttps://api.anti-captcha.com/)data	HTTPError
http_errorzNetwork is unreachablezConnection refusedr   zConnection timeoutzRead timeoutzConnection retry error: )r3   sessionpostjsondumpsrequests
exceptionsrH   errnostrerrorargsfilenamer&   strConnectTimeouturllib3ConnectTimeoutErrorReadTimeoutMaxRetryErrorreasonConnectionError)r   methodrG   responseerrerrArgs         r   r   zantiNetworking.make_request|   s   %f,---	||$CF$JQUQ[\`QaQa|bbHH", 	 	 	HH[#)S\38S\RRR*DO( ; ;+s6{{::&>DO'3v;;66&:DO11111"1 	 	 	2DO11!5 	 	 	2DO11". 	 	 	,DO11!/ 	 	 	8CDO11111"2 	 	 	2DO11	 }}s<   1A E:!A.CE:6E:E:0E:EE:9E:c                     || _         d S N)r   r   values     r   set_keyzantiNetworking.set_key       r   c                     || _         d S ra   )soft_idrb   s     r   set_soft_idzantiNetworking.set_soft_id       r   c                     || _         d S ra   )website_urlrb   s     r   set_website_urlzantiNetworking.set_website_url        r   c                     || _         d S ra   )website_keyrb   s     r   set_website_keyzantiNetworking.set_website_key   rm   r   c                     || _         d S ra   )website_stokenrb   s     r   set_website_stokenz!antiNetworking.set_website_stoken       #r   c                     || _         d S ra   )recaptcha_data_srb   s     r   
set_data_szantiNetworking.set_data_s   s     %r   c                     || _         d S ra   )recaptcha_enterprise_payloadrb   s     r   set_enterprise_payloadz%antiNetworking.set_enterprise_payload   s    ,1)))r   c                     || _         d S ra   )
proxy_typerb   s     r   set_proxy_typezantiNetworking.set_proxy_type   re   r   c                     || _         d S ra   )proxy_addressrb   s     r   set_proxy_addressz antiNetworking.set_proxy_address       "r   c                     || _         d S ra   )
proxy_portrb   s     r   set_proxy_portzantiNetworking.set_proxy_port   re   r   c                     || _         d S ra   )proxy_loginrb   s     r   set_proxy_loginzantiNetworking.set_proxy_login   rm   r   c                     || _         d S ra   )proxy_passwordrb   s     r   set_proxy_passwordz!antiNetworking.set_proxy_password   rt   r   c                     || _         d S ra   )
user_agentrb   s     r   set_user_agentzantiNetworking.set_user_agent   re   r   c                     || _         d S ra   )cookiesrb   s     r   set_cookieszantiNetworking.set_cookies   ri   r   c                     || _         d S ra   )is_invisiblerb   s     r   set_is_invisiblezantiNetworking.set_is_invisible   s    !r   c                     || _         d S ra   )is_enterpriserb   s     r   set_is_enterprisez antiNetworking.set_is_enterprise   r   r   c                     || _         d S ra   )
is_verboserb   s     r   set_verbosezantiNetworking.set_verbose   re   r   c                 6    | j         rt          |           d S d S ra   )r   print)r   msgs     r   r3   zantiNetworking.log   s%    ? 	#JJJJJ	 	r   c                     t          t          j                    t          ddd          z
                                            S )Ni  r   )intr   utcnowtotal_secondsr;   s    r   get_time_stampzantiNetworking.get_time_stamp   s5    HO%%q!(<(<<KKMMNNNr   c                     || _         d S ra   )phraserb   s     r   
set_phrasezantiNetworking.set_phrase   s    r   c                     || _         d S ra   )caserb   s     r   set_casezantiNetworking.set_case       			r   c                     || _         d S ra   )numericrb   s     r   set_numericzantiNetworking.set_numeric   ri   r   c                     || _         d S ra   )mathrb   s     r   set_mathzantiNetworking.set_math   r   r   c                     || _         d S ra   )	minLengthrb   s     r   set_minLengthzantiNetworking.set_minLength       r   c                     || _         d S ra   )	maxLengthrb   s     r   set_maxLengthzantiNetworking.set_maxLength   r   r   c                     || _         d S ra   )commentrb   s     r   set_commentzantiNetworking.set_comment   ri   r   d   c                 ^    t          ||          }t                              d|           d S )N)pool_connectionspool_maxsizezhttps://)r   rJ   mount)r   r   r   adapters       r   set_poolSizezantiNetworking.set_poolSize   s8    -%
 
 
 	j'*****r   )r*   r   )r   )B__name__
__module____qualname__r   rg   rk   ro   rr   rv   ry   r|   r   r   r   r   r   r   r   r   r   r&   r$   r%   r   r   r   r   r   r   r   r   r   r)   r4   r<   r?   rB   rE   r   rd   rh   rl   rp   rs   rw   rz   r}   r   r   r   r   r   r   r   r   r   r3   r   r   r   r   r   r   r   r   r    r   r   r   r      s       JGKKN#' JMJKNJGLMJJGJFDGDIIG         6          >       ! ! !! ! !$ $ $' ' '3 3 3     # # #     ! ! !$ $ $       " " "# # #       O O O              + + + + + +r   r   )rN   requests.adaptersr   rL   rV   r   r1   default_headersSessionrJ   headersupdater   r   r   r   <module>r      s     ) ) ) ) ) )         #5ASTT
(


    ' ' 'a+ a+ a+ a+ a+ a+ a+ a+ a+ a+r   