diff --git a/.pydevproject b/.pydevproject index b6d22db5e1..aaa4cc3986 100644 --- a/.pydevproject +++ b/.pydevproject @@ -2,7 +2,7 @@ -python 2.6 +python 2.5 /calibre/src diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 625a4035d0..a40878480f 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -132,7 +132,7 @@ class HTMLMetadataReader(MetadataReaderPlugin): class MOBIMetadataReader(MetadataReaderPlugin): name = 'Read MOBI metadata' - file_types = set(['mobi', 'prc']) + file_types = set(['mobi', 'prc', '.azw']) description = _('Read metadata from %s files')%'MOBI' def get_metadata(self, stream, ftype): diff --git a/src/calibre/ebooks/epub/from_any.py b/src/calibre/ebooks/epub/from_any.py index e81821ed53..9a8e251108 100644 --- a/src/calibre/ebooks/epub/from_any.py +++ b/src/calibre/ebooks/epub/from_any.py @@ -124,6 +124,7 @@ MAP = { 'lit' : lit2opf, 'mobi' : mobi2opf, 'prc' : mobi2opf, + 'azw' : mobi2opf, 'fb2' : fb22opf, 'rtf' : rtf2opf, 'txt' : txt2opf, @@ -131,7 +132,8 @@ MAP = { 'epub' : epub2opf, 'odt' : odt2epub, } -SOURCE_FORMATS = ['lit', 'mobi', 'prc', 'fb2', 'odt', 'rtf', 'txt', 'pdf', 'rar', 'zip', 'oebzip', 'htm', 'html', 'epub'] +SOURCE_FORMATS = ['lit', 'mobi', 'prc', 'azw', 'fb2', 'odt', 'rtf', + 'txt', 'pdf', 'rar', 'zip', 'oebzip', 'htm', 'html', 'epub'] def unarchive(path, tdir): extract(path, tdir) diff --git a/src/calibre/ebooks/lrf/__init__.py b/src/calibre/ebooks/lrf/__init__.py index 73a261b931..2f9d724ce2 100644 --- a/src/calibre/ebooks/lrf/__init__.py +++ b/src/calibre/ebooks/lrf/__init__.py @@ -29,6 +29,7 @@ preferred_source_formats = [ 'XHTM', 'XHTML', 'PRC', + 'AZW', 'RTF', 'PDF', 'TXT', diff --git a/src/calibre/ebooks/lrf/any/convert_from.py b/src/calibre/ebooks/lrf/any/convert_from.py index 002064bced..fdfe1c54d5 100644 --- a/src/calibre/ebooks/lrf/any/convert_from.py +++ b/src/calibre/ebooks/lrf/any/convert_from.py @@ -154,7 +154,7 @@ def process_file(path, options, logger=None): convertor = txt2lrf elif 'epub' == ext: convertor = epub2lrf - elif ext in ['mobi', 'prc']: + elif ext in ['mobi', 'prc', 'azw']: convertor = mobi2lrf elif ext == 'fb2': convertor = fb22lrf diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 78415f3a19..519314782a 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -269,7 +269,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): def cover_dropped(self): self.cover_changed = True - def initialize_series_and_publisher(self): + def initialize_series(self): all_series = self.db.all_series() all_series.sort(cmp=lambda x, y : cmp(x[1], y[1])) series_id = self.db.series_id(self.row) @@ -293,6 +293,8 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): l.invalidate() l.activate() + def initialize_series_and_publisher(self): + self.initialize_series() all_publishers = self.db.all_publishers() all_publishers.sort(cmp=lambda x, y : cmp(x[1], y[1])) publisher_id = self.db.publisher_id(self.row) diff --git a/src/calibre/gui2/images/news/linuxdevices.png b/src/calibre/gui2/images/news/linuxdevices.png new file mode 100644 index 0000000000..a6782b9e41 Binary files /dev/null and b/src/calibre/gui2/images/news/linuxdevices.png differ diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index a6fcceade0..7d964c3a14 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -414,8 +414,11 @@ class BooksModel(QAbstractTableModel): - def get_preferred_formats(self, rows, formats, paths=False, set_metadata=False): + def get_preferred_formats(self, rows, formats, paths=False, + set_metadata=False, specific_format=None): ans = [] + if specific_format is not None: + formats = [specific_format.lower()] for row in (row.row() for row in rows): format = None fmts = self.db.formats(row) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 611b520ef2..84e4be699c 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -156,6 +156,9 @@ class Main(MainWindow, Ui_MainWindow): sm.addAction(QIcon(':/images/sd.svg'), _('Send to storage card')) sm.addAction(QIcon(':/images/reader.svg'), _('Send to main memory')+' '+_('and delete from library')) sm.addAction(QIcon(':/images/sd.svg'), _('Send to storage card')+' '+_('and delete from library')) + sm.addAction(self.action_send_specific_format_to_device) + self.connect(self.action_send_specific_format_to_device, + SIGNAL('triggered()'), self.send_specific_format_to_device) sm.addSeparator() sm.addAction(_('Send to storage card by default')) sm.actions()[-1].setCheckable(True) @@ -893,8 +896,16 @@ class Main(MainWindow, Ui_MainWindow): self.upload_books(files, names, metadata, on_card=on_card, memory=[[f.name for f in files], remove]) self.status_bar.showMessage(_('Sending news to device.'), 5000) + def send_specific_format_to_device(self): + d = ChooseFormatDialog(self, _('Choose format to send to device'), + self.device_manager.device_class.FORMATS) + d.exec_() + fmt = d.format().lower() + on_card = config['send_to_storage_card_by_default'] + self.sync_to_device(on_card, False, specific_format=fmt) + - def sync_to_device(self, on_card, delete_from_library): + def sync_to_device(self, on_card, delete_from_library, specific_format=None): rows = self.library_view.selectionModel().selectedRows() if not self.device_manager or not rows or len(rows) == 0: return @@ -907,7 +918,8 @@ class Main(MainWindow, Ui_MainWindow): metadata = iter(metadata) _files = self.library_view.model().get_preferred_formats(rows, self.device_manager.device_class.FORMATS, - paths=True, set_metadata=True) + paths=True, set_metadata=True, + specific_format=specific_format) files = [getattr(f, 'name', None) for f in _files] bad, good, gf, names, remove_ids = [], [], [], [], [] for f in files: diff --git a/src/calibre/gui2/main.ui b/src/calibre/gui2/main.ui index 323b1bf170..ad8c450d1a 100644 --- a/src/calibre/gui2/main.ui +++ b/src/calibre/gui2/main.ui @@ -656,6 +656,15 @@ Books with the same tags + + + + :/images/book.svg:/images/book.svg + + + Send specific format to device + + diff --git a/src/calibre/linux.py b/src/calibre/linux.py index 81b8424199..1960a3d547 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -502,6 +502,7 @@ VIEWER = '''\ Version=%s Type=Application Name=LRF Viewer +GenericName=Viewer for LRF files Comment=Viewer for LRF files (SONY ebook format files) TryExec=lrfviewer Exec=lrfviewer %%F @@ -514,8 +515,9 @@ EVIEWER = '''\ [Desktop Entry] Version=%s Type=Application -Name=Ebook Viewer -Comment=Viewer for Ebooks +Name=E-book Viewer +GenericName=Viewer for E-books +Comment=Viewer for E-books TryExec=ebook-viewer Exec=ebook-viewer %%F Icon=calibre-viewer @@ -528,7 +530,8 @@ GUI = '''\ [Desktop Entry] Version=%s Type=Application -Name=calibre - Ebook library management +Name=calibre +GenericName=E-book library management Comment=E-book library management TryExec=calibre Exec=calibre diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index edcf315d62..4773d551c3 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -190,7 +190,7 @@ class BasicNewsRecipe(object, LoggingInterface): #: For the format for specifying a tag see :attr:`BasicNewsRecipe.remove_tags`. #: For example:: #: - #: remove_tags_before = [dict(id='content')] + #: remove_tags_before = dict(id='content') #: #: will remove all #: tags before the first element with `id="content"`. diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 761b5ab4de..3723483fb7 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -28,7 +28,8 @@ recipe_modules = ['recipe_' + r for r in ( 'la_tercera', 'el_mercurio_chile', 'la_cuarta', 'lanacion_chile', 'la_segunda', 'jb_online', 'estadao', 'o_globo', 'vijesti', 'elmundo', 'the_oz', 'honoluluadvertiser', 'starbulletin', 'exiled', 'indy_star', 'dna', - 'pobjeda', 'chicago_breaking_news', 'glasgow_herald', + 'pobjeda', 'chicago_breaking_news', 'glasgow_herald', 'linuxdevices', + 'hindu' )] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/recipe_hindu.py b/src/calibre/web/feeds/recipes/recipe_hindu.py new file mode 100644 index 0000000000..073eb7afd1 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_hindu.py @@ -0,0 +1,47 @@ +from __future__ import with_statement +__license__ = 'GPL 3' +__copyright__ = '2009, Kovid Goyal ' + +import re +from calibre.web.feeds.news import BasicNewsRecipe + +class TheHindu(BasicNewsRecipe): + title = u'The Hindu' + language = _('English') + oldest_article = 7 + __author__ = _('Kovid Goyal') + max_articles_per_feed = 100 + + remove_tags_before = {'name':'font', 'class':'storyhead'} + preprocess_regexps = [ + (re.compile(r'.*', re.DOTALL), + lambda match: ''), + ] + + feeds = [ + (u'Main - Font Page', u'http://www.hindu.com/rss/01hdline.xml'), + (u'Main - National', u'http://www.hindu.com/rss/02hdline.xml'), + (u'Main - International', u'http://www.hindu.com/rss/03hdline.xml'), + (u'Main - Opinion', u'http://www.hindu.com/rss/05hdline.xml'), + (u'Main - Business', u'http://www.hindu.com/rss/06hdline.xml'), + (u'Main - Sport', u'http://www.hindu.com/rss/07hdline.xml'), + (u'Main - Weather / Religion / Crossword / Cartoon', + u'http://www.hindu.com/rss/10hdline.xml'), + (u'Main - Engagements', u'http://www.hindu.com/rss/26hdline.xml'), + (u'Supplement - Literary Review', + u'http://www.hindu.com/rss/lrhdline.xml'), + (u'Supplement - Sunday Magazine', + u'http://www.hindu.com/rss/maghdline.xml'), + (u'Supplement - Open Page', u'http://www.hindu.com/rss/ophdline.xml'), + (u'Supplement - Business Review', + u'http://www.hindu.com/rss/bizhdline.xml'), + (u'Supplement - Book Review', + u'http://www.hindu.com/rss/brhdline.xml'), + (u'Supplement - Science & Technology', + u'http://www.hindu.com/rss/setahdline.xml') + ] + + def postprocess_html(self, soup, first_fetch): + for t in soup.findAll(['table', 'tr', 'td']): + t.name = 'div' + return soup \ No newline at end of file diff --git a/src/calibre/web/feeds/recipes/recipe_linuxdevices.py b/src/calibre/web/feeds/recipes/recipe_linuxdevices.py new file mode 100644 index 0000000000..04db6b02d5 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_linuxdevices.py @@ -0,0 +1,80 @@ +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + +''' +Fetch Linuxdevices. +''' + +from calibre.web.feeds.news import BasicNewsRecipe + + +class Sueddeutsche(BasicNewsRecipe): + + title = u'Linuxdevices' + description = 'News about Linux driven Hardware' + __author__ = 'Oliver Niesner' + use_embedded_content = False + timefmt = ' [%a, %d %b %Y]' + language = _('English') + max_articles_per_feed = 50 + no_stylesheets = True + encoding = 'latin1' + + remove_tags_after = [dict(id='nointelliTXT')] + filter_regexps = [r'ad\.doubleclick\.net'] + + + remove_tags = [dict(name='div', attrs={'class':'bannerSuperBanner'}), + dict(name='div', attrs={'class':'bannerSky'}), + dict(name='div', attrs={'class':'footerLinks'}), + dict(name='div', attrs={'class':'seitenanfang'}), + dict(name='td', attrs={'class':'mar5'}), + dict(name='td', attrs={'class':'mar5'}), + dict(name='table', attrs={'class':'pageAktiv'}), + dict(name='table', attrs={'class':'xartable'}), + dict(name='table', attrs={'class':'wpnavi'}), + dict(name='table', attrs={'class':'bgcontent absatz'}), + dict(name='table', attrs={'class':'footer'}), + dict(name='table', attrs={'class':'artikelBox'}), + dict(name='table', attrs={'class':'kommentare'}), + dict(name='table', attrs={'class':'pageBoxBot'}), + #dict(name='table', attrs={'with':'100%'}), + dict(name='td', attrs={'nowrap':'nowrap'}), + dict(name='td', attrs={'valign':'middle'}), + dict(name='td', attrs={'align':'left'}), + dict(name='td', attrs={'align':'center'}), + dict(name='td', attrs={'height':'5'}), + dict(name='div', attrs={'class':'artikelBox navigatorBox'}), + dict(name='div', attrs={'class':'similar-article-box'}), + dict(name='div', attrs={'class':'videoBigHack'}), + dict(name='td', attrs={'class':'artikelDruckenRight'}), + dict(name='td', attrs={'class':'width="200"'}), + dict(name='a', attrs={'href':'/news'}), + dict(name='a', attrs={'href':'/'}), + dict(name='a', attrs={'href':'/articles'}), + dict(name='a', attrs={'href':'/cgi-bin/survey/survey.cgi'}), + dict(name='a', attrs={'href':'/cgi-bin/board/UltraBoard.pl'}), + dict(name='iframe'), + dict(name='form'), + #dict(name='tr', attrs={'td':'Click here to learn'}), + dict(name='span', attrs={'class':'hidePrint'}), + dict(id='headerLBox'), + dict(id='nointelliTXT'), + dict(id='rechteSpalte'), + dict(id='newsticker-list-small'), + dict(id='ntop5'), + dict(id='ntop5send'), + dict(id='ntop5commented'), + dict(id='nnav-bgheader'), + dict(id='nnav-headerteaser'), + dict(id='nnav-head'), + dict(id='nnav-top'), + dict(id='nnav-logodiv'), + dict(id='nnav-logo'), + dict(id='nnav-oly'), + dict(id='readcomment')] + + + + feeds = [ (u'Linuxdevices', u'http://www.linuxdevices.com/backend/headlines.rss') ] +