Ticket #4985: test.py

File test.py, 2.8 KB (added by Ian Barton <ian@…>, 12 years ago)
Line 
1#!/usr/bin/python
2
3# Some examples showing how to use most of
4# the functions in the MythTV module.
5
6try:
7    from MythTV.MythTV import *
8    from MythTV.MythLog import *
9   
10except:
11    print "MythTV module cannot be initialized."
12
13
14
15myMyth = MythTV()
16
17# Get a value for one of the settings. See the
18# settings table for possible settings.
19print 'Theme setting:'
20print myMyth.getSetting('mythtv', 'Theme')
21
22# Get all recordings.
23recording_list =  myMyth.getRecordingList('Delete')
24print '\n\nLast 10 recordings, excluding Live TV\n'
25count = 0
26for i in range(len(recording_list)):
27   # Ignore LiveTV and only print fist 10 recordings.
28   if not(recording_list[i].recgroup == 'LiveTV') :
29       count = count + 1
30       print recording_list[i].title
31       if count > 9:
32           break
33
34# Get upcoming recordings.
35recording_list =  myMyth.getUpcomingRecordings()
36print '\n\nUpcoming recordings\n'
37
38for i in range(len(recording_list)):
39   print recording_list[i].title
40
41
42# Get all scheduled recordings.
43recording_list =  myMyth.getAllScheduledRecordings()
44print '\n\nScheduled recordings\n'
45
46for i in range(len(recording_list)):
47   print recording_list[i].title
48
49
50# Get list of 10 programs about to expire.
51expiring_list =  myMyth.getExpiring()
52count = 0
53print '\n\nList of expiring programs, excluding Live TV:\n'
54
55for i in range(len(expiring_list)):
56   # Ignore LiveTV and only print fist 10 recordings.
57   if not(expiring_list[i].recgroup == 'LiveTV') :
58       count = count + 1
59       print expiring_list[i].title
60       if count > 9:
61           break
62
63# Get list of scheduled recordings.
64recording_list =  myMyth.getScheduledRecordings()
65print '\n\nList of next  scheduled programs:\n'
66
67for i in range(len(recording_list)):
68       print recording_list[i].title
69
70
71# Get list of upcoming recordings.
72
73recording_list =  myMyth.getUpcomingRecordings()
74print '\n\nList of  upcoming recordings:\n'
75
76for i in range(len(recording_list)):
77       print recording_list[i].title
78
79
80# Get guide data through to
81print '\nGuide data until:'
82print myMyth.getGuideDataThrough()
83
84
85print '\nUptime in seconds:'
86print myMyth.queryUptime()
87
88print '\nRecorder list:'
89print myMyth.getRecorderList()
90
91print '\nFree recorder list:'
92print myMyth.getFreeRecorderList()
93
94# Get details for recorder 1
95myRecorder = myMyth.getRecorderDetails(1)
96print '\nDeatils for recorder 1:'
97print 'Card type: ' + myRecorder.cardtype
98print 'Video device: ' + myRecorder.videodevice
99print 'Host name : ' + myRecorder.hostname
100
101
102# Print all channel names.
103channels =  myMyth.getChannels()
104for i in range(len(channels)):
105   print channels[i].name
106
107
108# Print guide data. Note you must pass
109# valid channel and date, as no sanity
110# checking is performed.
111guide = myMyth.getGuideData('1002', '2008-03-17')
112print '\nGuide data:'
113for i in range(len(guide)):
114   print guide[i].title