Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(file_id, False),
True,
),
(
"https://drive.google.com/a/jsk.imi.i.u-tokyo.ac.jp/uc?id={}&export=download".format( # NOQA
file_id
),
(file_id, True),
False,
),
]
for url, expected, check_warn in urls:
if check_warn:
with pytest.warns(UserWarning):
assert parse_url(url) == expected
else:
assert parse_url(url) == expected
# Load cookies
cache_dir = osp.join(home, ".cache", "gdown")
if not osp.exists(cache_dir):
os.makedirs(cache_dir)
cookies_file = osp.join(cache_dir, "cookies.json")
if osp.exists(cookies_file) and use_cookies:
with open(cookies_file) as f:
cookies = json.load(f)
for k, v in cookies:
sess.cookies[k] = v
if proxy is not None:
sess.proxies = {"http": proxy, "https": proxy}
print("Using proxy:", proxy, file=sys.stderr)
file_id, is_download_link = parse_url(url)
while True:
try:
res = sess.get(url, stream=True)
except requests.exceptions.ProxyError as e:
print("An error has occurred using proxy:", proxy, file=sys.stderr)
print(e, file=sys.stderr)
return
# Save cookies
with open(cookies_file, "w") as f:
cookies = [
(k, v)
for k, v in sess.cookies.items()
if not k.startswith("download_warning_")