本文整理汇总了Python中gmail.Gmail.get_unread方法的典型用法代码示例。如果您正苦于以下问题:Python Gmail.get_unread方法的具体用法?Python Gmail.get_unread怎么用?Python Gmail.get_unread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gmail.Gmail
的用法示例。
在下文中一共展示了Gmail.get_unread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gmail
# 需要导入模块: from gmail import Gmail [as 别名]
# 或者: from gmail.Gmail import get_unread [as 别名]
if plex:
downloaded_movies_location = filebot_location
print_length = 50
new_movies_location = downloaded_movies_location
old_downloaded = os.listdir(downloaded_movies_location)
gmail = Gmail(email_address)
gmail.login_yagmail()
while True:
current_time = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
print("Checking for emails" + " "*(print_length-(len("Checking for emails"))), end="\r")
for received_email in gmail.get_unread():
print("Email received" + " "*(print_length-(len("Email received"))))
sender = received_email['From']
subject = received_email['Subject']
if any(email in sender for email in users):
added_torrent = find_torrent.search_and_download(subject)
print(" "*print_length)
print(sender + " "*(print_length-(len(sender))))
print(subject + " "*(print_length-(len(subject))))
gmail.send_email(receivers=users, subject="Movie Received. Downloading.",
message="Added movie name: " + added_torrent[0] +
"\nServer output: " + str(added_torrent[1]))