IGN:Automatically email downloaded news

This commit is contained in:
Kovid Goyal 2009-03-25 00:34:02 -07:00
parent 63ebe19a5f
commit cb7ccaf23d
3 changed files with 37 additions and 4 deletions

View File

@ -505,6 +505,37 @@ class DeviceGUI(object):
p = p.scaledToHeight(ht, Qt.SmoothTransformation) p = p.scaledToHeight(ht, Qt.SmoothTransformation)
return (p.width(), p.height(), pixmap_to_data(p)) return (p.width(), p.height(), pixmap_to_data(p))
def email_news(self, id):
opts = email_config().parse()
accounts = [(account, [x.strip().lower() for x in x[0].split(',')])
for account, x in opts.accounts.items() if x[1]]
sent_mails = []
for account, fmts in accounts:
files = self.library_view.model().\
get_preferred_formats_from_ids([id], fmts)
files = [f.name for f in files if f is not None]
if not files:
continue
attachment = files[0]
mi = self.library_view.model().db.get_metadata(id,
index_is_id=True)
to_s = [account]
subjects = [_('News:')+' '+mi.title]
texts = [_('Attached is the')+' '+mi.title]
attachment_names = [mi.title+os.path.splitext(attachment)[1]]
attachments = [attachment]
jobnames = ['%s:%s'%(id, mi.title)]
remove = [id] if config['delete_news_from_library_on_upload']\
else []
self.emailer.send_mails(jobnames,
Dispatcher(partial(self.emails_sent, remove=remove)),
attachments, to_s, subjects, texts, attachment_names)
sent_mails.append(to_s[0])
if sent_mails:
self.status_bar.showMessage(_('Sent news to')+' '+\
', '.join(sent_mails), 3000)
def sync_news(self): def sync_news(self):
if self.device_connected: if self.device_connected:
ids = list(dynamic.get('news_to_be_synced', set([]))) ids = list(dynamic.get('news_to_be_synced', set([])))

View File

@ -954,6 +954,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
dynamic.set('news_to_be_synced', sync) dynamic.set('news_to_be_synced', sync)
callback(recipe) callback(recipe)
self.status_bar.showMessage(recipe.title + _(' fetched.'), 3000) self.status_bar.showMessage(recipe.title + _(' fetched.'), 3000)
self.email_news(id)
self.sync_news() self.sync_news()
############################################################################ ############################################################################

View File

@ -15,6 +15,7 @@ class Joelonsoftware(BasicNewsRecipe):
language = _('English') language = _('English')
no_stylesheets = True no_stylesheets = True
use_embedded_content = True use_embedded_content = True
oldest_article = 60
cover_url = 'http://www.joelonsoftware.com/RssJoelOnSoftware.jpg' cover_url = 'http://www.joelonsoftware.com/RssJoelOnSoftware.jpg'