File: //usr/local/lib/python3.6/site-packages/gdown/__pycache__/parse_url.cpython-36.pyc
3
LBj� � @ s* d dl Z d dlZd dlmZ ddd�ZdS )� N)�urllib_parseTc C s� t j| �}t j|j�}|jdk}|jjd�}|s8||fS d}d|krb|d }t|�dkr�|d }nBdd d
ddd
ddg}x,|D ]$} tj | |j�}
|
r||
j
� d }P q|W |r�| r�tjdj
dj
|�d�� ||fS )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.
�drive.google.com�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 r )r �urlparse�parse_qs�query�hostname�path�endswith�len�re�match�groups�warnings�warn�format)r �warning�parsedr
Z is_gdriveZis_download_linkZfile_idZfile_ids�patterns�patternr � r �0/tmp/pip-build-44150kxb/gdown/gdown/parse_url.py� parse_url s:
r )T)r r Z six.movesr r r r r r �<module> s