This commit is contained in:
Kovid Goyal 2011-10-20 21:49:02 +05:30
parent a37212a456
commit f41c8c9a08
10 changed files with 31 additions and 30 deletions

View File

@ -4,7 +4,6 @@ __copyright__ = '2011 Aurélien Chabot <contact@aurelienchabot.fr>'
''' '''
20minutes.fr 20minutes.fr
''' '''
import re
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
class Minutes(BasicNewsRecipe): class Minutes(BasicNewsRecipe):

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class BasicUserRecipe1318572550(AutomaticNewsRecipe):
from calibre.web.feeds.news import BasicNewsRecipe
class BasicUserRecipe1318572550(BasicNewsRecipe):
title = u'FrAndroid' title = u'FrAndroid'
oldest_article = 2 oldest_article = 2
max_articles_per_feed = 100 max_articles_per_feed = 100

View File

@ -1,5 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class BasicUserRecipe1318572445(AutomaticNewsRecipe):
from calibre.web.feeds.news import BasicNewsRecipe
class BasicUserRecipe1318572445(BasicNewsRecipe):
title = u'Google Mobile Blog' title = u'Google Mobile Blog'
oldest_article = 7 oldest_article = 7
max_articles_per_feed = 100 max_articles_per_feed = 100

View File

@ -3,34 +3,31 @@ __copyright__ = '2011, Seongkyoun Yoo <seongkyoun.yoo at gmail.com>'
''' '''
Profile to download The Hankyoreh Profile to download The Hankyoreh
''' '''
import re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import BeautifulSoup
class Hankyoreh(BasicNewsRecipe): class Hankyoreh(BasicNewsRecipe):
title = u'Hankyoreh' title = u'Hankyoreh'
language = 'ko' language = 'ko'
description = u'The Hankyoreh News articles' description = u'The Hankyoreh News articles'
__author__ = 'Seongkyoun Yoo' __author__ = 'Seongkyoun Yoo'
oldest_article = 5 oldest_article = 5
recursions = 1 recursions = 1
max_articles_per_feed = 5 max_articles_per_feed = 5
no_stylesheets = True no_stylesheets = True
keep_only_tags = [ keep_only_tags = [
dict(name='tr', attrs={'height':['60px']}), dict(name='tr', attrs={'height':['60px']}),
dict(id=['fontSzArea']) dict(id=['fontSzArea'])
] ]
remove_tags = [ remove_tags = [
dict(target='_blank'), dict(target='_blank'),
dict(name='td', attrs={'style':['padding: 10px 8px 5px 8px;']}), dict(name='td', attrs={'style':['padding: 10px 8px 5px 8px;']}),
dict(name='iframe', attrs={'width':['590']}), dict(name='iframe', attrs={'width':['590']}),
] ]
remove_tags_after = [ remove_tags_after = [
dict(target='_top') dict(target='_top')
] ]
feeds = [ 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/'), ('Politics','http://www.hani.co.kr/rss/politics/'),
('Economy','http://www.hani.co.kr/rss/economy/'), ('Economy','http://www.hani.co.kr/rss/economy/'),
('Society','http://www.hani.co.kr/rss/society/'), ('Society','http://www.hani.co.kr/rss/society/'),
@ -47,4 +44,4 @@ class Hankyoreh(BasicNewsRecipe):
('Multihani','http://www.hani.co.kr/rss/multihani/'), ('Multihani','http://www.hani.co.kr/rss/multihani/'),
('Lead','http://www.hani.co.kr/rss/lead/'), ('Lead','http://www.hani.co.kr/rss/lead/'),
('Newsrank','http://www.hani.co.kr/rss/newsrank/'), ('Newsrank','http://www.hani.co.kr/rss/newsrank/'),
] ]

View File

@ -3,7 +3,6 @@ __copyright__ = '2011, Seongkyoun Yoo <seongkyoun.yoo at gmail.com>'
''' '''
Profile to download The Hankyoreh Profile to download The Hankyoreh
''' '''
import re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class Hankyoreh21(BasicNewsRecipe): class Hankyoreh21(BasicNewsRecipe):
@ -23,4 +22,4 @@ class Hankyoreh21(BasicNewsRecipe):
feeds = [ feeds = [
('Hani21','http://h21.hani.co.kr/rss/ '), ('Hani21','http://h21.hani.co.kr/rss/ '),
] ]

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class BasicUserRecipe1318619728(AutomaticNewsRecipe): from calibre.web.feeds.news import BasicNewsRecipe
class BasicUserRecipe1318619728(BasicNewsRecipe):
title = u'Korben' title = u'Korben'
oldest_article = 7 oldest_article = 7
max_articles_per_feed = 100 max_articles_per_feed = 100

View File

@ -4,7 +4,6 @@ __copyright__ = '2011 Aurélien Chabot <contact@aurelienchabot.fr>'
''' '''
LePoint.fr LePoint.fr
''' '''
import re
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
class lepoint(BasicNewsRecipe): class lepoint(BasicNewsRecipe):

View File

@ -4,7 +4,6 @@ __copyright__ = '2011 Aurélien Chabot <contact@aurelienchabot.fr>'
''' '''
Lexpress.fr Lexpress.fr
''' '''
import re
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
class lepoint(BasicNewsRecipe): class lepoint(BasicNewsRecipe):

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class BasicUserRecipe1318619832(AutomaticNewsRecipe):
from calibre.web.feeds.news import BasicNewsRecipe
class BasicUserRecipe1318619832(BasicNewsRecipe):
title = u'OmgUbuntu' title = u'OmgUbuntu'
oldest_article = 7 oldest_article = 7
max_articles_per_feed = 100 max_articles_per_feed = 100

View File

@ -20,9 +20,8 @@ from calibre.devices.usbms.driver import USBMS, debug_print
from calibre.devices.usbms.device import USBDevice from calibre.devices.usbms.device import USBDevice
from calibre.devices.usbms.books import CollectionsBookList from calibre.devices.usbms.books import CollectionsBookList
from calibre.devices.usbms.books import BookList 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.constants import islinux
from calibre.ebooks.metadata import authors_to_string, authors_to_sort_string
DBPATH = 'Sony_Reader/database/books.db' DBPATH = 'Sony_Reader/database/books.db'
THUMBPATH = 'Sony_Reader/database/cache/books/%s/thumbnail/main_thumbnail.jpg' THUMBPATH = 'Sony_Reader/database/cache/books/%s/thumbnail/main_thumbnail.jpg'
@ -186,7 +185,7 @@ class PRST1(USBMS):
if self.device_offset is None: if self.device_offset is None:
query = 'SELECT file_path, modified_date FROM books' query = 'SELECT file_path, modified_date FROM books'
cursor.execute(query) cursor.execute(query)
time_offsets = {} time_offsets = {}
for i, row in enumerate(cursor): for i, row in enumerate(cursor):
comp_date = int(os.path.getmtime(self.normalize_path(prefix + row[0])) * 1000); 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 offset = device_date - comp_date
time_offsets.setdefault(offset, 0) time_offsets.setdefault(offset, 0)
time_offsets[offset] = time_offsets[offset] + 1 time_offsets[offset] = time_offsets[offset] + 1
try: try:
device_offset = max(time_offsets,key = lambda a: time_offsets.get(a)) device_offset = max(time_offsets,key = lambda a: time_offsets.get(a))
debug_print("Device Offset: %d ms"%device_offset) debug_print("Device Offset: %d ms"%device_offset)
@ -304,7 +303,7 @@ class PRST1(USBMS):
if use_sony_authors: if use_sony_authors:
author = newmi.authors[0] author = newmi.authors[0]
else: else:
author = authors_to_string(newmi.authors) author = authors_to_string(newmi.authors)
except: except:
author = _('Unknown') author = _('Unknown')
title = newmi.title or _('Unknown') title = newmi.title or _('Unknown')
@ -348,7 +347,7 @@ class PRST1(USBMS):
if self.is_sony_periodical(book): if self.is_sony_periodical(book):
self.periodicalize_book(connection, book) self.periodicalize_book(connection, book)
for book, bookId in db_books.items(): for book, bookId in db_books.items():
if bookId is not None: if bookId is not None:
# Remove From Collections # Remove From Collections
@ -531,7 +530,7 @@ class PRST1(USBMS):
if book.pubdate.date() < date(2010, 10, 17): if book.pubdate.date() < date(2010, 10, 17):
return False return False
return True return True
def periodicalize_book(self, connection, book): def periodicalize_book(self, connection, book):
if not self.is_sony_periodical(book): if not self.is_sony_periodical(book):
return return
@ -555,19 +554,19 @@ class PRST1(USBMS):
pubdate = int(time.mktime(book.pubdate.timetuple()) * 1000) pubdate = int(time.mktime(book.pubdate.timetuple()) * 1000)
except: except:
pass pass
cursor = connection.cursor() cursor = connection.cursor()
query = ''' query = '''
UPDATE books UPDATE books
SET conforms_to = 'http://xmlns.sony.net/e-book/prs/periodicals/1.0/newspaper/1.0', SET conforms_to = 'http://xmlns.sony.net/e-book/prs/periodicals/1.0/newspaper/1.0',
periodical_name = ?, periodical_name = ?,
description = ?, description = ?,
publication_date = ? publication_date = ?
WHERE _id = ? WHERE _id = ?
''' '''
t = (name, None, pubdate, book.bookId,) t = (name, None, pubdate, book.bookId,)
cursor.execute(query, t) cursor.execute(query, t)
connection.commit() connection.commit()
cursor.close() cursor.close()