Skip to content

Commit

Permalink
Add is_google_drive_url function
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Jan 26, 2024
1 parent d3e769f commit a080c9a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gdown/parse_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import warnings


def is_google_drive_url(url):
parsed = urllib.parse.urlparse(url)
return parsed.hostname in ["drive.google.com", "docs.google.com"]


def parse_url(url, warning=True):
"""Parse URLs especially for Google Drive links.
Expand All @@ -11,7 +16,7 @@ def parse_url(url, warning=True):
"""
parsed = urllib.parse.urlparse(url)
query = urllib.parse.parse_qs(parsed.query)
is_gdrive = parsed.hostname in ["drive.google.com", "docs.google.com"]
is_gdrive = is_google_drive_url(url=url)
is_download_link = parsed.path.endswith("/uc")

if not is_gdrive:
Expand Down

0 comments on commit a080c9a

Please sign in to comment.