Skip to content

Instantly share code, notes, and snippets.

@onjiro
Created February 28, 2012 04:00
Show Gist options
  • Save onjiro/1929302 to your computer and use it in GitHub Desktop.
Save onjiro/1929302 to your computer and use it in GitHub Desktop.
Calibre のあれ
#/bin/bash
PATH_RECIPES=(calibreインストールディレクトリ)/calibre/resources/recipes
PATH_EBOOKS_OUT=(ebook出力先ディレクトリ)
# 実行前に出力先ディレクトリをクリーン
rm $PATH_EBOOKS_OUT/*
# ebook生成
xvfb-run ebook-convert $PATH_RECIPES/reuters_ja.recipe $PATH_EBOOKS_OUT/reuters_ja.mobi --output-profile kindle --tags "Reuters(Japan),ニュース"
# ファイルを添付して送信
calibre-smtp -a $PATH_EBOOKS_OUT/reuters_ja.mobi -s reuters_ja -e TLS --port 587 --relay smtp.gmail.com --username (gmailのユーザー名) --password (gmailのパスワード) (メールの送信元 gmailのユーザー名と同じでOK) (メールの送信先 [email protected]) "send reuters_ja"
from calibre.web.feeds.news import BasicNewsRecipe
import re
class ReutersJa(BasicNewsRecipe):
title = 'Reuters(Japan)'
description = 'Global news in Japanese'
__author__ = 'Hiroshi Miura'
use_embedded_content = False
language = 'ja'
max_articles_per_feed = 5
remove_javascript = True
feeds = [
('Top Stories', 'http://feeds.reuters.com/reuters/JPTopNews?format=xml'),
('World News', 'http://feeds.reuters.com/reuters/JPWorldNews?format=xml'),
('Business News', 'http://feeds.reuters.com/reuters/JPBusinessNews?format=xml'),
('Technology News', 'http://feeds.reuters.com/reuters/JPTechnologyNews?format=xml'),
('Oddly Enough News', 'http://feeds.reuters.com/reuters/JPOddlyEnoughNews?format=xml')
]
remove_tags_before = {'class':"article primaryContent"}
remove_tags = [
dict(id="banner"),
dict(id="autilities"),
dict(id="textSizer"),
dict(id="shareFooter"),
dict(id="relatedNews"),
dict(id="editorsChoice"),
dict(id="ecArticles"),
{'class':"secondaryContent"},
{'class':"module"},
]
remove_tags_after = {'class':"assetBuddy"}
def print_version(self, url):
m = re.search('(.*idJP[A-Z0-9]+)', url)
return m.group(0)+'?sp=true'
@onjiro
Copy link
Author

onjiro commented Mar 2, 2012

calibre では xvfb が必要になったらしい
{{{
sudo apt-get install xvfb
}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment