fromhttp.cookiejarimportMozillaCookieJarimportos.pathasospimportrequestsdef_get_session(proxy,use_cookies,user_agent,return_cookies_file=False):sess=requests.session()sess.headers.update({"User-Agent":user_agent})ifproxyisnotNone:sess.proxies={"http":proxy,"https":proxy}print("Using proxy:",proxy,file=sys.stderr)# Load cookies if existscookies_file=osp.join(home,".cache/gdown/cookies.txt")ifuse_cookiesandosp.exists(cookies_file):cookie_jar=MozillaCookieJar(cookies_file)cookie_jar.load()sess.cookies.update(cookie_jar)ifreturn_cookies_file:returnsess,cookies_fileelse:returnsess