diff --git a/recipes/icons/losandes.png b/recipes/icons/losandes.png new file mode 100644 index 0000000000..635217e727 Binary files /dev/null and b/recipes/icons/losandes.png differ diff --git a/recipes/losandes.recipe b/recipes/losandes.recipe new file mode 100644 index 0000000000..cd095f1b4a --- /dev/null +++ b/recipes/losandes.recipe @@ -0,0 +1,78 @@ +__license__ = 'GPL v3' +__copyright__ = '2011, Darko Miletic ' +''' +www.losandes.com.ar +''' + +from calibre import strftime +from calibre.web.feeds.news import BasicNewsRecipe + +class LosAndes(BasicNewsRecipe): + title = 'Los Andes' + __author__ = 'Darko Miletic' + description = 'Noticias de Mendoza, Argentina y el resto del mundo' + publisher = 'Los Andes' + category = 'news, politics, Argentina' + oldest_article = 2 + max_articles_per_feed = 200 + no_stylesheets = True + encoding = 'cp1252' + use_embedded_content = False + language = 'es_AR' + remove_empty_feeds = True + publication_type = 'newspaper' + masthead_url = 'http://www.losandes.com.ar/graficos/losandes.png' + extra_css = """ + body{font-family: Arial,Helvetica,sans-serif } + h1,h2{font-family: "Times New Roman",Times,serif} + .fechaNota{font-weight: bold; color: gray} + """ + + conversion_options = { + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language + } + + remove_tags = [ + dict(name=['meta','link']) + ,dict(attrs={'class':['cabecera', 'url']}) + ] + remove_tags_before=dict(attrs={'class':'cabecera'}) + remove_tags_after=dict(attrs={'class':'url'}) + + + feeds = [ + (u'Ultimas Noticias' , u'http://www.losandes.com.ar/servicios/rss.asp?r=78' ) + ,(u'Politica' , u'http://www.losandes.com.ar/servicios/rss.asp?r=68' ) + ,(u'Economia nacional' , u'http://www.losandes.com.ar/servicios/rss.asp?r=65' ) + ,(u'Economia internacional' , u'http://www.losandes.com.ar/servicios/rss.asp?r=505') + ,(u'Internacionales' , u'http://www.losandes.com.ar/servicios/rss.asp?r=66' ) + ,(u'Turismo' , u'http://www.losandes.com.ar/servicios/rss.asp?r=502') + ,(u'Fincas' , u'http://www.losandes.com.ar/servicios/rss.asp?r=504') + ,(u'Isha nos habla' , u'http://www.losandes.com.ar/servicios/rss.asp?r=562') + ,(u'Estilo' , u'http://www.losandes.com.ar/servicios/rss.asp?r=81' ) + ,(u'Cultura' , u'http://www.losandes.com.ar/servicios/rss.asp?r=503') + ,(u'Policiales' , u'http://www.losandes.com.ar/servicios/rss.asp?r=70' ) + ,(u'Deportes' , u'http://www.losandes.com.ar/servicios/rss.asp?r=69' ) + ,(u'Sociedad' , u'http://www.losandes.com.ar/servicios/rss.asp?r=67' ) + ,(u'Opinion' , u'http://www.losandes.com.ar/servicios/rss.asp?r=80' ) + ,(u'Editorial' , u'http://www.losandes.com.ar/servicios/rss.asp?r=76' ) + ,(u'Mirador' , u'http://www.losandes.com.ar/servicios/rss.asp?r=79' ) + ] + + def print_version(self, url): + artid = url.rpartition('.')[0].rpartition('-')[2] + return "http://www.losandes.com.ar/includes/modulos/imprimir.asp?tipo=noticia&id=" + artid + + def get_cover_url(self): + month = strftime("%m").lstrip('0') + day = strftime("%d").lstrip('0') + year = strftime("%Y") + return "http://www.losandes.com.ar/fotografias/fotosnoticias/" + year + "/" + month + "/" + day + "/th_tapa.jpg" + + def preprocess_html(self, soup): + for item in soup.findAll(style=True): + del item['style'] + return soup diff --git a/src/calibre/ebooks/mobi/debug.py b/src/calibre/ebooks/mobi/debug.py index 2dbe363e7c..971f037479 100644 --- a/src/calibre/ebooks/mobi/debug.py +++ b/src/calibre/ebooks/mobi/debug.py @@ -11,7 +11,7 @@ import struct, datetime, sys, os, shutil from collections import OrderedDict from calibre.utils.date import utc_tz from calibre.ebooks.mobi.langcodes import main_language, sub_language -from calibre.ebooks.mobi.writer2.utils import (decode_hex_number, decint, +from calibre.ebooks.mobi.utils import (decode_hex_number, decint, get_trailing_data) from calibre.utils.magick.draw import identify_data @@ -618,6 +618,13 @@ class IndexEntry(object): # {{{ vals.append(val) self.tags.append(Tag(tag, vals, self.entry_type, cncx)) + @property + def label(self): + for tag in self.tags: + if tag.attr == 'label_offset': + return tag.cncx_value + return '' + def __str__(self): ans = ['Index Entry(index=%s, entry_type=%s, length=%d)'%( self.index, self.entry_type, len(self.tags))] @@ -828,7 +835,7 @@ class MOBIFile(object): # {{{ else: decompress = lambda x: x - self.index_header = None + self.index_header = self.index_record = None self.indexing_record_nums = set() pir = self.mobi_header.primary_index_record if pir != 0xffffffff: diff --git a/src/calibre/ebooks/mobi/writer2/utils.py b/src/calibre/ebooks/mobi/utils.py similarity index 96% rename from src/calibre/ebooks/mobi/writer2/utils.py rename to src/calibre/ebooks/mobi/utils.py index 708b9152d4..cd0ee453c3 100644 --- a/src/calibre/ebooks/mobi/writer2/utils.py +++ b/src/calibre/ebooks/mobi/utils.py @@ -161,16 +161,17 @@ def get_trailing_data(record, extra_data_flags): ''' data = OrderedDict() for i in xrange(16, -1, -1): - flag = 2**i + flag = 1 << i # 2**i if flag & extra_data_flags: if i == 0: # Only the first two bits are used for the size since there can # never be more than 3 trailing multibyte chars - sz = ord(record[-1]) & 0b11 + sz = (ord(record[-1]) & 0b11) + 1 consumed = 1 else: sz, consumed = decint(record, forward=False) - data[i] = record[-(sz+consumed):-consumed] - record = record[:-(sz+consumed)] + if sz > consumed: + data[i] = record[-sz:-consumed] + record = record[:-sz] return data, record diff --git a/src/calibre/ebooks/mobi/writer2/main.py b/src/calibre/ebooks/mobi/writer2/main.py index 76976ce81e..2e9d31458a 100644 --- a/src/calibre/ebooks/mobi/writer2/main.py +++ b/src/calibre/ebooks/mobi/writer2/main.py @@ -18,7 +18,7 @@ from calibre.ebooks.compression.palmdoc import compress_doc from calibre.ebooks.mobi.langcodes import iana2mobi from calibre.utils.filenames import ascii_filename from calibre.ebooks.mobi.writer2 import PALMDOC, UNCOMPRESSED -from calibre.ebooks.mobi.writer2.utils import (rescale_image, encint) +from calibre.ebooks.mobi.utils import (rescale_image, encint) EXTH_CODES = { 'creator': 100, diff --git a/src/calibre/gui2/convert/metadata.ui b/src/calibre/gui2/convert/metadata.ui index 95ccac6890..478f65e870 100644 --- a/src/calibre/gui2/convert/metadata.ui +++ b/src/calibre/gui2/convert/metadata.ui @@ -240,7 +240,7 @@ Book - 9999.989999999999782 + 9999999999.99 1.000000000000000