a
    Ú
þdö  ã                   @   s*   d dl Z d dlZd dlmZ ddd„ZdS )é    N)Úurllib_parseTc                 C   s¾   t  | ¡}t  |j¡}|jdv }|j d¡}|s8||fS d}d|v rb|d }t|ƒdkr–|d }n4g d¢}|D ]&}	t 	|	|j¡}
|
rn|
 
¡ d } q–qn|r¶|s¶t djd	 |¡d
¡ ||fS )zŸParse URLs especially for Google Drive links.

    file_id: ID of file on Google Drive.
    is_download_link: Flag if it is download link of Google Drive.
    )zdrive.google.comzdocs.google.comz/ucNÚidé   r   )z^/file/d/(.*?)/(edit|view)$z$^/file/u/[0-9]+/d/(.*?)/(edit|view)$z(^/document/d/(.*?)/(edit|htmlview|view)$z1^/document/u/[0-9]+/d/(.*?)/(edit|htmlview|view)$z,^/presentation/d/(.*?)/(edit|htmlview|view)$z5^/presentation/u/[0-9]+/d/(.*?)/(edit|htmlview|view)$z,^/spreadsheets/d/(.*?)/(edit|htmlview|view)$z5^/spreadsheets/u/[0-9]+/d/(.*?)/(edit|htmlview|view)$z•You specified a Google Drive link that is not the correct link to download a file. You might want to try `--fuzzy` option or the following url: {url}z!https://drive.google.com/uc?id={})Úurl)r   ÚurlparseÚparse_qsÚqueryÚhostnameÚpathÚendswithÚlenÚreÚmatchÚgroupsÚwarningsÚwarnÚformat)r   ÚwarningÚparsedr   Z	is_gdriveZis_download_linkZfile_idZfile_idsÚpatternsÚpatternr   © r   úX/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/gdown/parse_url.pyÚ	parse_url   s0    



ýÿr   )T)r   r   Z	six.movesr   r   r   r   r   r   Ú<module>   s   