From 08bd4a92fc813f191f6f88518fed4138d1e70851 Mon Sep 17 00:00:00 2001 From: Timothy Legge Date: Thu, 7 Jul 2011 13:03:57 -0230 Subject: [PATCH 1/4] Additional cleanup code reduction for managing kobo collections --- src/calibre/devices/kobo/driver.py | 54 +++++++++++++----------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 2d6e66afc3..b909dd1e90 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -596,12 +596,27 @@ class KOBO(USBMS): try: cursor.execute (query) except: - debug_print('Database Exception: Unable to reset Shortlist list') + debug_print(' Database Exception: Unable to reset Shortlist list') raise else: connection.commit() debug_print(' Commit: Reset FavouritesIndex list') + def set_favouritesindex(self, connection, ContentID): + cursor = connection.cursor() + + t = (ContentID,) + + try: + cursor.execute('update content set FavouritesIndex=1 where BookID is Null and ContentID = ?', t) + except: + debug_print(' Database Exception: Unable set book as Shortlist') + raise + else: + connection.commit() + debug_print(' Commit: Set FavouritesIndex') + + def update_device_database_collections(self, booklists, collections_attributes, oncard): # Define lists for the ReadStatus readstatuslist = { @@ -636,11 +651,7 @@ class KOBO(USBMS): # Process any collections that exist for category, books in collections.items(): - # This is used to reset the Im_Reading, Read and Closed list - # in the ReadStatus column of the Content table - if category in readstatuslist.keys(): debug_print("Category: ", category, " id = ", readstatuslist.get(category)) - for book in books: debug_print(' Title:', book.title, 'category: ', category) if category not in book.device_collections: @@ -650,35 +661,16 @@ class KOBO(USBMS): ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(book.path) ContentID = self.contentid_from_path(book.path, ContentType) - self.set_readstatus(connection, ContentID, readstatuslist.get(category)) - if category == 'Shortlist': - debug_print("Category: ", category) - cursor = connection.cursor() - for book in books: - debug_print(' Title:', book.title, 'category: ', category) - if 'Shortlist' not in book.device_collections: - book.device_collections.append('Shortlist') - # debug_print ("Shortlist found for: ", book.title) - extension = os.path.splitext(book.path)[1] - ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(book.path) - - ContentID = self.contentid_from_path(book.path, ContentType) -# datelastread = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()) - - t = (ContentID,) - - try: - cursor.execute('update content set FavouritesIndex=1 where BookID is Null and ContentID = ?', t) - except: - debug_print('Database Exception: Unable set book as Shortlist') - raise - else: - connection.commit() -# debug_print('Database: Commit set Shortlist as Shortlist') + if category in readstatuslist.keys(): + # Manage ReadStatus + self.set_readstatus(connection, ContentID, readstatuslist.get(category)) + if category == 'Shortlist': + # Manage FavouritesIndex/Shortlist + self.set_favouritesindex(connection, ContentID) else: # No collections # Since no collections exist the ReadStatus needs to be reset to 0 (Unread) - debug_print("No Collections - reseting ReadStatus to 0") + debug_print("No Collections - reseting ReadStatus") self.reset_readstatus(connection, oncard) debug_print("No Collections - reseting FavouritesIndex") self.reset_favouritesindex(connection, oncard) From 8f4457cf8bda16123126afb746a0956bdb14d36e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 7 Jul 2011 16:40:41 -0600 Subject: [PATCH 2/4] Fix #807244 (Calibre does not detect LG Optimus Speed Android phone) --- src/calibre/devices/android/driver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/android/driver.py b/src/calibre/devices/android/driver.py index d9c30d56fe..870efc5bd5 100644 --- a/src/calibre/devices/android/driver.py +++ b/src/calibre/devices/android/driver.py @@ -72,7 +72,8 @@ class ANDROID(USBMS): 0x413c : { 0xb007 : [0x0100, 0x0224, 0x0226]}, # LG - 0x1004 : { 0x61cc : [0x100], 0x61ce : [0x100], 0x618e : [0x226] }, + 0x1004 : { 0x61cc : [0x100], 0x61ce : [0x100], 0x618e : [0x226, + 0x9999] }, # Archos 0x0e79 : { From d9952aca3debd318e4357031ddedc5e8ec61763b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 7 Jul 2011 20:48:43 -0600 Subject: [PATCH 3/4] Improved Metro News NL --- recipes/metro_news_nl.recipe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/metro_news_nl.recipe b/recipes/metro_news_nl.recipe index cfdd9e5441..180dab079f 100644 --- a/recipes/metro_news_nl.recipe +++ b/recipes/metro_news_nl.recipe @@ -20,7 +20,7 @@ class AdvancedUserRecipe1306097511(BasicNewsRecipe): remove_tags_before = dict(name='div', attrs={'id':'date'}) remove_tags_after = dict(name='div', attrs={'id':'column-1-3'}) encoding = 'utf-8' - extra_css = '#date {font-size: 10px} .article-image-caption {font-size: 8px}' + extra_css = 'body{font-size:12px} #date, .article-image-caption {font-size: 0.583em} h2 {font-size: 0.917em} p.small, span, li, li span span, p, b, i, u, p.small.article-paragraph, p.small.article-paragraph p, p.small.article-paragraph span, p span, span {font-size: 0.833em} h1 {font-size: 1em}' remove_tags = [dict(name='div', attrs={'class':[ 'metroCommentFormWrap', 'commentForm', 'metroCommentInnerWrap', 'article-slideshow-counter-container', 'article-slideshow-control', 'ad', 'header-links', From b5da82b1dbe8d881d8b24f11feb56f6930f4668a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 7 Jul 2011 21:07:40 -0600 Subject: [PATCH 4/4] Blog da Cidadania and Noticias UnB by Diniz Bortolotto --- recipes/blog_da_cidadania.recipe | 20 ++++++++++++++++++++ recipes/noticias_unb.recipe | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 recipes/blog_da_cidadania.recipe create mode 100644 recipes/noticias_unb.recipe diff --git a/recipes/blog_da_cidadania.recipe b/recipes/blog_da_cidadania.recipe new file mode 100644 index 0000000000..8988d6eb28 --- /dev/null +++ b/recipes/blog_da_cidadania.recipe @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from calibre.web.feeds.news import BasicNewsRecipe + +class BlogdaCidadania(BasicNewsRecipe): + title = 'Blog da Cidadania' + __author__ = 'Diniz Bortolotto' + description = 'Posts do Blog da Cidadania' + oldest_article = 7 + max_articles_per_feed = 50 + encoding = 'utf8' + publisher = 'Eduardo Guimaraes' + category = 'politics, Brazil' + language = 'pt_BR' + publication_type = 'politics portal' + + feeds = [(u'Blog da Cidadania', u'http://www.blogcidadania.com.br/feed/')] + + reverse_article_order = True + diff --git a/recipes/noticias_unb.recipe b/recipes/noticias_unb.recipe new file mode 100644 index 0000000000..3699926b47 --- /dev/null +++ b/recipes/noticias_unb.recipe @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +from calibre.web.feeds.news import BasicNewsRecipe + +class NoticiasUnB(BasicNewsRecipe): + title = 'Noticias UnB' + __author__ = 'Diniz Bortolotto' + description = 'Noticias da UnB' + oldest_article = 5 + max_articles_per_feed = 20 + category = 'news, educational, Brazil' + language = 'pt_BR' + publication_type = 'newsportal' + use_embedded_content = False + no_stylesheets = True + remove_javascript = True + + feeds = [(u'UnB AgĂȘncia', u'http://www.unb.br/noticias/rss/noticias.rss')] + + reverse_article_order = True + + def print_version(self, url): + return url.replace('http://', 'http://www.unb.br/noticias/print_email/imprimir.php?u=http://') +