
    yi                     D    d dl Z d dlZdedefdZdedeedz  ef   fdZy)    Nurlreturnc                 \    t         j                  j                  |       }|j                  dv S )N)zdrive.google.comzdocs.google.com)urllibparseurlparsehostname)r   parseds     C/home/ubuntu/.local/lib/python3.12/site-packages/gdown/parse_url.pyis_google_drive_urlr      s&    \\""3'F??EEE    c                    t         j                  j                  |       }t         j                  j                  |j                        }t        |       }|j                  j                  d      }|sd|fS d}d|v r|d   }t        |      dk(  r|d   }||fS g d}|D ]<  }t        j                  ||j                        }	|	s&|	j                         d   } ||fS  ||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.
    )r   z/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)$)r   r   r   parse_qsqueryr   pathendswithlenrematchgroups)
r   r
   r   	is_gdriveis_download_linkfile_idfile_idspatternspatternr   s
             r   	parse_urlr   
   s     \\""3'FLL!!&,,/E#,I{{++E2%%%Gu};x=AqkG$ $$$!	
   	GHHWfkk2E,,.+$$$	 $$$r   )r   urllib.parser   strboolr   tupler    r   r   <module>r%      sB    	 FS FT F
$%3 $%5tT!12 $%r   