Hello,
I'm making a python script to power on my HTPC from my raspberry in the case there is a recording to start.
I succeeded to get back the schedules :
Here's the ouput :
I want to use get starttime and endtime fields.
How can I convert starttime and endtime in python date ?
edit : ok, I saw from MediaPortal.bundle that he just strip the string with [6:-7].
Thanks in advance.
I'm making a python script to power on my HTPC from my raspberry in the case there is a recording to start.
I succeeded to get back the schedules :
Code:
import urllib2, base64, traceback, sys, json
from wakeonlan import wol
from datetime import datetime, date, time
username = ''
password = ''
result = ''
power = False
datenow = datetime.now()
try:
request = urllib2.Request("http://192.168.0.32:4322/MPExtended/TVAccessService/json/GetSchedules")
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request)
records = json.loads(result.read())
print records
for record in records:
#/json/GetScheduleById
print record['Title']
print record['StartTime']
print record['EndTime']
print "\n"
power = False
if power == True:
wol.send_magic_packet('ec.a8.6b.ff.1b.33')
print 'powerup'
except Exception, e:
print e
sys.exit(0)
raw_input()
Here's the ouput :
[{u'Title': u'Tennis (Masters ATP 2014)', u'PreRecordInterval': 0, u'IsChanged': False, u'MaxAirings': 2147483647, u'Priority': 0, u'BitRateMode': 3, u'KeepMethod': 3, u'PostRecordInterval': 0, u'ScheduleType': 0, u'EndTime': u'/Date(1416002400000+0100)/', u'ChannelId': 24, u'ParentScheduleId': -1, u'DoesUseEpisodeManagement': False, u'IsManual': False, u'Directory': u'', u'RecommendedCard': -1, u'Series': False, u'Canceled': u'/Date(946681200000+0100)/', u'StartTime': u'/Date(1415994300000+0100)/', u'KeepDate': u'/Date(1447530300000+0100)/', u'QualityType': 7, u'Quality': 73, u'Id': 3}]
Tennis (Masters ATP 2014)
/Date(1415994300000+0100)/
/Date(1416002400000+0100)/
I want to use get starttime and endtime fields.
How can I convert starttime and endtime in python date ?
edit : ok, I saw from MediaPortal.bundle that he just strip the string with [6:-7].
Thanks in advance.
Last edited: