Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Regex and show name problem
06-05-2010, 02:34 AM #1
- Join Date
- Jun 2010
- Thanked 0 Times in 0 Posts
Regex and show name problem
I literally started learning python two hours ago in an attempt to produce a script that can monitor my mythtv box recording status. Scripts do exist but they all see live tv as a recording. So I wanted a custom script.
I have this so far:
#!/usr/bin/python import httplib import time import MythTV import twitter import re from MythTV import MythDB, MythBE prefix = 'Recording: ' db1 = MythDB(args=(('DBHostName','localhost'), ('DBName','mythconverg'), ('DBUserName','mythtv'), ('DBPassword','################'))) LastTweet1 = ' ' LastTweet2 = ' ' be1 = MythBE(db=db1) api = twitter.Api(username='########', password='#########') Encoder1 = "Encoder 1 " Encoder2 = "Encoder 2 " Recording = "is local on chimera and is recording" while(True): Connection = httplib.HTTPConnection("localhost:6544") Connection.request("GET", "/") Results = Connection.getresponse().read() if Encoder1+Recording in Results: REC1 = be1.getCurrentRecording(1) result = re.search ( "\'[A-Z a-z 0-9]*\'", str(REC1) ) Show = result.group ( 0 ) if LastTweet1 != Show: LastTweet1 = Show tempPrefix = prefix tempPrefix += Show api.PostUpdate(tempPrefix) if Encoder2+Recording in Results: REC2 = be1.getCurrentRecording(2) result = re.search ( "\'[A-Z a-z 0-9]*\'", str(REC2) ) Show = result.group ( 0 ) if LastTweet2 != Show: LastTweet2 = Show tempPrefix = prefix tempPrefix += Show api.PostUpdate(tempPrefix) time.sleep(10)
<Program '4Music's Top 20','2010-06-05 01:30:00' at 0x1dd4050>
I there a better way to get the show name from the given string?
Please excuse any bad programming! Im a newbie of two hours
06-07-2010, 12:11 PM #2
Sorry I know nothing about the MythBE module. But from what I've found in the module's Wiki, getCurrentRecording is supposed to return a Program object.
--- [Edit: just looked at the MythData.Program source...] ---
You can try looking for "4Music" in the Program object's title, as in:
REC1 = be1.getCurrentRecording(1) if "4Music" in REC1.title: # do stuff...
Last edited by Samhain13; 06-07-2010 at 01:05 PM. Reason: Modified sample code.I am a Man of Truth. I am a Free Human Person. I am a Peacemaker.
** Independent Multimedia Artist in Pasig **