diff --git a/modules/orange/browser.py b/modules/orange/browser.py index 34c058be1cd53694886c18fb9e1327885f15bf12..00b975b5cbffe2b1d2177cab34e6397413491515 100644 --- a/modules/orange/browser.py +++ b/modules/orange/browser.py @@ -38,28 +38,35 @@ class OrangeBillBrowser(LoginBrowser): BASEURL = 'https://espaceclientv3.orange.fr' - home_page = URL('https://businesslounge.orange.fr/$', HomePage) - loginpage = URL('https://login.orange.fr/\?service=sosh&return_url=https://www.sosh.fr/', - 'https://login.orange.fr/front/login', LoginPage) + home_page = URL(r'https://businesslounge.orange.fr/$', HomePage) + loginpage = URL( + r'https://login.orange.fr/\?service=sosh&return_url=https://www.sosh.fr/', + r'https://login.orange.fr/front/login', + LoginPage, + ) password_page = URL(r'https://login.orange.fr/front/password', PasswordPage) - contracts = URL('https://espaceclientpro.orange.fr/api/contracts\?page=1&nbcontractsbypage=15', ContractsPage) + contracts = URL(r'https://espaceclientpro.orange.fr/api/contracts\?page=1&nbcontractsbypage=15', ContractsPage) subscriptions = URL(r'https://espaceclientv3.orange.fr/js/necfe.php\?zonetype=bandeau&idPage=gt-home-page', SubscriptionsPage) - manage_cgi = URL('https://eui.orange.fr/manage_eui/bin/manage.cgi', ManageCGI) + manage_cgi = URL(r'https://eui.orange.fr/manage_eui/bin/manage.cgi', ManageCGI) # is billspage deprecated ? - billspage = URL('https://m.espaceclientv3.orange.fr/\?page=factures-archives', - 'https://.*.espaceclientv3.orange.fr/\?page=factures-archives', - 'https://espaceclientv3.orange.fr/\?page=factures-archives', - 'https://espaceclientv3.orange.fr/\?page=facture-telecharger', - 'https://espaceclientv3.orange.fr/maf.php', - 'https://espaceclientv3.orange.fr/\?idContrat=(?P.*)&page=factures-historique', - 'https://espaceclientv3.orange.fr/\?page=factures-historique&idContrat=(?P.*)', - BillsPage) - - bills_api_pro = URL('https://espaceclientpro.orange.fr/api/contract/(?P\d+)/bills\?count=(?P)', - BillsApiProPage) + billspage = URL( + r'https://m.espaceclientv3.orange.fr/\?page=factures-archives', + r'https://.*.espaceclientv3.orange.fr/\?page=factures-archives', + r'https://espaceclientv3.orange.fr/\?page=factures-archives', + r'https://espaceclientv3.orange.fr/\?page=facture-telecharger', + r'https://espaceclientv3.orange.fr/maf.php', + r'https://espaceclientv3.orange.fr/\?idContrat=(?P.*)&page=factures-historique', + r'https://espaceclientv3.orange.fr/\?page=factures-historique&idContrat=(?P.*)', + BillsPage, + ) + + bills_api_pro = URL( + r'https://espaceclientpro.orange.fr/api/contract/(?P\d+)/bills\?count=(?P)', + BillsApiProPage, + ) bills_api_par = URL(r'https://sso-f.orange.fr/omoi_erb/facture/v2.0/billsAndPaymentInfos/users/current/contracts/(?P\d+)', BillsApiParPage) doc_api_par = URL(r'https://sso-f.orange.fr/omoi_erb/facture/v1.0/pdf') @@ -67,6 +74,10 @@ class OrangeBillBrowser(LoginBrowser): doc_api_pro = URL('https://espaceclientpro.orange.fr/api/contract/(?P\d+)/bill/(?P.*)/(?P.*)/\?(?P)') profile = URL('/\?page=profil-infosPerso', ProfilePage) + def __init__(self, *args, **kwargs): + super(OrangeBillBrowser, self).__init__(*args, **kwargs) + self.is_new_website = False + def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) @@ -86,6 +97,11 @@ def do_login(self): if error_message: raise BrowserPasswordExpired(error_message) + self.location(self.BASEURL) + print('location done / is_here : %s' % self.new_website.is_here()) + if self.new_website.is_here(): + self.is_new_website = True + def get_nb_remaining_free_sms(self): raise NotImplementedError() diff --git a/modules/orange/module.py b/modules/orange/module.py index cae6b513369da51998f014060433ce358c8a935d..4f1e0d1d8178f6c822f37cf85174c588f5ea6cbb 100644 --- a/modules/orange/module.py +++ b/modules/orange/module.py @@ -17,13 +17,14 @@ # You should have received a copy of the GNU Lesser General Public License # along with this weboob module. If not, see . +from __future__ import unicode_literals from weboob.capabilities.bill import DocumentTypes, CapDocument, Subscription, Document, SubscriptionNotFound, DocumentNotFound from weboob.capabilities.base import find_object, NotAvailable from weboob.capabilities.account import CapAccount from weboob.capabilities.profile import CapProfile from weboob.tools.backend import Module, BackendConfig -from weboob.tools.value import ValueBackendPassword, Value +from weboob.tools.value import ValueBackendPassword from .browser import OrangeBillBrowser @@ -38,8 +39,10 @@ class OrangeModule(Module, CapAccount, CapDocument, CapProfile): VERSION = '1.6' DESCRIPTION = 'Orange French mobile phone provider' LICENSE = 'LGPLv3+' - CONFIG = BackendConfig(Value('login', label='Login'), - ValueBackendPassword('password', label='Password')) + CONFIG = BackendConfig( + ValueBackendPassword('login', label='Login'), + ValueBackendPassword('password', label='Password'), + ) BROWSER = OrangeBillBrowser def __init__(self, *args, **kwargs): @@ -49,7 +52,10 @@ def __init__(self, *args, **kwargs): accepted_document_types = (DocumentTypes.BILL,) def create_default_browser(self): - return self.create_browser(self.config['login'].get(), self.config['password'].get()) + return self.create_browser( + self.config['login'].get(), + self.config['password'].get(), + ) def iter_subscription(self): return self.browser.get_subscription_list() diff --git a/modules/orange/pages/bills.py b/modules/orange/pages/bills.py index 89a4eeb90c86b57fe77210d4f3e543b97079f85a..ec27924f1a92cb967d5b01d1af1fbc7499b53d88 100644 --- a/modules/orange/pages/bills.py +++ b/modules/orange/pages/bills.py @@ -52,7 +52,7 @@ class get_bills(DictElement): class item(ItemElement): klass = Bill - obj_date = Date(Dict('dueDate'), parse_func=parse_french_date, default=NotAvailable) + obj_date = Date(Dict('dueDate'), parse_func=parse_french_date, default=NotAvailable) obj_price = CleanDecimal(Dict('amountIncludingTax')) obj_format = 'pdf' @@ -78,7 +78,7 @@ class get_bills(DictElement): class item(ItemElement): klass = Bill - obj_date = Date(Dict('date'), default=NotAvailable) + obj_date = Date(Dict('date'), default=NotAvailable) obj_price = Eval(lambda x: x / 100, CleanDecimal(Dict('amount'))) obj_format = 'pdf' @@ -109,7 +109,7 @@ class item(ItemElement): klass = Bill obj_type = DocumentTypes.BILL - obj_format = u"pdf" + obj_format = "pdf" # TableCell('date') can have other info like: 'duplicata' obj_date = Date(CleanText('./td[@headers="ec-dateCol"]/text()[not(preceding-sibling::br)]'), parse_func=parse_french_date, dayfirst=True) @@ -134,12 +134,12 @@ def obj_currency(self): # Only when a list of documents is present obj__url_base = Regexp(CleanText('.//ul[@class="liste"]/script', default=None), '.*?contentList[\d]+ \+= \'
  • (.*?)