Skip to content

Instantly share code, notes, and snippets.

@rubenkr
Created September 12, 2020 20:19
Show Gist options
  • Save rubenkr/c0a8f08e55ee83dfb8fe223763ae9c44 to your computer and use it in GitHub Desktop.
Save rubenkr/c0a8f08e55ee83dfb8fe223763ae9c44 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import os
import smtplib
import subprocess
from smtplib import SMTPException
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('127.0.0.1')
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