X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/d3dfd4b8285e3b5939f7865907cc0537e948b6b6..fbc10cff4c1ea91b0a42d2435755d538cce4a241:/src/depot/publishers/woblink.py diff --git a/src/depot/publishers/woblink.py b/src/depot/publishers/woblink.py index 96971c28..8472a180 100644 --- a/src/depot/publishers/woblink.py +++ b/src/depot/publishers/woblink.py @@ -249,17 +249,17 @@ class Woblink(BasePublisher): def get_abstract(self, wldoc, errors=None, description_add=None): description = self.get_description(wldoc, description_add) parts = description.split('\n', 1) - if len(parts) == 1 or len(parts[0]) > 200: + if len(parts) == 1 or len(parts[0]) > 240: # No newline found here. # Try to find last sentence end.. - parts = re.split(r' \.', description[200::-1], 1) + parts = re.split(r' \.', description[240::-1], 1) if len(parts) == 2: p1 = parts[1][::-1] + '.' p2 = description[len(p1) + 1:] else: # No sentence end found. # Just find a space. - p1 = description[:200].rsplit(' ', 1)[0] + p1 = description[:240].rsplit(' ', 1)[0] p2 = description[len(p1) + 1:] p1 += '…' p2 = '…' + p2 @@ -267,11 +267,11 @@ class Woblink(BasePublisher): m = re.search(r'<[^>]+$', parts[0]) if m is not None: - parts[0] = parts[:-len(m.group(0))] + parts[0] = parts[0][:-len(m.group(0))] parts[1] = m.group(0) + parts[1] opened = [] - for tag in re.findall(r'<[^>]+[^/>]>', parts[0]): + for tag in re.findall(r'<[^>]*[^/>]>', parts[0]): if tag[1] == '/': opened.pop() else: @@ -288,7 +288,12 @@ class Woblink(BasePublisher): return lang_code_3to2(meta.language) def get_price(self, shop, wldoc, errors=None): - stats = wldoc.get_statistics()['total'] + try: + stats = wldoc.get_statistics()['total'] + except: + if errors: + errors.append(NoPrice(shop)) + return 0 words = stats['words_with_fn'] pages = stats['chars_with_fn'] / 1800 price = shop.get_price(words, pages)