From 4b0ed2ab99c84998516745f156827d68822dcd93 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 1 Apr 2019 14:30:30 +0530 Subject: [PATCH] py3: Port use of cookielib in recipes --- recipes/discover_magazine_monthly.recipe | 7 +++++-- recipes/economist.recipe | 7 +++++-- recipes/economist_free.recipe | 7 +++++-- recipes/trouw.recipe | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/recipes/discover_magazine_monthly.recipe b/recipes/discover_magazine_monthly.recipe index 37babe26cb..1c6eb8cd02 100644 --- a/recipes/discover_magazine_monthly.recipe +++ b/recipes/discover_magazine_monthly.recipe @@ -9,7 +9,10 @@ discovermagazine.com ''' import re import json -import cookielib +try: + from http.cookiejar import Cookie +except ImportError: + from cookielib import Cookie import mechanize from calibre.web.feeds.news import BasicNewsRecipe @@ -55,7 +58,7 @@ class DiscoverMagazine(BasicNewsRecipe): if hasattr(br, 'set_cookie'): br.set_cookie('KSERV', session_id, 'discovermagazine.com') else: - c = cookielib.Cookie( + c = Cookie( None, 'KSERV', session_id, None, False, 'discovermagazine.com', True, False, diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 2608db52ed..0dd9272f18 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -5,7 +5,10 @@ __copyright__ = '2008, Kovid Goyal ' ''' economist.com ''' -import cookielib +try: + from http.cookiejar import Cookie +except ImportError: + from cookielib import Cookie from collections import OrderedDict from calibre.ebooks.BeautifulSoup import NavigableString, Tag @@ -113,7 +116,7 @@ class Economist(BasicNewsRecipe): br = BasicNewsRecipe.get_browser(self) # Add a cookie indicating we have accepted Economist's cookie # policy (needed when running from some European countries) - ck = cookielib.Cookie( + ck = Cookie( version=0, name='notice_preferences', value='2:', diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 2608db52ed..0dd9272f18 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -5,7 +5,10 @@ __copyright__ = '2008, Kovid Goyal ' ''' economist.com ''' -import cookielib +try: + from http.cookiejar import Cookie +except ImportError: + from cookielib import Cookie from collections import OrderedDict from calibre.ebooks.BeautifulSoup import NavigableString, Tag @@ -113,7 +116,7 @@ class Economist(BasicNewsRecipe): br = BasicNewsRecipe.get_browser(self) # Add a cookie indicating we have accepted Economist's cookie # policy (needed when running from some European countries) - ck = cookielib.Cookie( + ck = Cookie( version=0, name='notice_preferences', value='2:', diff --git a/recipes/trouw.recipe b/recipes/trouw.recipe index 0c224296e3..48b0a3d4a9 100644 --- a/recipes/trouw.recipe +++ b/recipes/trouw.recipe @@ -1,5 +1,8 @@ from calibre.web.feeds.news import BasicNewsRecipe -import cookielib +try: + from http.cookiejar import Cookie +except ImportError: + from cookielib import Cookie class BasicUserRecipe1333905513(BasicNewsRecipe): @@ -15,7 +18,7 @@ class BasicUserRecipe1333905513(BasicNewsRecipe): br = BasicNewsRecipe.get_browser(self) # Add a cookie indicating we have accepted the cookie # policy - ck = cookielib.Cookie( + ck = Cookie( version=0, name='nl_cookiewall_version', value='1', port=None, port_specified=False, domain='.trouw.nl', domain_specified=False, domain_initial_dot=True, path='/',