mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
152ce22fa0
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
@ -23,7 +22,14 @@ class Danas(BasicNewsRecipe):
|
||||
language = 'sr'
|
||||
publication_type = 'newspaper'
|
||||
remove_empty_feeds = True
|
||||
extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} .article_description,body,.lokacija{font-family: Tahoma,Arial,Helvetica,sans1,sans-serif} .nadNaslov,h1,.preamble{font-family: Georgia,"Times New Roman",Times,serif1,serif} .antrfileText{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em; margin-bottom: 0; margin-top: 0} h2,.datum,.lokacija,.autor{font-size: small} .antrfileNaslov{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em; font-weight:bold; margin-bottom: 0; margin-top: 0} img{margin-bottom: 0.8em} '
|
||||
extra_css = """ @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
||||
@font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
|
||||
.article_description,body,.lokacija{font-family: Tahoma,Arial,Helvetica,sans1,sans-serif}
|
||||
.nadNaslov,h1,.preamble{font-family: Georgia,"Times New Roman",Times,serif1,serif}
|
||||
.antrfileText{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em;
|
||||
margin-bottom: 0; margin-top: 0} h2,.datum,.lokacija,.autor{font-size: small}
|
||||
.antrfileNaslov{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em;
|
||||
font-weight:bold; margin-bottom: 0; margin-top: 0} img{margin-bottom: 0.8em} """
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
@ -42,19 +48,32 @@ class Danas(BasicNewsRecipe):
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Politika' , u'http://www.danas.rs/rss/rss.asp?column_id=27')
|
||||
,(u'Hronika' , u'http://www.danas.rs/rss/rss.asp?column_id=2' )
|
||||
,(u'Dru\xc5\xa1tvo', u'http://www.danas.rs/rss/rss.asp?column_id=24')
|
||||
,(u'Dijalog' , u'http://www.danas.rs/rss/rss.asp?column_id=1' )
|
||||
,(u'Ekonomija', u'http://www.danas.rs/rss/rss.asp?column_id=6' )
|
||||
,(u'Svet' , u'http://www.danas.rs/rss/rss.asp?column_id=25')
|
||||
,(u'Srbija' , u'http://www.danas.rs/rss/rss.asp?column_id=28')
|
||||
,(u'Kultura' , u'http://www.danas.rs/rss/rss.asp?column_id=5' )
|
||||
,(u'Sport' , u'http://www.danas.rs/rss/rss.asp?column_id=13')
|
||||
,(u'Scena' , u'http://www.danas.rs/rss/rss.asp?column_id=42')
|
||||
,(u'Feljton' , u'http://www.danas.rs/rss/rss.asp?column_id=19')
|
||||
,(u'Periskop' , u'http://www.danas.rs/rss/rss.asp?column_id=4' )
|
||||
,(u'Famozno' , u'http://www.danas.rs/rss/rss.asp?column_id=47')
|
||||
(u'Politika' , u'http://www.danas.rs/rss/rss.asp?column_id=27')
|
||||
,(u'Hronika' , u'http://www.danas.rs/rss/rss.asp?column_id=2' )
|
||||
,(u'Drustvo' , u'http://www.danas.rs/rss/rss.asp?column_id=24')
|
||||
,(u'Dijalog' , u'http://www.danas.rs/rss/rss.asp?column_id=1' )
|
||||
,(u'Ekonomija' , u'http://www.danas.rs/rss/rss.asp?column_id=6' )
|
||||
,(u'Svet' , u'http://www.danas.rs/rss/rss.asp?column_id=25')
|
||||
,(u'Srbija' , u'http://www.danas.rs/rss/rss.asp?column_id=28')
|
||||
,(u'Kultura' , u'http://www.danas.rs/rss/rss.asp?column_id=5' )
|
||||
,(u'Sport' , u'http://www.danas.rs/rss/rss.asp?column_id=13')
|
||||
,(u'Scena' , u'http://www.danas.rs/rss/rss.asp?column_id=42')
|
||||
,(u'Feljton' , u'http://www.danas.rs/rss/rss.asp?column_id=19')
|
||||
,(u'Periskop' , u'http://www.danas.rs/rss/rss.asp?column_id=4' )
|
||||
,(u'Famozno' , u'http://www.danas.rs/rss/rss.asp?column_id=47')
|
||||
,(u'Sluzbena beleska' , u'http://www.danas.rs/rss/rss.asp?column_id=48')
|
||||
,(u'Suocavanja' , u'http://www.danas.rs/rss/rss.asp?column_id=49')
|
||||
,(u'Moj Izbor' , u'http://www.danas.rs/rss/rss.asp?column_id=50')
|
||||
,(u'Direktno' , u'http://www.danas.rs/rss/rss.asp?column_id=51')
|
||||
,(u'I tome slicno' , u'http://www.danas.rs/rss/rss.asp?column_id=52')
|
||||
,(u'No longer and not yet', u'http://www.danas.rs/rss/rss.asp?column_id=53')
|
||||
,(u'Resetovanje' , u'http://www.danas.rs/rss/rss.asp?column_id=54')
|
||||
,(u'Iza scene' , u'http://www.danas.rs/rss/rss.asp?column_id=60')
|
||||
,(u'Drustvoslovlje' , u'http://www.danas.rs/rss/rss.asp?column_id=55')
|
||||
,(u'Zvaka u pepeljari' , u'http://www.danas.rs/rss/rss.asp?column_id=56')
|
||||
,(u'Vostani Serbie' , u'http://www.danas.rs/rss/rss.asp?column_id=57')
|
||||
,(u'Med&Jad-a' , u'http://www.danas.rs/rss/rss.asp?column_id=58')
|
||||
,(u'Svetlosti pozornice' , u'http://www.danas.rs/rss/rss.asp?column_id=59')
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
@ -65,3 +84,10 @@ class Danas(BasicNewsRecipe):
|
||||
def print_version(self, url):
|
||||
return url + '&action=print'
|
||||
|
||||
def get_cover_url(self):
|
||||
cover_url = None
|
||||
soup = self.index_to_soup('http://www.danas.rs/')
|
||||
for citem in soup.findAll('img'):
|
||||
if citem['src'].endswith('naslovna.jpg'):
|
||||
return 'http://www.danas.rs' + citem['src']
|
||||
return cover_url
|
||||
|
58
resources/recipes/thairath.recipe
Normal file
58
resources/recipes/thairath.recipe
Normal file
@ -0,0 +1,58 @@
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class AdvancedUserRecipe1271637235(BasicNewsRecipe):
|
||||
|
||||
title = u'Thairath'
|
||||
__author__ = 'Anat R.'
|
||||
language = 'th'
|
||||
|
||||
oldest_article = 7
|
||||
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
|
||||
remove_javascript = True
|
||||
|
||||
use_embedded_content = False
|
||||
feeds = [(u'News',
|
||||
u'http://www.thairath.co.th/rss/news.xml'), (u'Politics',
|
||||
u'http://www.thairath.co.th/rss/pol.xml'), (u'Economy',
|
||||
u'http://www.thairath.co.th/rss/eco.xml'), (u'International',
|
||||
u'http://www.thairath.co.th/rss/oversea.xml'), (u'Sports',
|
||||
u'http://www.thairath.co.th/rss/sport.xml'), (u'Life',
|
||||
u'http://www.thairath.co.th/rss/life.xml'), (u'Education',
|
||||
u'http://www.thairath.co.th/rss/edu.xml'), (u'Tech',
|
||||
u'http://www.thairath.co..th/rss/tech.xml'), (u'Entertainment',
|
||||
u'http://www.thairath.co.th/rss/ent.xml')]
|
||||
keep_only_tags = []
|
||||
|
||||
keep_only_tags.append(dict(name = 'h1', attrs = {'id' : 'title'}))
|
||||
|
||||
keep_only_tags.append(dict(name = 'ul', attrs = {'class' :
|
||||
'detail-info'}))
|
||||
|
||||
keep_only_tags.append(dict(name = 'img', attrs = {'class' :
|
||||
'detail-image'}))
|
||||
|
||||
keep_only_tags.append(dict(name = 'div', attrs = {'class' :
|
||||
'entry'}))
|
||||
remove_tags = []
|
||||
remove_tags.append(dict(name = 'div', attrs = {'id':
|
||||
'menu-holder'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'addthis_toolbox addthis_default_style'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class': 'box top-item'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class': 'column-200 column-margin-430'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'id':
|
||||
'detail-related'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'id': 'related'}))
|
||||
|
||||
remove_tags.append(dict(name = 'id', attrs = {'class': 'footer'}))
|
||||
|
||||
remove_tags.append(dict(name = "ul",attrs =
|
||||
{'id':'banner-highlights-images'}))
|
44
resources/recipes/the_nation_thai.recipe
Normal file
44
resources/recipes/the_nation_thai.recipe
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class AdvancedUserRecipe1271596863(BasicNewsRecipe):
|
||||
|
||||
title = u'The Nation'
|
||||
__author__ = 'Anat R.'
|
||||
language = 'en_TH'
|
||||
|
||||
oldest_article = 7
|
||||
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
|
||||
remove_javascript = True
|
||||
|
||||
use_embedded_content = False
|
||||
feeds = [(u'Topstory',
|
||||
u'http://www.nationmultimedia.com/home/rss/topstories.rss'),
|
||||
(u'National', u'http://www.nationmultimedia.com/home/rss/national.rss'),
|
||||
(u'Politics',
|
||||
u'http://www.nationmultimedia.com/home/rss/politics.rss'), (u'Business',
|
||||
u'http://www.nationmultimedia.com/home/rss/business.rss'),
|
||||
(u'Regional', u'http://www.nationmultimedia.com/home/rss/regional.rss'),
|
||||
(u'Sports', u'http://www.nationmultimedia.com/home/rss/sport.rss'),
|
||||
(u'Travel', u'http://www.nationmultimedia.com/home/rss/travel.rss'),
|
||||
(u'Life', u'http://www.nationmultimedia.com/home/rss/life.rss')]
|
||||
keep_only_tags = []
|
||||
|
||||
keep_only_tags.append(dict(name = 'div', attrs = {'class' :
|
||||
'pd10'}))
|
||||
remove_tags = []
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'WrapperHeaderCol2-2'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'LayoutMenu2'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'TextHeaderRight'}))
|
||||
|
||||
remove_tags.append(dict(name = "ul",attrs = {'id':'toolZoom'}))
|
||||
|
@ -223,6 +223,7 @@ class MetaInformation(object):
|
||||
'isbn', 'tags', 'cover_data', 'application_id', 'guide',
|
||||
'manifest', 'spine', 'toc', 'cover', 'language',
|
||||
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc',
|
||||
'author_sort_map',
|
||||
'pubdate', 'rights', 'publication_type', 'uuid'):
|
||||
if hasattr(mi, attr):
|
||||
setattr(ans, attr, getattr(mi, attr))
|
||||
@ -244,6 +245,7 @@ class MetaInformation(object):
|
||||
self.tags = getattr(mi, 'tags', [])
|
||||
#: mi.cover_data = (ext, data)
|
||||
self.cover_data = getattr(mi, 'cover_data', (None, None))
|
||||
self.author_sort_map = getattr(mi, 'author_sort_map', {})
|
||||
|
||||
for x in ('author_sort', 'title_sort', 'comments', 'category', 'publisher',
|
||||
'series', 'series_index', 'rating', 'isbn', 'language',
|
||||
@ -258,7 +260,7 @@ class MetaInformation(object):
|
||||
'series', 'series_index', 'tags', 'rating', 'isbn', 'language',
|
||||
'application_id', 'manifest', 'toc', 'spine', 'guide', 'cover',
|
||||
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate',
|
||||
'rights', 'publication_type', 'uuid'
|
||||
'rights', 'publication_type', 'uuid', 'author_sort_map'
|
||||
):
|
||||
prints(x, getattr(self, x, 'None'))
|
||||
|
||||
@ -288,6 +290,9 @@ class MetaInformation(object):
|
||||
self.tags += mi.tags
|
||||
self.tags = list(set(self.tags))
|
||||
|
||||
if mi.author_sort_map:
|
||||
self.author_sort_map.update(mi.author_sort_map)
|
||||
|
||||
if getattr(mi, 'cover_data', False):
|
||||
other_cover = mi.cover_data[-1]
|
||||
self_cover = self.cover_data[-1] if self.cover_data else ''
|
||||
|
@ -35,6 +35,8 @@ PUBLICATION_METADATA_FIELDS = frozenset([
|
||||
'title_sort',
|
||||
# Ordered list of authors. Must never be None, can be [_('Unknown')]
|
||||
'authors',
|
||||
# Map of sort strings for each author
|
||||
'author_sort_map',
|
||||
# Pseudo field that can be set, but if not set is auto generated
|
||||
# from authors and languages
|
||||
'author_sort',
|
||||
|
@ -16,6 +16,7 @@ NULL_VALUES = {
|
||||
'classifiers' : {},
|
||||
'languages' : [],
|
||||
'device_collections': [],
|
||||
'author_sort_map': {},
|
||||
'authors' : [_('Unknown')],
|
||||
'title' : _('Unknown'),
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class CoverView(QWidget): # {{{
|
||||
|
||||
def show_data(self, data):
|
||||
self.animation.stop()
|
||||
if data.get('id', None) == self.data.get('id', None):
|
||||
if data.get('id', True) == self.data.get('id', False):
|
||||
return
|
||||
self.data = {'id':data.get('id', None)}
|
||||
if data.has_key('cover'):
|
||||
@ -258,8 +258,7 @@ class BookDetails(QWidget):
|
||||
id_, fmt = val.split(':')
|
||||
self.view_specific_format.emit(int(id_), fmt)
|
||||
elif typ == 'devpath':
|
||||
path = os.path.dirname(val)
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(val))
|
||||
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
@ -275,8 +274,6 @@ class BookDetails(QWidget):
|
||||
self.setToolTip('<p>'+_('Click to open Book Details window') +
|
||||
'<br><br>' + _('Path') + ': ' + data.get(_('Path'), ''))
|
||||
|
||||
|
||||
|
||||
def reset_info(self):
|
||||
self.show_data({})
|
||||
|
||||
|
@ -239,8 +239,7 @@ class StatusBar(QStatusBar, StatusBarInterface, BookDetailsInterface):
|
||||
id_, fmt = val.split(':')
|
||||
self.view_specific_format.emit(int(id_), fmt)
|
||||
elif typ == 'devpath':
|
||||
path = os.path.dirname(val)
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(val))
|
||||
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
|
@ -24,7 +24,7 @@ from calibre.gui2.dialogs.tag_categories import TagCategories
|
||||
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
||||
from calibre.gui2.dialogs.edit_authors_dialog import EditAuthorsDialog
|
||||
|
||||
class TagDelegate(QItemDelegate):
|
||||
class TagDelegate(QItemDelegate): # {{{
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
item = index.internalPointer()
|
||||
@ -54,6 +54,8 @@ class TagDelegate(QItemDelegate):
|
||||
model.data(index, Qt.DisplayRole).toString())
|
||||
painter.restore()
|
||||
|
||||
# }}}
|
||||
|
||||
class TagsView(QTreeView): # {{{
|
||||
|
||||
refresh_required = pyqtSignal()
|
||||
|
@ -430,7 +430,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin, # {{{
|
||||
self.book_on_device(None, reset=True)
|
||||
db.set_book_on_device_func(self.book_on_device)
|
||||
self.library_view.set_database(db)
|
||||
self.tags_view.set_database(db, self.tag_match, self.popularity)
|
||||
self.tags_view.set_database(db, self.tag_match, self.sort_by)
|
||||
self.library_view.model().set_book_on_device_func(self.book_on_device)
|
||||
self.status_bar.clear_message()
|
||||
self.search.clear_to_help()
|
||||
|
@ -433,7 +433,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
if aum: aum = [a.strip().replace('|', ',') for a in aum.split(',')]
|
||||
mi = MetaInformation(self.title(idx, index_is_id=index_is_id), aum)
|
||||
mi.author_sort = self.author_sort(idx, index_is_id=index_is_id)
|
||||
mi.authors_sort_strings = self.authors_sort_strings(idx, index_is_id)
|
||||
if mi.authors:
|
||||
mi.author_sort_map = {}
|
||||
for name, sort in zip(mi.authors, self.authors_sort_strings(idx,
|
||||
index_is_id)):
|
||||
mi.author_sort_map[name] = sort
|
||||
mi.comments = self.comments(idx, index_is_id=index_is_id)
|
||||
mi.publisher = self.publisher(idx, index_is_id=index_is_id)
|
||||
mi.timestamp = self.timestamp(idx, index_is_id=index_is_id)
|
||||
|
@ -103,6 +103,7 @@ _extra_lang_codes = {
|
||||
'en_TH' : _('English (Thailand)'),
|
||||
'en_CY' : _('English (Cyprus)'),
|
||||
'en_PK' : _('English (Pakistan)'),
|
||||
'en_IL' : _('English (Israel)'),
|
||||
'en_SG' : _('English (Singapore)'),
|
||||
'en_YE' : _('English (Yemen)'),
|
||||
'en_IE' : _('English (Ireland)'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user