chill@will

MythTV UserJob: MythMailNotify

by 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:

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:

mythmailnotify mail example

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:

  1. Have MythTV up and running, obviously
  2. Have a local mailsystem (exim or postfix or sendmail) installed & configured
  3. Dependencies (Debian Package):
    1. mail (mailx)
    2. md5sum (core-utils)
    3. convert (imagemagick)
    4. mimencode (metamail)
  4. Get the script, make it executable and place it in /usr/local/bin
  5. Change it according to your needs: MythWeb URL, date-style and subject.
  6. Login to MythWeb
  7. Select Settings / MythTV / Settings-Table for [All hosts]
  8. Scroll down to UserJob1 or the next free one.
  9. Insert /usr/local/bin/mythmailnotify.sh <your eMail> „%STARTTIME%“ „%ENDTIME%“ „%TITLE%“ „%SUBTITLE%“ „%DESCRIPTION%“ „%DIR%“ „%FILE%“ „%HOSTNAME%“
  10. Further down you’ll find UserJobDesc1 which can be labeled like „MythMailNotify“.
  11. And you could also change AutoRunUserJob1 to 1 to have automatically selected with new recording schedules.
  12. Scroll to the bottom and SAVE (Double check! No error correction from the app)
  13. 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.

:,

Comments are closed.

fortune cookie

BOFH excuse #103:

operators on strike due to broken coffee machine

,


Apparent:
Pressure:
Humidity: %
Winds:
Sunrise:
Sunset:
More forecast...
 

,


Apparent:
Pressure:
Humidity: %
Winds:
Sunrise:
Sunset:
More forecast...