Add BrowserCookieJar class and get_browser function#186
Add BrowserCookieJar class and get_browser function#186ReK42 wants to merge 2 commits intoborisbabic:masterfrom
Conversation
|
I added these because I'm currently using the following method to pull cookies from a specific browser in bcamp-dl, where func = getattr(browser_cookie3, self.browser)
self.cookies = func(domain_name="bandcamp.com")This seems a little fragile to me, as I need to validate the string against a list of supported browsers that isn't easily available from upstream, and it can produce some unhelpful exceptions if it goes wrong. Adding a subclass of The |
Adds the following methods to get cookies:
BrowserCookieJaris a subclass ofhttp.cookiejar.CookieJarwhich will take the browser name as a string:get_browseris a function which will return the browser-specific function based on the browser name as a string:To support these, I update the type annotations on the existing browser-specific functions, including adding the
key_fileargument to those which didn't have it, for consistency. Additionally, both methods use a newSUPPORTED_BROWSERSdictionary, and theloadmethod was updated to use it as well: