Skip to content

Instantly share code, notes, and snippets.

@rubenkr
Created September 6, 2020 17:24
Show Gist options
  • Save rubenkr/e310990338b5644c6f74aa876b3e53e4 to your computer and use it in GitHub Desktop.
Save rubenkr/e310990338b5644c6f74aa876b3e53e4 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import os
import smtplib
import subprocess
sender = '[email protected]'
receivers = ['[email protected]']
fullpath = sys.argv[1]
recording = sys.argv[2]
string_fullpath = str(fullpath)
string_recording = str(recording)
message = """From: TVHeadend <[email protected]>
To: Pushover <[email protected]>
Subject: TVHeadend New Recording:
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message + recording)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
print "Converting started for recording: " + string_recording + " in path: " + string_fullpath
# arguments need to be converted to strings
subprocess.call(['/config/convert-mkv2mp4.sh %s %s' % (string_fullpath, string_recording)], shell = True)
# better use call instead of popen -better use subprocess instead of OS.system
#os.system('bash /config/convert-mkv2mp4.sh {} {}' .format(str(fullpath), str(recording))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment