Created
November 16, 2015 08:57
-
-
Save greatvc/58f24cc1b21cf309609e to your computer and use it in GitHub Desktop.
Send email of corrupted.txt if videos are found inside. Great tool for notifying you for corrupted videos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import os | |
| import sys | |
| import smtplib | |
| if os.stat('path to Corrupted.txt').st_size == 0: | |
| sys.exit() | |
| from email.MIMEMultipart import MIMEMultipart | |
| from email.MIMEText import MIMEText | |
| fromaddr = "fromemailaddress" | |
| toaddr = "toemailaddress" | |
| msg = MIMEMultipart() | |
| msg['From'] = fromaddr | |
| msg['To'] = toaddr | |
| msg['Subject'] = "Subject" | |
| body = "" | |
| ## Open the file with read only permit | |
| f = open('path to Corrupted.txt') | |
| ## Read the first line | |
| line = f.readline() | |
| ## If the file is not empty keep reading line one at a time | |
| ## till the file is empty | |
| while line: | |
| #print line | |
| body +=line | |
| line = f.readline() | |
| f.close() | |
| # print body | |
| server = smtplib.SMTP('smtp server', 25) | |
| server.ehlo() | |
| server.login("username", "password") | |
| msg.attach(MIMEText(body, 'plain')) | |
| text = msg.as_string() | |
| server.sendmail(fromaddr, toaddr, text) | |
| server.quit() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this script with addition of checkvideos.py that i use and redirect the output to > path to corrupted.txt.
On the .txt it writes the filename of the corrupted videos and then i open the file and read line by line and send an email with the filenames.