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

Method ATTRIB_VIDEOURL

XMLConverter.py:1179–1323  ·  view source on GitHub ↗
(self, src, srcXML, param)

Source from the content-addressed store, hash-verified

1177 return res
1178
1179 def ATTRIB_VIDEOURL(self, src, srcXML, param):
1180 Video, leftover = self.getElement(src, srcXML, param)
1181 partIndex, leftover, dfltd = self.getKey(src, srcXML, leftover)
1182 partIndex = int(partIndex) if partIndex else 0
1183
1184 AuthToken = PlexAPI.getPMSProperty(self.ATV_udid, self.PMS_uuid, 'accesstoken')
1185
1186 if not Video:
1187 dprint(__name__, 0, "VIDEOURL - VIDEO element not found: {0}", param)
1188 res = 'VIDEO_ELEMENT_NOT_FOUND' # not found?
1189 return res
1190
1191 # complete video structure - request transcoding if needed
1192 Media = Video.find('Media')
1193
1194 # check "Media" element and get key
1195 if Media!=None:
1196 # transcoder action
1197 transcoderAction = g_ATVSettings.getSetting(self.ATV_udid, 'transcoderaction')
1198 # transcoderAction = "Transcode"
1199
1200 # video format
1201 # HTTP live stream
1202 # or native aTV media
1203 videoATVNative = \
1204 Media.get('protocol','-') in ("hls") \
1205 or \
1206 Media.get('container','-') in ("mov", "mp4") and \
1207 Media.get('videoCodec','-') in ("mpeg4", "h264", "drmi") and \
1208 Media.get('audioCodec','-') in ("aac", "drms") # remove AC3 when Dolby Digital is Off
1209
1210 # determine if Dolby Digital is active
1211 DolbyDigital = g_ATVSettings.getSetting(self.ATV_udid, 'dolbydigital')
1212 if DolbyDigital=='On':
1213 self.options['DolbyDigital'] = True
1214 videoATVNative = \
1215 Media.get('protocol','-') in ("hls") \
1216 or \
1217 Media.get('container','-') in ("mov", "mp4") and \
1218 Media.get('videoCodec','-') in ("mpeg4", "h264", "drmi") and \
1219 Media.get('audioCodec','-') in ("aac", "ac3", "drms")
1220
1221 for Stream in Media.find('Part').findall('Stream'):
1222 if Stream.get('streamType','') == '1' and\
1223 Stream.get('codec','-') in ("mpeg4", "h264"):
1224 if Stream.get('profile', '-') == 'high 10' or \
1225 int(Stream.get('refFrames','0')) > 8:
1226 videoATVNative = False
1227 break
1228 if Stream.get('scanType', '') == 'interlaced' or Stream.get('codec') == 'mpeg2video':
1229 videoATVNative = False
1230 break
1231
1232 dprint(__name__, 2, "video: ATVNative - {0}", videoATVNative)
1233
1234 # quality limits: quality=(resolution, quality, bitrate)
1235 qLookup = { '480p 2.0Mbps' :('720x480', '60', '2000'), \
1236 '720p 3.0Mbps' :('1280x720', '75', '3000'), \

Callers

nothing calls this directly

Calls 4

dprintFunction · 0.85
getElementMethod · 0.80
getKeyMethod · 0.80
getSettingMethod · 0.45

Tested by

no test coverage detected