From f41c8c9a087ccda16f2bc0059960a9eb172c2f64 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 Oct 2011 21:49:02 +0530 Subject: [PATCH] ... --- recipes/20minutes.recipe | 1 - recipes/frandroid.recipe | 4 +++- recipes/googlemobileblog.recipe | 5 ++++- recipes/hankyoreh.recipe | 17 +++++++---------- recipes/hankyoreh21.recipe | 3 +-- recipes/korben.recipe | 4 +++- recipes/lepoint.recipe | 1 - recipes/lexpress.recipe | 1 - recipes/omgubuntu.recipe | 4 +++- src/calibre/devices/prst1/driver.py | 21 ++++++++++----------- 10 files changed, 31 insertions(+), 30 deletions(-) diff --git a/recipes/20minutes.recipe b/recipes/20minutes.recipe index 84dcd226e1..683f89fac9 100644 --- a/recipes/20minutes.recipe +++ b/recipes/20minutes.recipe @@ -4,7 +4,6 @@ __copyright__ = '2011 Aurélien Chabot ' ''' 20minutes.fr ''' -import re from calibre.web.feeds.recipes import BasicNewsRecipe class Minutes(BasicNewsRecipe): diff --git a/recipes/frandroid.recipe b/recipes/frandroid.recipe index 0ad46dee4e..76c42f7360 100644 --- a/recipes/frandroid.recipe +++ b/recipes/frandroid.recipe @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -class BasicUserRecipe1318572550(AutomaticNewsRecipe): + +from calibre.web.feeds.news import BasicNewsRecipe +class BasicUserRecipe1318572550(BasicNewsRecipe): title = u'FrAndroid' oldest_article = 2 max_articles_per_feed = 100 diff --git a/recipes/googlemobileblog.recipe b/recipes/googlemobileblog.recipe index c33c02db79..8d755e4a26 100644 --- a/recipes/googlemobileblog.recipe +++ b/recipes/googlemobileblog.recipe @@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- -class BasicUserRecipe1318572445(AutomaticNewsRecipe): + +from calibre.web.feeds.news import BasicNewsRecipe + +class BasicUserRecipe1318572445(BasicNewsRecipe): title = u'Google Mobile Blog' oldest_article = 7 max_articles_per_feed = 100 diff --git a/recipes/hankyoreh.recipe b/recipes/hankyoreh.recipe index 3afd3dd5dd..8212765b66 100644 --- a/recipes/hankyoreh.recipe +++ b/recipes/hankyoreh.recipe @@ -3,34 +3,31 @@ __copyright__ = '2011, Seongkyoun Yoo ' ''' Profile to download The Hankyoreh ''' -import re from calibre.web.feeds.news import BasicNewsRecipe -from calibre.ebooks.BeautifulSoup import BeautifulSoup - class Hankyoreh(BasicNewsRecipe): title = u'Hankyoreh' language = 'ko' description = u'The Hankyoreh News articles' - __author__ = 'Seongkyoun Yoo' + __author__ = 'Seongkyoun Yoo' oldest_article = 5 recursions = 1 max_articles_per_feed = 5 no_stylesheets = True keep_only_tags = [ - dict(name='tr', attrs={'height':['60px']}), - dict(id=['fontSzArea']) + dict(name='tr', attrs={'height':['60px']}), + dict(id=['fontSzArea']) ] remove_tags = [ dict(target='_blank'), - dict(name='td', attrs={'style':['padding: 10px 8px 5px 8px;']}), - dict(name='iframe', attrs={'width':['590']}), + dict(name='td', attrs={'style':['padding: 10px 8px 5px 8px;']}), + dict(name='iframe', attrs={'width':['590']}), ] remove_tags_after = [ dict(target='_top') ] feeds = [ - ('All News','http://www.hani.co.kr/rss/'), + ('All News','http://www.hani.co.kr/rss/'), ('Politics','http://www.hani.co.kr/rss/politics/'), ('Economy','http://www.hani.co.kr/rss/economy/'), ('Society','http://www.hani.co.kr/rss/society/'), @@ -47,4 +44,4 @@ class Hankyoreh(BasicNewsRecipe): ('Multihani','http://www.hani.co.kr/rss/multihani/'), ('Lead','http://www.hani.co.kr/rss/lead/'), ('Newsrank','http://www.hani.co.kr/rss/newsrank/'), - ] \ No newline at end of file + ] diff --git a/recipes/hankyoreh21.recipe b/recipes/hankyoreh21.recipe index 85ded3b8e3..f49b4cc1ab 100644 --- a/recipes/hankyoreh21.recipe +++ b/recipes/hankyoreh21.recipe @@ -3,7 +3,6 @@ __copyright__ = '2011, Seongkyoun Yoo ' ''' Profile to download The Hankyoreh ''' -import re from calibre.web.feeds.news import BasicNewsRecipe class Hankyoreh21(BasicNewsRecipe): @@ -23,4 +22,4 @@ class Hankyoreh21(BasicNewsRecipe): feeds = [ ('Hani21','http://h21.hani.co.kr/rss/ '), - ] \ No newline at end of file + ] diff --git a/recipes/korben.recipe b/recipes/korben.recipe index cab52f2e32..fb8134b5cb 100644 --- a/recipes/korben.recipe +++ b/recipes/korben.recipe @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -class BasicUserRecipe1318619728(AutomaticNewsRecipe): +from calibre.web.feeds.news import BasicNewsRecipe + +class BasicUserRecipe1318619728(BasicNewsRecipe): title = u'Korben' oldest_article = 7 max_articles_per_feed = 100 diff --git a/recipes/lepoint.recipe b/recipes/lepoint.recipe index 9ecc764534..9a4aab01da 100644 --- a/recipes/lepoint.recipe +++ b/recipes/lepoint.recipe @@ -4,7 +4,6 @@ __copyright__ = '2011 Aurélien Chabot ' ''' LePoint.fr ''' -import re from calibre.web.feeds.recipes import BasicNewsRecipe class lepoint(BasicNewsRecipe): diff --git a/recipes/lexpress.recipe b/recipes/lexpress.recipe index 1b48e4778b..3de6226f1b 100644 --- a/recipes/lexpress.recipe +++ b/recipes/lexpress.recipe @@ -4,7 +4,6 @@ __copyright__ = '2011 Aurélien Chabot ' ''' Lexpress.fr ''' -import re from calibre.web.feeds.recipes import BasicNewsRecipe class lepoint(BasicNewsRecipe): diff --git a/recipes/omgubuntu.recipe b/recipes/omgubuntu.recipe index 1e50e0eec2..e2a619c281 100644 --- a/recipes/omgubuntu.recipe +++ b/recipes/omgubuntu.recipe @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -class BasicUserRecipe1318619832(AutomaticNewsRecipe): + +from calibre.web.feeds.news import BasicNewsRecipe +class BasicUserRecipe1318619832(BasicNewsRecipe): title = u'OmgUbuntu' oldest_article = 7 max_articles_per_feed = 100 diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index 12d6b3ddef..7d27b4657a 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -20,9 +20,8 @@ from calibre.devices.usbms.driver import USBMS, debug_print from calibre.devices.usbms.device import USBDevice from calibre.devices.usbms.books import CollectionsBookList from calibre.devices.usbms.books import BookList -from calibre.ebooks.metadata import authors_to_sort_string +from calibre.ebooks.metadata import authors_to_sort_string, authors_to_string from calibre.constants import islinux -from calibre.ebooks.metadata import authors_to_string, authors_to_sort_string DBPATH = 'Sony_Reader/database/books.db' THUMBPATH = 'Sony_Reader/database/cache/books/%s/thumbnail/main_thumbnail.jpg' @@ -186,7 +185,7 @@ class PRST1(USBMS): if self.device_offset is None: query = 'SELECT file_path, modified_date FROM books' cursor.execute(query) - + time_offsets = {} for i, row in enumerate(cursor): comp_date = int(os.path.getmtime(self.normalize_path(prefix + row[0])) * 1000); @@ -194,7 +193,7 @@ class PRST1(USBMS): offset = device_date - comp_date time_offsets.setdefault(offset, 0) time_offsets[offset] = time_offsets[offset] + 1 - + try: device_offset = max(time_offsets,key = lambda a: time_offsets.get(a)) debug_print("Device Offset: %d ms"%device_offset) @@ -304,7 +303,7 @@ class PRST1(USBMS): if use_sony_authors: author = newmi.authors[0] else: - author = authors_to_string(newmi.authors) + author = authors_to_string(newmi.authors) except: author = _('Unknown') title = newmi.title or _('Unknown') @@ -348,7 +347,7 @@ class PRST1(USBMS): if self.is_sony_periodical(book): self.periodicalize_book(connection, book) - + for book, bookId in db_books.items(): if bookId is not None: # Remove From Collections @@ -531,7 +530,7 @@ class PRST1(USBMS): if book.pubdate.date() < date(2010, 10, 17): return False return True - + def periodicalize_book(self, connection, book): if not self.is_sony_periodical(book): return @@ -555,19 +554,19 @@ class PRST1(USBMS): pubdate = int(time.mktime(book.pubdate.timetuple()) * 1000) except: pass - + cursor = connection.cursor() - + query = ''' UPDATE books SET conforms_to = 'http://xmlns.sony.net/e-book/prs/periodicals/1.0/newspaper/1.0', periodical_name = ?, description = ?, - publication_date = ? + publication_date = ? WHERE _id = ? ''' t = (name, None, pubdate, book.bookId,) cursor.execute(query, t) - + connection.commit() cursor.close()