mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-04-29 02:12:10 +02:00
Polish Fetch from Email, add auto-reject feature.
This commit is contained in:
parent
d59a1bda1a
commit
beef2ebadc
5 changed files with 348 additions and 307 deletions
|
|
@ -342,6 +342,7 @@ class ConfigWidget(QWidget):
|
|||
prefs['imapfolder'] = unicode(self.imap_tab.imapfolder.text())
|
||||
prefs['imapmarkread'] = self.imap_tab.imapmarkread.isChecked()
|
||||
prefs['imapsessionpass'] = self.imap_tab.imapsessionpass.isChecked()
|
||||
prefs['auto_reject_from_email'] = self.imap_tab.auto_reject_from_email.isChecked()
|
||||
|
||||
prefs.save_to_db()
|
||||
|
||||
|
|
@ -1327,6 +1328,12 @@ class ImapTab(QWidget):
|
|||
self.l.addWidget(self.imapmarkread,row,0,1,-1)
|
||||
row+=1
|
||||
|
||||
self.auto_reject_from_email = QCheckBox(_('Discard URLs on Reject List'),self)
|
||||
self.auto_reject_from_email.setToolTip(_('If checked, FanFicFare will silently discard story URLs from emails that are on your Reject URL List.<br>Otherwise they will appear and you will see the normal Reject URL dialog.<br>The Emails will still be marked Read if configured to.'))
|
||||
self.auto_reject_from_email.setChecked(prefs['auto_reject_from_email'])
|
||||
self.l.addWidget(self.auto_reject_from_email,row,0,1,-1)
|
||||
row+=1
|
||||
|
||||
label = QLabel(_("<b>It's safest if you create a separate email account that you use only "
|
||||
"for your story update notices. FanFicFare and calibre cannot guarantee that "
|
||||
"malicious code cannot get your email password once you've entered it. "
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ import email
|
|||
import traceback
|
||||
|
||||
try:
|
||||
from PyQt5.Qt import (QApplication, QMenu, QTimer)
|
||||
from PyQt5.Qt import (QApplication, QMenu, QTimer, QCursor, Qt)
|
||||
from PyQt5.QtCore import QBuffer
|
||||
except ImportError as e:
|
||||
from PyQt4.Qt import (QApplication, QMenu, QTimer)
|
||||
from PyQt4.Qt import (QApplication, QMenu, QTimer, QCursor, Qt)
|
||||
from PyQt4.QtCore import QBuffer
|
||||
|
||||
from calibre.constants import numeric_version as calibre_version
|
||||
|
|
@ -421,17 +421,30 @@ class FanFicFarePlugin(InterfaceAction):
|
|||
if prefs['imapsessionpass']:
|
||||
self.imap_pass = imap_pass
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
self.gui.status_bar.show_message(_('Fetching Story URLs from Email...'))
|
||||
url_list = get_urls_from_imap(prefs['imapserver'],
|
||||
prefs['imapuser'],
|
||||
imap_pass,
|
||||
prefs['imapfolder'],
|
||||
prefs['imapmarkread'],)
|
||||
reject_list=[]
|
||||
if prefs['auto_reject_from_email']:
|
||||
reject_list = set([x for x in url_list if rejecturllist.check(x)])
|
||||
url_list = url_list - reject_list
|
||||
|
||||
self.gui.status_bar.show_message(_('Finished Fetching Story URLs from Email.'),3000)
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
if url_list:
|
||||
self.add_dialog("\n".join(url_list),merge=False)
|
||||
else:
|
||||
|
||||
msg = _('No Valid Story URLs Found in Unread Emails.')
|
||||
if reject_list:
|
||||
msg = msg + '<p>'+(_('(%d Story URLs Skipped, on Rejected URL List)')%len(reject_list))+'</p>'
|
||||
info_dialog(self.gui, _('Get Story URLs from Email'),
|
||||
_('No Valid Story URLs Found in Unread Emails.'),
|
||||
msg,
|
||||
show=True,
|
||||
show_copy_button=False)
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ default_prefs['imappass'] = ''
|
|||
default_prefs['imapsessionpass'] = False
|
||||
default_prefs['imapfolder'] = 'INBOX'
|
||||
default_prefs['imapmarkread'] = True
|
||||
default_prefs['auto_reject_from_email'] = False
|
||||
|
||||
def set_library_config(library_config,db):
|
||||
db.prefs.set_namespaced(PREFS_NAMESPACE,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -216,9 +216,9 @@ def get_urls_from_imap(srv,user,passwd,folder,markread=True):
|
|||
try:
|
||||
#print("part mime:%s"%part.get_content_type())
|
||||
if part.get_content_type() == 'text/plain':
|
||||
urllist.extend(get_urls_from_text(part.get_payload(decode=True)))
|
||||
urllist.extend(get_urls_from_text(part.get_payload(decode=True),normalize=True))
|
||||
if part.get_content_type() == 'text/html':
|
||||
urllist.extend(get_urls_from_html(part.get_payload(decode=True)))
|
||||
urllist.extend(get_urls_from_html(part.get_payload(decode=True),normalize=True))
|
||||
except Exception as e:
|
||||
print("Failed to read email content: %s"%e)
|
||||
#print "urls:%s"%get_urls_from_text(get_first_text_block(email_message))
|
||||
|
|
|
|||
Loading…
Reference in a new issue