a
    
d                     @   s   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZddl	m
Z
 ddlmZ ddlmZ ddlmZ G dd	 d	ejZd
d Zdd Zedkre  dS )    )print_functionN   )__version__)download)MAX_NUMBER_FILES)download_folderc                   @   s   e Zd ZdddZdS )_ShowVersionActionNc                 C   s.   t djttjtjtd |  d S )Nzgdown {ver} at {pos})verpos)printformatr   ospathdirname__file__exit)selfparser	namespacevaluesoption_string r   R/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/gdown/cli.py__call__   s    z_ShowVersionAction.__call__)N)__name__
__module____qualname__r   r   r   r   r   r      s   r   c                 C   sv   | d urrt d| }|st| \}}t|}|dkrB|d9 }n,|dkrT|d9 }n|dkrf|d9 }n|dkrn|S d S )	Nz([0-9]+)(GB|MB|KB|B)ZKBi   ZMBi   ZGBi   @B)rematch	TypeErrorgroupsfloat)argvmsizeunitr   r   r   	file_size   s    


r'   c                  C   s  t jt jd} | jddtddd | jddd	 | jd
ddd	 | jddddd | jdddd | jdddd | jddd	 | jdtdd | jdddd | jdddd | jdd d!dd"d# | jd$dd%jtd&d | jd'dd(jtd&d | jd)d*d	 |  }|j	d+kr2t
jr*tjj|_	ntj|_	|jrTtjd,td- d }|j}n&td.|jrp|j}d }n
d }|j}|jrt|||j	|j|j|j|j |j |jd/	}|d u}n<t||j	|j|j|j|j |j ||j|j |jd0}|d u}|st!d1 d S )2N)formatter_classz-Vz	--versionzdisplay versionr   )actionhelpnargs	url_or_idz2url or file/folder id (with --id) to download from)r*   z-Oz--outputzoutput file name / pathz-qz--quiet
store_truezsuppress standard output)r)   r*   z--fuzzyz*(fild only) extract Google Drive's file IDz--idz:[DEPRECATED] flag to specify file/folder id instead of urlz--proxyz9<protocol://host:port> download using the specified proxyz--speedz7download speed limit in second (e.g., '10MB' -> 10MB/s))typer*   z--no-cookiesz0don't use cookies in ~/.cache/gdown/cookies.jsonz--no-check-certificatez(don't check the server's TLS certificatez
--continuez-c	continue_z6(file only) resume getting a partially-downloaded file)destr)   r*   z--folderzLdownload entire folder instead of a single file (max {max} files per folder))maxz--remaining-okzH(folder only) asserts that is ok to download max {max} files per folder.z--formatztFormat of Google Docs, Spreadsheets and Slides. Default is Google Docs: 'docx', Spreadsheet: 'xlsx', Slides: 'pptx'.-z}Option `--id` was deprecated in version 4.3.1 and will be removed in 5.0. You don't need to pass it anymore to use a file ID.)categoryz^https?://.*)	urlidoutputquietproxyspeeduse_cookiesverifyremaining_ok)r4   r6   r7   r8   r9   r:   r;   r5   fuzzyresumer   r   )"argparseArgumentParserArgumentDefaultsHelpFormatteradd_argumentr   r'   r   r   
parse_argsr6   sixPY3sysstdoutbufferr5   warningswarnFutureWarningr,   r   r   folderr   r7   r8   r9   Z
no_cookiesZno_check_certificater<   r   r=   r/   r   )r   argsr4   r5   	filenamessuccessfilenamer   r   r   main-   s    
rQ   __main__)
__future__r   r?   os.pathr   r   rF   rI   rD    r   r   r   r   Actionr   r'   rQ   r   r   r   r   r   <module>   s    
 