<commit_before># -*- coding: utf-8 -*-

# Copyright(C) 2010-2011 <NAME>
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.



import re

from weboob.capabilities.gallery import ICapGallery, BaseGallery, BaseImage
from weboob.tools.json import json
from weboob.tools.backend import BaseBackend
from weboob.tools.browser import BaseBrowser, BasePage

__all__ = ['IzneoBackend']


class ReaderV2(BasePage):
    def get_ean(self):
        return self.document.xpath("//div[@id='viewer']/attribute::rel")[0]

    def iter_gallery_images(self, gallery):
        ean = self.get_ean()
        pages = json.load(self.browser.openurl(
            'http://www.izneo.com/playerv2/ajax.php?ean=%s&action=get_list_jpg'
            % ean))

        for page in pages:
            width = 1200  # maximum width
            yield BaseImage(page['page'],
                    gallery=gallery,
                    url=("http://www.izneo.com/playerv2/%s/%s/%s/%d/%s" %
                        (page['expires'], page['token'], ean, width, page['page'])))


class IzneoBrowser(BaseBrowser):
    PAGES = {r'http://.+\.izneo.\w+/readv2-.+': ReaderV2}

    def iter_gallery_images(self, gallery):
        self.location(gallery.url)
        assert self.is_on_page(ReaderV2)
        return self.page.iter_gallery_images(gallery)

    def fill_image(self, image, fields):
        if 'data' in fields:
            image.data = self.readurl(self.request_class(
                image.url, None, {'Referer': image.gallery.url}))


class IzneoBackend(BaseBackend, ICapGallery):
    NAME = 'izneo'<commit_msg>Fix bug in page list<commit_after># -*- coding: utf-8 -*-

# Copyright(C) 2010-2011 <NAME>
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.



import re

from weboob.capabilities.gallery import ICapGallery, BaseGallery, BaseImage
from weboob.tools.json import json
from weboob.tools.backend import BaseBackend
from weboob.tools.browser import BaseBrowser, BasePage

__all__ = ['IzneoBackend']


class ReaderV2(BasePage):
    def get_ean(self):
        return self.document.xpath("//div[@id='viewer']/attribute::rel")[0]

    def iter_gallery_images(self, gallery):
        ean = self.get_ean()
        pages = json.load(self.browser.openurl(
            'http://www.izneo.com/playerv2/ajax.php?ean=%s&action=get_list_jpg'
            % ean))

        for page in pages['list']:
            width = 1200  # maximum width
            yield BaseImage(page['page'],
                    gallery=gallery,
                    url=("http://www.izneo.com/playerv2/%s/%s/%s/%d/%s" %
                        (page['expires'], page['token'], ean, width, page['page'])))


class IzneoBrowser(BaseBrowser):
    PAGES = {r'http://.+\.izneo.\w+/readv2-.+': ReaderV2}

    def iter_gallery_images(self, gallery):
        self.location(gallery.url)
        assert self.is_on_page(ReaderV2)
        return self.page.iter_gallery_images(gallery)

    def fill_image(self, image, fields):
        if 'data' in fields:
            image.data = self.readurl(self.request_class(
                image.url, None, {'Referer': image.gallery.url}))


class IzneoBackend(BaseBackend, ICapGallery):
    NAME = 'izneo'
{'fraction_non_alphanumeric': 0.11588275391956374, 'fraction_numerical': 0.00954328561690525, 'mean_word_length': 3.0274473924977126, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '205355', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1321, 'n_words': 399}