You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I was very glad i found the library because I've tried to implement the same functionality to communicate with my Bravia from a microcontroller by sniffing the protocol between the tv and android application. Now I can use my Raspberry Pi 3 instead but I am very new to Python.
One goal is to add recording time since the tv doesn't include this feature and often I miss the end of a recording if the show is delayed by a fem minutes. This is implemented by reading the recording list and if the program title doesn't include an asterisk/*, the recording in deleted, five minutes are added to the duration time and recording is added to the list again but now with an asterisk in its title so the script wont add another five minutes next time. I also check if there are a recording following and in this case I don't add time, just an asterisk to the title. Three new functions has been added, but I don't have the knowledge yet to handle the error control:
def get_recordings(self):
"""Returns list of recordings - Max 100"""
original_content_list = []
content_index = 0
while True:
resp = self.bravia_req_json("sony/recording",
self._jdata_build("getScheduleList", {"cnt":100,"stIdx":0}))
if not resp.get('error'):
if len(resp.get('result')[0]) == 0:
break
original_content_list.extend(resp.get('result')[0])
else:
break
break
return original_content_list
def add_schedule(self,datarow):
"""Add a recording to the list"""
original_content_list = []
content_index = 0
while True:
# ["addSchedule",["{"type":"string","uri":"string","title":"string","startDateTime":"string","durationSec":"int","repeatType":"string","quality":"string"}"],["{"annotation":"int"}"],"1.0"],
resp = self.bravia_req_json("sony/recording",
self._jdata_build("addSchedule", datarow))
if not resp.get('error'):
if len(resp.get('result')[0]) == 0:
break
original_content_list.extend(resp.get('result')[0])
else:
break
break
return original_content_list
def delete_schedule(self, datarow):
"""Delete a scheduled recording"""
while True:
#["deleteSchedule",["{"id":"string","type":"string","uri":"string","title":"string","startDateTime":"string","durationSec":"int"}"],[],"1.0"],
To add the time, I use the demo code to connect to the tv:
# Get the recordings
tv_rec = braviarc.get_recordings()
# Go through all entries
for line in tv_rec:
# Check entries without asterisk
if line['title'].find('*') < 0 :
# Edit the start time format so a datetime variable can be used
Date1 = line['startDateTime'].split('+')
Date = datetime.strptime(Date1[0], "20%y-%m-%dT%H:%M:%S")
print("Start:",Date)
Date = Date + timedelta(seconds=line['durationSec'])
print("End:",Date.strftime("20%y-%m-%dT%H:%M:%S+0200"))
# Ensure there aren't a recording following this one
found = 0
for line2 in tv_rec:
if line2['startDateTime'] == Date.strftime("20%y-%m-%dT%H:%M:%S+0200") :
print("Collision")
found = 1
# Unless the recording has been started - edit the entry
if line['recordingStatus'] == 'notStarted' :
# Delete the entry
braviarc.delete_schedule(line)
# Don't add any time if there are a recording following this one
if found == 0 :
line.update({'durationSec':(300+line['durationSec'])})
# Update the title
line.update({'title': line['title']+'*'})
# Add the recording to the list again
braviarc.add_schedule(line)
The text was updated successfully, but these errors were encountered:
Hi, I was very glad i found the library because I've tried to implement the same functionality to communicate with my Bravia from a microcontroller by sniffing the protocol between the tv and android application. Now I can use my Raspberry Pi 3 instead but I am very new to Python.
One goal is to add recording time since the tv doesn't include this feature and often I miss the end of a recording if the show is delayed by a fem minutes. This is implemented by reading the recording list and if the program title doesn't include an asterisk/*, the recording in deleted, five minutes are added to the duration time and recording is added to the list again but now with an asterisk in its title so the script wont add another five minutes next time. I also check if there are a recording following and in this case I don't add time, just an asterisk to the title. Three new functions has been added, but I don't have the knowledge yet to handle the error control:
def get_recordings(self):
"""Returns list of recordings - Max 100"""
original_content_list = []
content_index = 0
while True:
resp = self.bravia_req_json("sony/recording",
self._jdata_build("getScheduleList", {"cnt":100,"stIdx":0}))
if not resp.get('error'):
if len(resp.get('result')[0]) == 0:
break
original_content_list.extend(resp.get('result')[0])
else:
break
break
return original_content_list
def add_schedule(self,datarow):
"""Add a recording to the list"""
original_content_list = []
content_index = 0
while True:
# ["addSchedule",["{"type":"string","uri":"string","title":"string","startDateTime":"string","durationSec":"int","repeatType":"string","quality":"string"}"],["{"annotation":"int"}"],"1.0"],
def delete_schedule(self, datarow):
"""Delete a scheduled recording"""
while True:
#["deleteSchedule",["{"id":"string","type":"string","uri":"string","title":"string","startDateTime":"string","durationSec":"int"}"],[],"1.0"],
To add the time, I use the demo code to connect to the tv:
The text was updated successfully, but these errors were encountered: