
    hh                     (    d dl Z d dlZd dlmZ ddZy)    N)urllib_parsec                    t        j                  |       }t        j                  |j                        }|j                  dv }|j
                  j                  d      }|s||fS d}d|v r|d   }t        |      dk(  rH|d   }nBg d}|D ]9  }	t        j                  |	|j
                        }
|
s&|
j                         d   } n |r6|s4t        j                  dj                  d	j                  |      
             ||fS )zParse 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)$zYou 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
   	is_gdriveis_download_linkfile_idfile_idspatternspatternr   s              M/var/www/html/dev/engine/venv/lib/python3.12/site-packages/gdown/parse_url.py	parse_urlr      s    ""3'F!!&,,/E#JJI{{++E2***Gu};x=AqkG	
   	GHHWfkk2E,,.+		 '**0&7>>wG +1 +	
 $$$    )T)r   r   	six.movesr   r    r   r   <module>r"      s    	  "-%r   