MythTV UserJob: MythMailNotify
by 9teen on Apr.20, 2009, under yellow
I’m a happy MythTV user and I love the keyword based recording, which means that the system matches programs to record in the electronic program guide by keywords I have scheduled and surprises me – sometimes in both ways 😛 – everyday. If I’m not too busy to look at the recorded programs …
I’m actually not much a TV person (it got better again since I have MythTV and it strips the commercials so well) and I don’t have the time to check out the program guide on a regular basis to see what was recorded.
Thus I looked at other programs I use: why not simply send a mail, when a new recording is in. I looked for an option in MythTV and if someone else on the net had the same idea and maybe posted something. But I couldn’t find anything, except for UserJobs, which are being executed after recording and I already had used before.
The plain text version of the mail was quite easily finished, but of course one looks at the nice MythWeb interface and thinks … Hmm, actually one wants a mail with the information presented as on the „Recorded“ page in Mythweb:
So I browsed through html mail stuff like boundaries, Content-Transfer-Types and base64-encoding and finally get a mail in plain-text and html with a thumbnail (resized to 3K) of the recorded program and description:
If someone else is interested in this feature, you can download a zip archive below. Here is a list, what steps need to be taken:
- Have MythTV up and running, obviously
- Have a local mailsystem (exim or postfix or sendmail) installed & configured
- Dependencies (Debian Package):
- mail (mailx)
- md5sum (core-utils)
- convert (imagemagick)
- mimencode (metamail)
- Get the script, make it executable and place it in /usr/local/bin
- Change it according to your needs: MythWeb URL, date-style and subject.
- Login to MythWeb
- Select Settings / MythTV / Settings-Table for [All hosts]
- Scroll down to UserJob1 or the next free one.
- Insert /usr/local/bin/mythmailnotify.sh <your eMail> „%STARTTIME%“ „%ENDTIME%“ „%TITLE%“ „%SUBTITLE%“ „%DESCRIPTION%“ „%DIR%“ „%FILE%“ „%HOSTNAME%“
- Further down you’ll find UserJobDesc1 which can be labeled like „MythMailNotify“.
- And you could also change AutoRunUserJob1 to 1 to have automatically selected with new recording schedules.
- Scroll to the bottom and SAVE (Double check! No error correction from the app)
- Your existing schedules need to be manually updated either by MythWeb or via MySQL directly and all new jobs will have mythmailnotify pre-selected, if you set AutoRunUserJob1 to 1.
Some variables seem not to be available for UserJobs, so I had to leave them out for now (missing [possible way]: Duration [deduct times], Filesize [du], Channel[?]).
I also stumbled across several „out-of-the-box“ mailer tools, which all didn’t make it to simply replace the mail command (with which I had started) and at the same time handle the inline attachment in a nice way.
I didn’t want to mix several languages, like having a bash script calling a phpmailer; The languages sometimes look to similar, which confuses me a lot amongst bash, perl, python, php and the like. That’s why I tried to stick to bash and have as few dependencies as possible. I’m not an everyday programmer and I believe the code looks pretty much thrown together, but it works 🙂
Thanks to all the MythTV people for creating such a great software !!!
Finally here are some links, that helped me through the job and of course any hints are welcome.