forked from demonrik/hdhr2plex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump_rules.py
More file actions
96 lines (86 loc) · 2.69 KB
/
dump_rules.py
File metadata and controls
96 lines (86 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#-------------------------------------------------------------------------------
# Simple Tool to dump the Rules List from the HDHR DVR
#
#########
#
#-------------------------------------------------------------------------------
import os
import platform
import logging
import sys
import json
import urllib
import time
from time import strftime
class HDHomeRun:
def __init__(self, hdhr_data):
self.isHttpDVR = False
self.hdhr_base = hdhr_data['BaseURL']
self.hdhr_discover = hdhr_data['DiscoverURL']
self.hdhr_lineup = hdhr_data['LineupURL']
if self.hdhr_discover != None:
self.isHttpDVR = True
response = urllib.urlopen(self.hdhr_discover)
data = json.loads(response.read())
self.hdhr_auth = data['DeviceAuth']
self.hdhr_id = data['DeviceID']
self.hdhr_model = data['ModelNumber']
def getModel(self):
if self.isHttpDVR:
return self.hdhr_model
else:
return 'Not HHTP DVR'
def getID(self):
if self.isHttpDVR:
return self.hdhr_id
else:
return 'Not HHTP DVR'
def getAuth(self):
if self.isHttpDVR:
return self.hdhr_auth
else:
return 'Not HHTP DVR'
def isHttpDvr(self):
return self.isHttpDVR
def discoverHDHRList():
url = 'http://ipv4.my.hdhomerun.com/discover'
response = urllib.urlopen(url)
data = json.loads(response.read())
hdhrs_found = len(data)
print 'found ' + str(hdhrs_found) + ' HDHomerun devices'
authStr = ''
for hdhr_info in data:
hdhr_entry = HDHomeRun(hdhr_info)
if hdhr_entry.isHttpDvr():
print 'Found' + \
' ' + hdhr_entry.getModel() + \
' ' + hdhr_entry.getID() + \
' ' + hdhr_entry.getAuth()
authStr += hdhr_entry.getAuth()
print 'final authstr ' + authStr
recordings_url = 'http://my.hdhomerun.com/api/recording_rules?DeviceAuth=' + authStr
response = urllib.urlopen(recordings_url)
recordings = json.loads(response.read())
print recordings
for recording in recordings:
recentOnly = False
if 'RecentOnly' in recording:
recentOnly = True
if 'AfterOriginalAirdateOnly' in recording:
airdate = 0
if 'ChannelOnly' in recording:
channelOnly = 0
print 'RecordingRuleID: ' + recording['RecordingRuleID'] +\
' SeriesID: ' + recording['SeriesID'] + \
' StartPadding: ' + str(recording['StartPadding']) + \
' EndPadding: ' + str(recording['EndPadding']) + \
' Priority: ' + str(recording['Priority']) + \
' RecentOnly: ' + str(recentOnly) + \
' Title: ' + str(recording['Title'])
return
if __name__ == "__main__":
print '- HDHR Rules Dump Tool '+strftime("%Y-%m-%d %H:%M:%S")+'-'
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
md_file = ''
discoverHDHRList()
print '- Complete -'