mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #6846 (Updated recipe for Harpers free content) and remove metadata.db backup for S&R dialog
This commit is contained in:
commit
228c648d5d
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
harpers.org
|
harpers.org
|
||||||
'''
|
'''
|
||||||
@ -11,8 +9,7 @@ from calibre.ebooks.BeautifulSoup import Tag
|
|||||||
class Harpers(BasicNewsRecipe):
|
class Harpers(BasicNewsRecipe):
|
||||||
title = u"Harper's Magazine"
|
title = u"Harper's Magazine"
|
||||||
__author__ = u'Darko Miletic'
|
__author__ = u'Darko Miletic'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
|
||||||
description = u"Harper's Magazine: Founded June 1850."
|
description = u"Harper's Magazine: Founded June 1850."
|
||||||
publisher = "Harper's Magazine "
|
publisher = "Harper's Magazine "
|
||||||
category = 'news, politics, USA'
|
category = 'news, politics, USA'
|
||||||
@ -21,13 +18,12 @@ class Harpers(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
|
|
||||||
html2lrf_options = [
|
conversion_options = {
|
||||||
'--comment', description
|
'comment' : description
|
||||||
, '--category', category
|
, 'tags' : category
|
||||||
, '--publisher', publisher
|
, 'publisher' : publisher
|
||||||
]
|
, 'language' : language
|
||||||
|
}
|
||||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"'
|
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
h1{ font-family:georgia ; color:#111111; font-size:large;}
|
h1{ font-family:georgia ; color:#111111; font-size:large;}
|
||||||
@ -39,8 +35,9 @@ class Harpers(BasicNewsRecipe):
|
|||||||
keep_only_tags = [ dict(name='div', attrs={'id':'cached'}) ]
|
keep_only_tags = [ dict(name='div', attrs={'id':'cached'}) ]
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='table', attrs={'class':['rcnt','rcnt topline']})
|
dict(name='table', attrs={'class':['rcnt','rcnt topline']})
|
||||||
,dict(name=['link','object','embed'])
|
,dict(name=['link','object','embed','meta','base'])
|
||||||
]
|
]
|
||||||
|
remove_attributes = ['width','height']
|
||||||
|
|
||||||
feeds = [(u"Harper's Magazine", u'http://www.harpers.org/rss/frontpage-rss20.xml')]
|
feeds = [(u"Harper's Magazine", u'http://www.harpers.org/rss/frontpage-rss20.xml')]
|
||||||
|
|
||||||
@ -49,20 +46,13 @@ class Harpers(BasicNewsRecipe):
|
|||||||
index = 'http://harpers.org/'
|
index = 'http://harpers.org/'
|
||||||
soup = self.index_to_soup(index)
|
soup = self.index_to_soup(index)
|
||||||
link_item = soup.find(name = 'img',attrs= {'class':"cover"})
|
link_item = soup.find(name = 'img',attrs= {'class':"cover"})
|
||||||
print link_item
|
|
||||||
if link_item:
|
if link_item:
|
||||||
cover_url = 'http://harpers.org' + link_item['src']
|
cover_url = 'http://harpers.org' + link_item['src']
|
||||||
print cover_url
|
|
||||||
return cover_url
|
return cover_url
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
|
|
||||||
soup.head.insert(1,mcharset)
|
|
||||||
for item in soup.findAll(style=True):
|
for item in soup.findAll(style=True):
|
||||||
del item['style']
|
del item['style']
|
||||||
for item in soup.findAll(xmlns=True):
|
for item in soup.findAll(xmlns=True):
|
||||||
del item['xmlns']
|
del item['xmlns']
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,8 +193,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
'Note: <b>you can destroy your library</b> '
|
'Note: <b>you can destroy your library</b> '
|
||||||
'using this feature. Changes are permanent. There '
|
'using this feature. Changes are permanent. There '
|
||||||
'is no undo function. You are strongly encouraged '
|
'is no undo function. You are strongly encouraged '
|
||||||
'to backup the metadata.db file in your library '
|
'to back up your library before proceeding.'))
|
||||||
'before proceeding.'))
|
|
||||||
self.s_r_error = None
|
self.s_r_error = None
|
||||||
self.s_r_obj = None
|
self.s_r_obj = None
|
||||||
|
|
||||||
@ -278,13 +277,6 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
field = unicode(self.search_field.currentText())
|
field = unicode(self.search_field.currentText())
|
||||||
if not field or not self.s_r_obj:
|
if not field or not self.s_r_obj:
|
||||||
return
|
return
|
||||||
if self.s_r_backup_db.isChecked():
|
|
||||||
self.db.commit()
|
|
||||||
src = self.db.dbpath
|
|
||||||
dest = self.db.dbpath+'.backup'
|
|
||||||
if os.path.exists(dest):
|
|
||||||
os.remove(dest)
|
|
||||||
shutil.copyfile(src, dest)
|
|
||||||
|
|
||||||
fm = self.db.field_metadata[field]
|
fm = self.db.field_metadata[field]
|
||||||
|
|
||||||
|
@ -329,17 +329,14 @@ Future conversion of these books will use the default settings.</string>
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
<item row="2" column="0">
|
||||||
<item row="2" column="0" colspan="3">
|
<widget class="QLabel" name="filler">
|
||||||
<widget class="QCheckBox" name="s_r_backup_db">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Backup 'metadata.db' to 'metadata.db.backup' before applying changes</string>
|
<string> </string>
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user