From e5c1b1879b50bec815450aa20ece5f7a0edcae57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Rubinstein?= Date: Tue, 30 Aug 2011 05:10:05 +0200 Subject: [PATCH] factorize mangatoshokan and simplyreadit (wip) --- weboob/backends/genericcomicreader/__init__.py | 4 ++-- .../mangatoshokan.py} | 16 ++++++++++++++-- .../simplyreadit.py} | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) rename weboob/backends/{mangatoshokan/__init__.py => genericcomicreader/mangatoshokan.py} (52%) rename weboob/backends/{simplyreadit/__init__.py => genericcomicreader/simplyreadit.py} (53%) diff --git a/weboob/backends/genericcomicreader/__init__.py b/weboob/backends/genericcomicreader/__init__.py index 58e3418a..1b7b235a 100644 --- a/weboob/backends/genericcomicreader/__init__.py +++ b/weboob/backends/genericcomicreader/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright(C) 2010-2011 Roger Philibert +# Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # @@ -19,4 +19,4 @@ from .mangafox import MangafoxBackend -__all__ = ['MangafoxBackend'] +__all__ = ['MangafoxBackend', 'MangatoshokanBackend', 'SimplyreaditBackend'] diff --git a/weboob/backends/mangatoshokan/__init__.py b/weboob/backends/genericcomicreader/mangatoshokan.py similarity index 52% rename from weboob/backends/mangatoshokan/__init__.py rename to weboob/backends/genericcomicreader/mangatoshokan.py index f83fb296..7a1d6a19 100644 --- a/weboob/backends/mangatoshokan/__init__.py +++ b/weboob/backends/genericcomicreader/mangatoshokan.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright(C) 2010-2011 Roger Philibert +# Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # @@ -17,6 +17,18 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from .backend import MangatoshokanBackend +from .backend import GenericComicReaderBackend, DisplayPage __all__ = ['MangatoshokanBackend'] + +class MangatoshokanBackend(GenericComicReaderBackend): + NAME = 'mangatoshokan' + DESCRIPTION = 'Mangatoshokan manga reading site' + DOMAIN = "www.mangatoshokan.com" + IMG_SRC_XPATH = "//img[@id='readerPage']/@src" + PAGE_LIST_XPATH = "(//select[@class='headerSelect'])[1]/option/@value" + PAGE_TO_LOCATION = 'http://%s%%s' % DOMAIN + ID_TO_URL = 'http://www.mangatoshokan.com/read/%s' + ID_REGEXP = r'[^/]+(?:/[^/]+)*' + URL_REGEXP = r'.+mangatoshokan.com/read/(%s).+' % ID_REGEXP + PAGES = { r'http://.+\.mangatoshokan.com/read/.+': DisplayPage } diff --git a/weboob/backends/simplyreadit/__init__.py b/weboob/backends/genericcomicreader/simplyreadit.py similarity index 53% rename from weboob/backends/simplyreadit/__init__.py rename to weboob/backends/genericcomicreader/simplyreadit.py index c6f6083f..a811aafc 100644 --- a/weboob/backends/simplyreadit/__init__.py +++ b/weboob/backends/genericcomicreader/simplyreadit.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright(C) 2010-2011 Roger Philibert +# Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # @@ -17,6 +17,17 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from .backend import SimplyreaditBackend +from .backend import GenericComicReaderBackend, DisplayPage __all__ = ['SimplyreaditBackend'] + +class SimplyreaditBackend(GenericComicReaderBackend): + NAME = 'simplyreadit' + DESCRIPTION = 'Simplyreadit manga reading site' + IMG_SRC_XPATH = "//img[@class='open']/@src" + PAGE_LIST_XPATH = "(//div[contains(@class,'dropdown_right')]/ul[@class='dropdown'])[1]/li/a/@href" + PAGE_TO_LOCATION = "%s" + ID_TO_URL = 'http://www.simplyread.it/reader/read/%s' + ID_REGEXP = r'[^/]+(?:/[^/]+)*' + URL_REGEXP = r'.+symplyread.it/reader/read/(%s)' % ID_REGEXP + PAGES = { r'http://.+\.simplyread.it/reader/read/.+': DisplayPage }