diff --git a/recipes/icons/nsfw_corp.png b/recipes/icons/nsfw_corp.png new file mode 100644 index 0000000000..e96c17fd48 Binary files /dev/null and b/recipes/icons/nsfw_corp.png differ diff --git a/recipes/nsfw_corp.recipe b/recipes/nsfw_corp.recipe new file mode 100644 index 0000000000..c88bdd705e --- /dev/null +++ b/recipes/nsfw_corp.recipe @@ -0,0 +1,94 @@ + +__license__ = 'GPL v3' +__copyright__ = '2012, Darko Miletic ' +''' +www.nsfwcorp.com +''' + +import urllib +from calibre import strftime +from calibre.web.feeds.news import BasicNewsRecipe + +class NotSafeForWork(BasicNewsRecipe): + title = 'Not Safe For Work Corporation' + __author__ = 'Darko Miletic' + description = 'Not Safe For Work Corporation' + publisher = 'Not Safe For Work Corporation' + category = 'news, politics, USA, World' + no_stylesheets = True + oldest_article = 15 + encoding = 'utf-8' + needs_subscription = True + auto_cleanup = False + INDEX = 'https://www.nsfwcorp.com' + LOGIN = INDEX + '/login' + use_embedded_content = False + language = 'en' + publication_type = 'magazine' + masthead_url = 'http://assets.nsfwcorp.com/media/headers/nsfw_banner.jpg' + extra_css = """ + body{font-family: Constantia,"Lucida Bright",Lucidabright,"Lucida Serif",Lucida,"DejaVu Serif","Bitstream Vera Serif","Liberation Serif",Georgia,serif} + img{margin-top:0.5em; margin-bottom: 0.7em; display: block} + .fontFace{font-family: 'LeagueGothicRegular',Arial,sans-serif;} + .dispatchTitle{text-transform: uppercase; font-size: x-large; font-weight: bold} + .dispatchSubtitle{font-size: x-large; font-weight: bold} + #fromLine{color: gray; text-align:right} + #toLine{color: gray} + #toLine a{color: red} + #fromLine a{color: red} + .row a{color: red} + """ + + conversion_options = { + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language + } + + remove_tags_before = dict(attrs={'id':'fromToLine'}) + remove_tags_after = dict(attrs={'id':'unlockButtonDiv'}) + remove_tags=[ + dict(name=['meta', 'link', 'iframe', 'embed', 'object']) + ,dict(name='a', attrs={'class':'switchToDeskNotes'}) + ,dict(attrs={'id':'unlockButtonDiv'}) + ] + remove_attributes = ['lang'] + + def get_browser(self): + br = BasicNewsRecipe.get_browser() + br.open(self.LOGIN) + if self.username is not None and self.password is not None: + data = urllib.urlencode({ 'email':self.username + ,'password':self.password + }) + br.open(self.LOGIN, data) + return br + + def parse_index(self): + articles = [] + soup = self.index_to_soup(self.INDEX) + dispatches = soup.find(attrs={'id':'dispatches'}) + if dispatches: + for item in dispatches.findAll('h3'): + description = u'' + title_link = item.find('span', attrs={'class':'dispatchTitle'}) + description_link = item.find('span', attrs={'class':'dispatchSubtitle'}) + feed_link = item.find('a', href=True) + if feed_link: + url = self.INDEX + feed_link['href'] + title = self.tag_to_string(title_link) + description = self.tag_to_string(description_link) + date = strftime(self.timefmt) + articles.append({ + 'title' :title + ,'date' :date + ,'url' :url + ,'description':description + }) + return [('Dispatches', articles)] + + def preprocess_html(self, soup): + for item in soup.findAll(style=True): + del item['style'] + return soup diff --git a/recipes/stamgasten.recipe b/recipes/stamgasten.recipe index 9a637eb7d6..3c7b9cfab8 100644 --- a/recipes/stamgasten.recipe +++ b/recipes/stamgasten.recipe @@ -1,3 +1,5 @@ +from calibre.web.feeds.news import BasicNewsRecipe + class AdvancedUserRecipe1347706704(BasicNewsRecipe): title = u'Stamgasten' __author__ = u'DrMerry' diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index e092f819c6..2db118c8e5 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -1673,10 +1673,7 @@ class DeviceMixin(object): # {{{ if update_metadata: mi = db.get_metadata(id_, index_is_id=True, get_cover=get_covers) - book.smart_update(db.get_metadata(id_, - index_is_id=True, - get_cover=get_covers), - replace_metadata=True) + book.smart_update(mi, replace_metadata=True) book.in_library = 'UUID' # ensure that the correct application_id is set book.application_id = id_ diff --git a/src/calibre/library/catalogs/epub_mobi_builder.py b/src/calibre/library/catalogs/epub_mobi_builder.py index 04e64b9695..41c42b3705 100644 --- a/src/calibre/library/catalogs/epub_mobi_builder.py +++ b/src/calibre/library/catalogs/epub_mobi_builder.py @@ -989,8 +989,8 @@ class CatalogBuilder(object): file_fmts.add(fmt) bookmark_extension = None - if file_fmts.intersection(han_formats): - book_extension = list(file_fmts.intersection(han_formats))[0] + if file_fmts.intersection(tan_formats): + book_extension = list(file_fmts.intersection(tan_formats))[0] bookmark_extension = 'han' elif file_fmts.intersection(mbp_formats): book_extension = list(file_fmts.intersection(mbp_formats))[0] diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index f76d13f27c..aaf152b643 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1262,7 +1262,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): ans = {} if path is not None: stat = os.stat(path) - ans['path'] = path; + ans['path'] = path ans['size'] = stat.st_size ans['mtime'] = utcfromtimestamp(stat.st_mtime) self.format_metadata_cache[id_][fmt] = ans