Skip to content

Instantly share code, notes, and snippets.

@greatvc
Created November 16, 2015 08:57
Show Gist options
  • Select an option

  • Save greatvc/58f24cc1b21cf309609e to your computer and use it in GitHub Desktop.

Select an option

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.
#!/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()
@greatvc
Copy link
Copy Markdown
Author

greatvc commented Nov 16, 2015

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.

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