MCPcopy
hub / github.com/iBaa/PlexConnect / do_GET

Method do_GET

WebServer.py:97–272  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

95 self.wfile.write(data)
96
97 def do_GET(self):
98 global g_param
99 try:
100 dprint(__name__, 2, "http request header:\n{0}", self.headers)
101 dprint(__name__, 2, "http request path:\n{0}", self.path)
102
103 # check for PMS address
104 PMSaddress = ''
105 pms_end = self.path.find(')')
106 if self.path.startswith('/PMS(') and pms_end>-1:
107 PMSaddress = urllib.unquote_plus(self.path[5:pms_end])
108 self.path = self.path[pms_end+1:]
109
110 # break up path, separate PlexConnect options
111 # clean path needed for filetype decoding
112 parts = re.split(r'[?&]', self.path, 1) # should be '?' only, but we do some things different :-)
113 if len(parts)==1:
114 self.path = parts[0]
115 options = {}
116 query = ''
117 else:
118 self.path = parts[0]
119
120 # break up query string
121 options = {}
122 query = ''
123 parts = parts[1].split('&')
124 for part in parts:
125 if part.startswith('PlexConnect'):
126 # get options[]
127 opt = part.split('=', 1)
128 if len(opt)==1:
129 options[opt[0]] = ''
130 else:
131 options[opt[0]] = urllib.unquote(opt[1])
132 else:
133 # recreate query string (non-PlexConnect) - has to be merged back when forwarded
134 if query=='':
135 query = '?' + part
136 else:
137 query += '&' + part
138
139 # get aTV language setting
140 options['aTVLanguage'] = Localize.pickLanguage(self.headers.get('Accept-Language', 'en'))
141
142 query = query.replace("yyltyy", "<").replace("yygtyy", ">")
143
144 # add client address - to be used in case UDID is unknown
145 if 'X-Forwarded-For' in self.headers:
146 options['aTVAddress'] = self.headers['X-Forwarded-For'].split(',', 1)[0]
147 else:
148 options['aTVAddress'] = self.client_address[0]
149
150 # get aTV hard-/software parameters
151 options['aTVFirmwareVersion'] = self.headers.get('X-Apple-TV-Version', '5.1')
152 options['aTVScreenResolution'] = self.headers.get('X-Apple-TV-Resolution', '720')
153
154 dprint(__name__, 2, "pms address:\n{0}", PMSaddress)

Callers

nothing calls this directly

Calls 4

sendResponseMethod · 0.95
dprintFunction · 0.85
JSConverterFunction · 0.85
getSettingMethod · 0.45

Tested by

no test coverage detected