
    hj                         S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
JrJrJrJrJr  \" SS	S
9S 5       r\" SS	S
9S 5       r\" SS	S
9S 5       r\" SS	S
9S 5       r\" SS	S
9S 5       rg)u  
✘ Commands Available

• `{i}gdul <reply/file name>`
    Reply to file to upload on Google Drive.
    Add file name to upload on Google Drive.

• `{i}gdown <file id/link> | <filename>`
    Download from Gdrive link or file id.

• `{i}gdsearch <file name>`
    Search file name on Google Drive and get link.

• `{i}gdlist`
    List all GDrive files.

• `{i}gdfolder`
    Link to your Google Drive Folder.
    If added then all files will be uploaded in this folder.
    N)Message)GDriveManager)time_formatter   )	ULTConfigassteodeor
get_stringultroid_cmdzgdown( (.*)|$)T)patternfullsudoc           	      z  #    [        5       nU R                  R                  S5      R                  5       nU(       d  [	        U S5      I S h  vN $ SU;   a"  UR                  S5      S   R                  5       OS nU R                  [        S5      5      I S h  vN n[        R                  " 5       nUR                  XBU5      I S h  vN u  pgU(       d  UR                  U5      I S h  vN $ UR                  SU S[        [        R                  " 5       U-
  S-  5       S35      I S h  vN   g  N N Nm NM N7f)	Nr   z/`Give file id or Gdrive link to download from!`z | com_1z`Downloaded ``z`` in i  `)r   pattern_matchgroupstripr	   splitr
   r   time_download_fileeditr   )eventGDrivematchfilenameeve_startstatusresponses           #/root/TeamUltroid/plugins/gdrive.pygdownr"   '   s    
 _F%%a(..0E QRRR05u{{5!!$**,DH		*W-.
.CYY[F#223xHHFXXh'''
((

&v9Mt8S)T(UUVW   S
.H's\   A
D;D1AD;D3.D;D5!D;)D7*AD;+D9,D;3D;5D;7D;9D;zgdlist$c                    #    [        5       n[        R                  R                  UR                  5      (       dI  U R                  [        S5      R                  [        R                  R                  5      5      I S h  vN $ U R                  [        S5      5      I S h  vN nSnUR                  =n(       a7  U[        UR                  5       5       S3-  nU H  nUSXE    SU S3-  nM     OUS-  n[        U5      S	:  a  UR                  US
S9I S h  vN   g [        SS5       nUR!                  UR#                  SS5      R#                  SS5      R#                  SS5      5        S S S 5         UR%                  5       I S h  vN   U R(                  R+                  U R,                  S[.        R0                  U S9I S h  vN   [        R2                  " S5        g  GNb GNC N! , (       d  f       N= f Np! [&         a     Nzf = f NF7f)Ngdrive_6r    z files found in gdrive.

> []()
zNothing in Gdrive   Flink_previewdrive-files.txtw[File Name: 
   
» Link: 

thumbreply_to)r   ospathexists
token_filer
   r   formatr   meusername_list_fileslenkeysr   openwritereplacedeleteBaseExceptionclient	send_filechat_idr   r3   remove)r   r   r   msgfiles_fs          r!   rI   rI   ;   s    
 _F77>>&++,,YYz*5<<TWW=M=MNOOO		*W-.
.C
C"""u"#ejjl#$$?@@AS
"QCs++C  	""
3x$hhsh///#S)QGGC/}-' *	**, ll$$MM//	 % 
 	
 	
 			#$9 P
. 	0))  			
s   A=H?G! !H!G$"A7HG'H+AG)-H6G< 	G:
G< 7HHH$H'H)
G73H:G< <
H	HH		Hzgdul( (.*)|$)c           	        #    [        5       n[        R                  R                  UR                  5      (       dD  [        U [        S5      R                  [        R                  R                  5      5      I S h  vN $ U R                  R                  S5      R                  5       =(       d    U R                  5       I S h  vN nU(       d  [        U S5      I S h  vN $ U R                  [        S5      5      I S h  vN n[!        U["        5      (       a  SnUR$                  (       a  UR'                  U5      I S h  vN nOUR(                  R*                  nU(       d'  [-        [/        [0        R0                  " 5       5      5      nU SU 3n U R2                  R5                  UR6                  R8                  USU[        S5      S	9I S h  vN u  pVUR*                  nUR=                  SU S35      I S h  vN   OGUR                  5       n[        R                  R                  U5      (       d  [        USSS9I S h  vN $ S n[        R                  R?                  U5      (       a  [        R@                  " U5      n	U	(       d  [        US5      I S h  vN $ URC                  U5      nSn
[E        U	5       HN  n	U SU	 3n[        R                  R?                  U5      (       a  M0   URG                  X;US9I S h  vN   U
S-  n
MP     UR=                  SU SU SU
 S35      I S h  vN $  URG                  UU5      I S h  vN nUR=                  [        S5      R                  URI                  S5      S   U5      5      I S h  vN   g  GN GN GN GN GN] GN! [:         a'  n[        U[-        U5      S
S9I S h  vN  s S nA$ S nAff = f GN GN GND N! [:         a)  nUR=                  SU 35      I S h  vN  s S nAs  $ S nAff = f N N N! [:         a'  nUR=                  SU 35      I S h  vN     S nAg S nAff = f7f)Nr$   r   z%`Reply to file or give its location.`r   zresources/downloads/Tcom_5)filer   show_progressr   message
   )r   z`Downloaded to ``z`.`z7File Not found in local server. Give me a file path :((   z=`Requested directory is empty. Can't create empty directory.`r   )r6   	folder_idz-Exception occurred while uploading to gDrive z`Uploaded `[z)](https://drive.google.com/folderview?id=z)` with z files.`gdrive_7)%r   r5   r6   r7   r8   r	   r   r9   r   r:   r;   r   r   r   get_reply_messager
   
isinstancer   photodownload_mediarO   namestrroundr   rD   fast_downloadermediadocument	Exceptionr   isdirlistdircreate_directorysorted_upload_filer   )r   r   
input_filemonelocationr   downloaded_inerT   rI   crO   g_drive_links                r!   rJ   rJ   a   s    
 _F77>>&++,,
: 6 = =dgg>N>N OPPP$$**1-335Xu?V?V?X9XJ GHHH:g.//D*g&&('66x@@H!++HuTYY[12"1XJ/H
8050L0L#))22%"&&w/ 1M 1 +' $== iiz-
 	
 	
 ##%ww~~h''I  
 I	ww}}X

8$U   ++H5	E]EZq(D77==&& --d-SSSFA # YY8*$Mi[X`ab`cckl
 
 	
	M#00
 
 iiz"))(..*=b*A<P
 	
 	
 Q9XH/ A+  8 s1vB77778	
 T  !%GsK"   

	
  MiiGsKLLLMs  A8Q:N;AQNQN!Q?N A Q NAQ=N# N N# "Q:O;AQOAQOAQ-O" O 	O"
"Q,P-Q2P PAP PP QQQQQ N# #
O-OOO	O
QOQQQ O""
P,PPPP	QPQP P 
Q(Q
?Q Q
Q
QQzgdsearch( (.*)|$)c                   #    [        5       n[        R                  R                  UR                  5      (       dI  U R                  [        S5      R                  [        R                  R                  5      5      I S h  vN $ U R                  R                  S5      R                  5       nU(       d  U R                  S5      I S h  vN $ U R                  SU S35      I S h  vN nUR                  U5      nSnU(       a:  U[        UR!                  5       5       SU S3-  nU H  nUS	XF    S
U S3-  nM     O	USU S3-  n[        U5      S:  a  UR                  USS9I S h  vN   g [#        SS5       nUR%                  UR'                  SS5      R'                  S
S5      R'                  SS5      5        S S S 5         UR)                  5       I S h  vN   U R,                  R/                  U R0                  U S3[2        R4                  U S9I S h  vN   [        R6                  " U S35        g  GN GNr GNX N! , (       d  f       N= f Ny! [*         a     Nf = f NL7f)Nr$   r   z&`Give filename to search on GDrive...`z`Searching for z in G-Drive...`r%   z files with z in title found in GDrive.

r&   r'   r(   z`No files with title r   r)   Fr*   r,   r-   r.   r/   r0   r1   z.txtr2   )r   r5   r6   r7   r8   r
   r   r9   r   r:   r;   r   r   r   searchr=   r>   r?   r@   rA   rB   rC   rD   rE   rF   r   r3   rG   )r   r   	input_strr   rI   rH   rJ   rK   s           r!   rJ   rJ      s     
 _F77>>&++,,YYz*5<<TWW=M=MNOOO##))!,224IYYGHHH		OI;oFG
GCMM)$E
C5::< !i[8VW	
 AS
"QCs++C  	&yk33
3x$ggcg...#S)QGGC/}-' *	**, ll$$MMk//	 % 
 	
 	
 			YKt$%E P I
G 	/))  			
s   A=I'?H7 AI'H:	I'%H=&BI')I *I';AI=I'I II :I'I%I':I'=I' I'
II'I 
I"I'!I""I'z	gdfolder$c                   #    [        5       n[        R                  R                  UR                  5      (       dI  U R                  [        S5      R                  [        R                  R                  5      5      I S h  vN $ UR                  (       a6  U R                  SUR                  UR                  5      -   5      I S h  vN   g [        U S5      I S h  vN   g  N` N N	7f)Nr$   z`Your G-Drive Folder link : `
z0Set FOLDERID from your Assistant bot's Settings )r   r5   r6   r7   r8   r
   r   r9   r   r:   r;   rT   _create_folder_linkr	   )r   r   s     r!   rJ   rJ      s     
 _F77>>&++,,YYz*5<<TWW=M=MNOOOii-(()9)9:;
 	
 	

 %KLLL P	

 	Ms7   A=C&?C  AC&C"C&C$C&"C&$C&)__doc__r5   r   telethon.tl.typesr   pyUltroid.fns.gDriver   pyUltroid.fns.helperr   r%   r   r   r	   r
   r   r   r"   rI   rJ        r!   <module>ry      s   * 
  % . / @ @ 	  %	%D FM	FMR %&	%&P 
M	
Mrx   