forked from plexinc/plex-for-kodi
-
Notifications
You must be signed in to change notification settings - Fork 28
/
plexplayer.py
616 lines (475 loc) · 26 KB
/
plexplayer.py
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
import re
import util
import captions
import http
import plexrequest
import mediadecisionengine
import serverdecision
DecisionFailure = serverdecision.DecisionFailure
class PlexPlayer(object):
DECISION_ENDPOINT = "/video/:/transcode/universal/decision"
def __init__(self, item, seekValue=0, forceUpdate=False):
self.decision = None
self.seekValue = seekValue
self.metadata = None
self.init(item, forceUpdate)
def init(self, item, forceUpdate=False):
self.item = item
self.choice = mediadecisionengine.MediaDecisionEngine().chooseMedia(item, forceUpdate=forceUpdate)
if self.choice:
self.media = self.choice.media
def terminate(self, code, reason):
util.LOG('TERMINATE PLAYER: ({0}, {1})'.format(code, reason))
# TODO: Handle this? ---------------------------------------------------------------------------------------------------------- TODO
def rebuild(self, item, decision=None):
# item.settings = self.item.settings
oldChoice = self.choice
self.init(item, True)
util.LOG("Replacing '{0}' with '{1}' and rebuilding.".format(oldChoice, self.choice))
self.build()
self.decision = decision
def build(self, forceTranscode=False):
if self.item.settings.getPreference("playback_directplay", False):
directPlayPref = self.item.settings.getPreference("playback_directplay_force", False) and 'forced' or 'allow'
else:
directPlayPref = 'disabled'
if forceTranscode or directPlayPref == "disabled" or self.choice.hasBurnedInSubtitles is True:
directPlay = False
else:
directPlay = directPlayPref == "forced" and True or None
return self._build(directPlay, self.item.settings.getPreference("playback_remux", False))
def _build(self, directPlay=None, directStream=True, currentPartIndex=None):
isForced = directPlay is not None
if isForced:
util.LOG(directPlay and "Forced Direct Play" or "Forced Transcode; allowDirectStream={0}".format(directStream))
directPlay = directPlay or self.choice.isDirectPlayable
server = self.item.getServer()
# A lot of our content metadata is independent of the direct play decision.
# Add that first.
obj = util.AttributeDict()
obj.duration = self.media.duration.asInt()
videoRes = self.media.getVideoResolution()
obj.fullHD = videoRes >= 1080
obj.streamQualities = (videoRes >= 480 and self.item.settings.getGlobal("IsHD")) and ["HD"] or ["SD"]
frameRate = self.media.videoFrameRate or "24p"
if frameRate == "24p":
obj.frameRate = 24
elif frameRate == "NTSC":
obj.frameRate = 30
# Add soft subtitle info
if self.choice.subtitleDecision == self.choice.SUBTITLES_SOFT_ANY:
obj.subtitleUrl = server.buildUrl(self.choice.subtitleStream.getSubtitlePath(), True)
elif self.choice.subtitleDecision == self.choice.SUBTITLES_SOFT_DP:
obj.subtitleConfig = {'TrackName': "mkv/" + str(self.choice.subtitleStream.index.asInt() + 1)}
# Create one content metadata object for each part and store them as a
# linked list. We probably want a doubly linked list, except that it
# becomes a circular reference nuisance, so we make the current item the
# base object and singly link in each direction from there.
baseObj = obj
prevObj = None
startOffset = 0
startPartIndex = currentPartIndex or 0
for partIndex in range(startPartIndex, len(self.media.parts)):
isCurrentPart = (currentPartIndex is not None and partIndex == currentPartIndex)
partObj = util.AttributeDict()
partObj.update(baseObj)
partObj.live = False
partObj.partIndex = partIndex
partObj.startOffset = startOffset
part = self.media.parts[partIndex]
partObj.partDuration = part.duration.asInt()
if part.isIndexed():
partObj.sdBifPath = part.getIndexPath("sd")
partObj.hdBifPath = part.getIndexPath("hd")
# We have to evaluate every part before playback. Normally we'd expect
# all parts to be identical, but in reality they can be different.
if partIndex > 0 and (not isForced and directPlay or not isCurrentPart):
choice = mediadecisionengine.MediaDecisionEngine().evaluateMediaVideo(self.item, self.media, partIndex)
canDirectPlay = (choice.isDirectPlayable is True)
else:
canDirectPlay = directPlay
if canDirectPlay:
partObj = self.buildDirectPlay(partObj, partIndex)
else:
transcodeServer = self.item.getTranscodeServer(True, "video")
if transcodeServer is None:
return None
partObj = self.buildTranscode(transcodeServer, partObj, partIndex, directStream, isCurrentPart)
# Set up our linked list references. If we couldn't build an actual
# object: fail fast. Otherwise, see if we're at our start offset
# yet in order to decide if we need to link forwards or backwards.
# We also need to account for parts missing a duration, by verifying
# the prevObj is None or if the startOffset has incremented.
if partObj is None:
obj = None
break
elif prevObj is None or (startOffset > 0 and int(self.seekValue / 1000) >= startOffset):
obj = partObj
partObj.prevObj = prevObj
elif prevObj is not None:
prevObj.nextPart = partObj
startOffset = startOffset + int(part.duration.asInt() / 1000)
prevObj = partObj
# Only set PlayStart for the initial part, and adjust for the part's offset
if obj is not None:
if obj.live:
# Start the stream at the end. Per Roku, this can be achieved using
# a number higher than the duration. Using the current time should
# ensure it's definitely high enough.
obj.playStart = util.now() + 1800
else:
obj.playStart = int(self.seekValue / 1000) - obj.startOffset
self.metadata = obj
util.LOG("Constructed video item for playback: {0}".format(dict(obj)))
return self.metadata
@property
def startOffset(self):
return self.metadata and self.metadata.startOffset or 0
def offsetIsValid(self, offset_seconds):
return self.metadata.startOffset <= offset_seconds < self.metadata.startOffset + (self.metadata.partDuration / 1000)
def isLiveHls(url=None, headers=None):
# Check to see if this is a live HLS playlist to fix two issues. One is a
# Roku workaround since it doesn't obey the absence of EXT-X-ENDLIST to
# start playback at the END of the playlist. The second is for us to know
# if it's live to modify the functionality and player UI.
# if IsString(url):
# request = createHttpRequest(url, "GET", true)
# AddRequestHeaders(request.request, headers)
# response = request.GetToStringWithTimeout(10)
# ' Inspect one of the media playlist streams if this is a master playlist.
# if response.instr("EXT-X-STREAM-INF") > -1 then
# Info("Identify live HLS: inspecting the master playlist")
# mediaUrl = CreateObject("roRegex", "(^https?://.*$)", "m").Match(response)[1]
# if mediaUrl <> invalid then
# request = createHttpRequest(mediaUrl, "GET", true)
# AddRequestHeaders(request.request, headers)
# response = request.GetToStringWithTimeout(10)
# end if
# end if
# isLiveHls = (response.Trim().Len() > 0 and response.instr("EXT-X-ENDLIST") = -1 and response.instr("EXT-X-STREAM-INF") = -1)
# Info("Identify live HLS: live=" + isLiveHls.toStr())
# return isLiveHls
return False
def getServerDecision(self):
directPlay = not (self.metadata and self.metadata.isTranscoded)
decisionPath = self.getDecisionPath(directPlay)
newDecision = None
if decisionPath:
server = self.metadata.transcodeServer or self.item.getServer()
request = plexrequest.PlexRequest(server, decisionPath)
response = request.getWithTimeout(10)
if response.isSuccess() and response.container:
decision = serverdecision.ServerDecision(self, response, self)
if decision.isSuccess():
util.LOG("MDE: Server was happy with client's original decision. {0}".format(decision))
elif decision.isDecision(True):
util.WARN_LOG("MDE: Server was unhappy with client's original decision. {0}".format(decision))
return decision.getDecision()
else:
util.LOG("MDE: Server was unbiased about the decision. {0}".format(decision))
# Check if the server has provided a new media item to use it. If
# there is no item, then we'll continue along as if there was no
# decision made.
newDecision = decision.getDecision(False)
else:
util.WARN_LOG("MDE: Server failed to provide a decision")
else:
util.WARN_LOG("MDE: Server or item does not support decisions")
return newDecision or self
def getDecisionPath(self, directPlay=False):
if not self.item or not self.metadata:
return None
decisionPath = self.metadata.decisionPath
if not decisionPath:
server = self.metadata.transcodeServer or self.item.getServer()
decisionPath = self.buildTranscode(server, util.AttributeDict(), self.metadata.partIndex, True, False).decisionPath
# Modify the decision params based on the transcode url
if decisionPath:
if directPlay:
decisionPath = decisionPath.replace("directPlay=0", "directPlay=1")
# Clear all subtitle parameters and add the a valid subtitle type based
# on the video player. This will let the server decide if it can supply
# sidecar subs, burn or embed w/ an optional transcode.
for key in ("subtitles", "advancedSubtitles"):
decisionPath = re.sub('([?&]{0}=)\w+'.format(key), '', decisionPath)
subType = 'sidecar' # AppSettings().getBoolPreference("custom_video_player"), "embedded", "sidecar")
decisionPath = http.addUrlParam(decisionPath, "subtitles=" + subType)
# Global variables for all decisions
decisionPath = http.addUrlParam(decisionPath, "mediaBufferSize=50000")
decisionPath = http.addUrlParam(decisionPath, "hasMDE=1")
decisionPath = http.addUrlParam(decisionPath, 'X-Plex-Platform=Chrome')
return decisionPath
def getTranscodeReason(self):
# Combine the server and local MDE decisions
obj = []
if self.decision:
obj.append(self.decision.getDecisionText())
if self.item:
obj.append(self.item.transcodeReason)
reason = ' '.join(obj)
if not reason:
return None
return reason
def buildTranscodeHls(self, obj):
util.DEBUG_LOG('buildTranscodeHls()')
obj.streamFormat = "hls"
obj.streamBitrates = [0]
obj.switchingStrategy = "no-adaptation"
obj.transcodeEndpoint = "/video/:/transcode/universal/start.m3u8"
builder = http.HttpRequest(obj.transcodeServer.buildUrl(obj.transcodeEndpoint, True))
builder.extras = []
builder.addParam("protocol", "hls")
if self.choice.subtitleDecision == self.choice.SUBTITLES_SOFT_ANY:
builder.addParam("skipSubtitles", "1")
else: # elif self.choice.hasBurnedInSubtitles is True: # Must burn transcoded because we can't set offset
captionSize = captions.CAPTIONS.getBurnedSize()
if captionSize is not None:
builder.addParam("subtitleSize", captionSize)
# Augment the server's profile for things that depend on the Roku's configuration.
if self.item.settings.supportsAudioStream("ac3", 6):
builder.extras.append("append-transcode-target-audio-codec(type=videoProfile&context=streaming&protocol=hls&audioCodec=ac3)")
builder.extras.append("add-direct-play-profile(type=videoProfile&container=matroska&videoCodec=*&audioCodec=ac3)")
return builder
def buildTranscodeMkv(self, obj):
util.DEBUG_LOG('buildTranscodeMkv()')
obj.streamFormat = "mkv"
obj.streamBitrates = [0]
obj.transcodeEndpoint = "/video/:/transcode/universal/start.mkv"
builder = http.HttpRequest(obj.transcodeServer.buildUrl(obj.transcodeEndpoint, True))
builder.extras = []
# builder.addParam("protocol", "http")
builder.addParam("copyts", "1")
obj.subtitleUrl = None
if True: # if self.choice.subtitleDecision == self.choice.SUBTITLES_BURN: # Must burn transcoded because we can't set offset
builder.addParam("subtitles", "burn")
captionSize = captions.CAPTIONS.getBurnedSize()
if captionSize is not None:
builder.addParam("subtitleSize", captionSize)
else:
# TODO(rob): can we safely assume the id will also be 3 (one based index).
# If not, we will have to get tricky and select the subtitle stream after
# video playback starts via roCaptionRenderer: GetSubtitleTracks() and
# ChangeSubtitleTrack()
obj.subtitleConfig = {'TrackName': "mkv/3"}
# Allow text conversion of subtitles if we only burn image formats
if self.item.settings.getPreference("burn_subtitles") == "image":
builder.addParam("advancedSubtitles", "text")
builder.addParam("subtitles", "auto")
# Augment the server's profile for things that depend on the Roku's configuration.
if self.item.settings.supportsSurroundSound():
if self.choice.audioStream is not None:
numChannels = self.choice.audioStream.channels.asInt(6)
else:
numChannels = 6
for codec in ("ac3", "eac3", "dca"):
if self.item.settings.supportsAudioStream(codec, numChannels):
builder.extras.append("append-transcode-target-audio-codec(type=videoProfile&context=streaming&audioCodec=" + codec + ")")
builder.extras.append("add-direct-play-profile(type=videoProfile&container=matroska&videoCodec=*&audioCodec=" + codec + ")")
if codec == "dca":
builder.extras.append(
"add-limitation(scope=videoAudioCodec&scopeName=dca&type=upperBound&name=audio.channels&value=6&isRequired=false)"
)
# AAC sample rate cannot be less than 22050hz (HLS is capable).
if self.choice.audioStream is not None and self.choice.audioStream.samplingRate.asInt(22050) < 22050:
builder.extras.append("add-limitation(scope=videoAudioCodec&scopeName=aac&type=lowerBound&name=audio.samplingRate&value=22050&isRequired=false)")
# HEVC and VP9 support!
if self.item.settings.getGlobal("hevcSupport"):
builder.extras.append("append-transcode-target-codec(type=videoProfile&context=streaming&videoCodec=hevc)")
if self.item.settings.getGlobal("vp9Support"):
builder.extras.append("append-transcode-target-codec(type=videoProfile&context=streaming&videoCodec=vp9)")
return builder
def buildDirectPlay(self, obj, partIndex):
util.DEBUG_LOG('buildDirectPlay()')
part = self.media.parts[partIndex]
server = self.item.getServer()
# Check if we should include our token or not for this request
obj.isRequestToServer = server.isRequestToServer(server.buildUrl(part.getAbsolutePath("key")))
obj.streamUrls = [server.buildUrl(part.getAbsolutePath("key"), obj.isRequestToServer)]
obj.token = obj.isRequestToServer and server.getToken() or None
if self.media.protocol == "hls":
obj.streamFormat = "hls"
obj.switchingStrategy = "full-adaptation"
obj.live = self.isLiveHLS(obj.streamUrls[0], self.media.indirectHeaders)
else:
obj.streamFormat = self.media.get('container', 'mp4')
if obj.streamFormat == "mov" or obj.streamFormat == "m4v":
obj.streamFormat = "mp4"
obj.streamBitrates = [self.media.bitrate.asInt()]
obj.isTranscoded = False
if self.choice.audioStream is not None:
obj.audioLanguageSelected = self.choice.audioStream.languageCode
return obj
def hasMoreParts(self):
return (self.metadata is not None and self.metadata.nextPart is not None)
def getNextPartOffset(self):
return self.metadata.nextPart.startOffset * 1000
def goToNextPart(self):
oldPart = self.metadata
if oldPart is None:
return
newPart = oldPart.nextPart
if newPart is None:
return
newPart.prevPart = oldPart
oldPart.nextPart = None
self.metadata = newPart
util.LOG("Next part set for playback: {0}".format(self.metadata))
def getBifUrl(self, offset=0):
server = self.item.getServer()
startOffset = 0
for part in self.media.parts:
duration = part.duration.asInt()
if startOffset <= offset < startOffset + duration:
bifUrl = part.getIndexPath("hd") or part.getIndexPath("sd")
if bifUrl is not None:
url = server.buildUrl('{0}/{1}'.format(bifUrl, offset - startOffset), True)
return url
startOffset += duration
return None
def buildTranscode(self, server, obj, partIndex, directStream, isCurrentPart):
util.DEBUG_LOG('buildTranscode()')
obj.transcodeServer = server
obj.isTranscoded = True
# if server.supportsFeature("mkvTranscode") and self.item.settings.getPreference("transcode_format", 'mkv') != "hls":
if server.supportsFeature("mkvTranscode"):
builder = self.buildTranscodeMkv(obj)
else:
builder = self.buildTranscodeHls(obj)
if self.item.getServer().TYPE == 'MYPLEXSERVER':
path = server.swizzleUrl(self.item.getAbsolutePath("key"))
else:
path = self.item.getAbsolutePath("key")
builder.addParam("path", path)
part = self.media.parts[partIndex]
seekOffset = int(self.seekValue / 1000)
# Disabled for HLS due to a Roku bug plexinc/roku-client-issues#776
if True: # obj.streamFormat == "mkv":
# Trust our seekOffset for this part if it's the current part (now playing) or
# the seekOffset is within the time frame. We have to trust the current part
# as we may have to rebuild the transcode when seeking, and not all parts
# have a valid duration.
if isCurrentPart or len(self.media.parts) <= 1 or (
seekOffset >= obj.startOffset and seekOffset <= obj.get('startOffset', 0) + int(part.duration.asInt() / 1000)
):
startOffset = seekOffset - (obj.startOffset or 0)
# Avoid a perfect storm of PMS and Roku quirks. If we pass an offset to
# the transcoder,: it'll start transcoding from that point. But if
# we try to start a few seconds into the video, the Roku seems to want
# to grab the first segment. The first segment doesn't exist, so PMS
# returns a 404 (but only if the offset is <= 12s, otherwise it returns
# a blank segment). If the Roku gets a 404 for the first segment,:
# it'll fail. So, if we're going to start playing from less than 12
# seconds, don't bother telling the transcoder. It's not worth the
# potential failure, let it transcode from the start so that the first
# segment will always exist.
# TODO: Probably can remove this (Rick)
if startOffset <= 12:
startOffset = 0
else:
startOffset = 0
builder.addParam("offset", str(startOffset))
builder.addParam("session", self.item.settings.getGlobal("clientIdentifier"))
builder.addParam("directStream", directStream and "1" or "0")
builder.addParam("directPlay", "0")
qualityIndex = self.item.settings.getQualityIndex(self.item.getQualityType(server))
builder.addParam("videoQuality", self.item.settings.getGlobal("transcodeVideoQualities")[qualityIndex])
builder.addParam("videoResolution", str(self.item.settings.getGlobal("transcodeVideoResolutions")[qualityIndex]))
builder.addParam("maxVideoBitrate", self.item.settings.getGlobal("transcodeVideoBitrates")[qualityIndex])
if self.media.mediaIndex is not None:
builder.addParam("mediaIndex", str(self.media.mediaIndex))
builder.addParam("partIndex", str(partIndex))
# Augment the server's profile for things that depend on the Roku's configuration.
if self.item.settings.getPreference("h264_level", "auto") != "auto":
builder.extras.append(
"add-limitation(scope=videoCodec&scopeName=h264&type=upperBound&name=video.level&value={0}&isRequired=true)".format(
self.item.settings.getPreference("h264_level")
)
)
if not self.item.settings.getGlobal("supports1080p60") and self.item.settings.getGlobal("transcodeVideoResolutions")[qualityIndex][0] >= 1920:
builder.extras.append("add-limitation(scope=videoCodec&scopeName=h264&type=upperBound&name=video.frameRate&value=30&isRequired=false)")
if builder.extras:
builder.addParam("X-Plex-Client-Profile-Extra", '+'.join(builder.extras))
if server.isLocalConnection():
builder.addParam("location", "lan")
obj.streamUrls = [builder.getUrl()]
# Build the decision path now that we have build our stream url, and only if the server supports it.
if server.supportsFeature("streamingBrain"):
decisionPath = builder.getRelativeUrl().replace(obj.transcodeEndpoint, self.DECISION_ENDPOINT)
if decisionPath.startswith(self.DECISION_ENDPOINT):
obj.decisionPath = decisionPath
return obj
class PlexAudioPlayer(object):
def __init__(self, item):
self.containerFormats = {
'aac': "es.aac-adts"
}
self.item = item
self.choice = mediadecisionengine.MediaDecisionEngine().chooseMedia(item)
if self.choice:
self.media = self.choice.media
self.lyrics = None # createLyrics(item, self.media)
def build(self, directPlay=None):
directPlay = directPlay or self.choice.isDirectPlayable
obj = util.AttributeDict()
# TODO(schuyler): Do we want/need to add anything generic here? Title? Duration?
if directPlay:
obj = self.buildDirectPlay(obj)
else:
obj = self.buildTranscode(obj)
self.metadata = obj
util.LOG("Constructed audio item for playback: {0}".format(dict(obj)))
return self.metadata
def buildTranscode(self, obj):
transcodeServer = self.item.getTranscodeServer(True, "audio")
if not transcodeServer:
return None
obj.streamFormat = "mp3"
obj.isTranscoded = True
obj.transcodeServer = transcodeServer
obj.transcodeEndpoint = "/music/:/transcode/universal/start.m3u8"
builder = http.HttpRequest(transcodeServer.buildUrl(obj.transcodeEndpoint, True))
# builder.addParam("protocol", "http")
builder.addParam("path", self.item.getAbsolutePath("key"))
builder.addParam("session", self.item.getGlobal("clientIdentifier"))
builder.addParam("directPlay", "0")
builder.addParam("directStream", "0")
obj.url = builder.getUrl()
return obj
def buildDirectPlay(self, obj):
if self.choice.part:
obj.url = self.item.getServer().buildUrl(self.choice.part.getAbsolutePath("key"), True)
# Set and override the stream format if applicable
obj.streamFormat = self.choice.media.get('container', 'mp3')
if self.containerFormats.get(obj.streamFormat):
obj.streamFormat = self.containerFormats[obj.streamFormat]
# If we're direct playing a FLAC, bitrate can be required, and supposedly
# this is the only way to do it. plexinc/roku-client#48
#
bitrate = self.choice.media.bitrate.asInt()
if bitrate > 0:
obj.streams = [{'url': obj.url, 'bitrate': bitrate}]
return obj
# We may as well fallback to transcoding if we could not direct play
return self.buildTranscode(obj)
def getLyrics(self):
return self.lyrics
def hasLyrics(self):
return False
return self.lyrics.isAvailable()
class PlexPhotoPlayer(object):
def __init__(self, item):
self.item = item
self.choice = item
self.media = item.media()[0]
self.metadata = None
def build(self):
if self.media.parts and self.media.parts[0]:
obj = util.AttributeDict()
part = self.media.parts[0]
path = part.key or part.thumb
server = self.item.getServer()
obj.url = server.buildUrl(path, True)
obj.enableBlur = server.supportsPhotoTranscoding
util.DEBUG_LOG("Constructed photo item for playback: {0}".format(dict(obj)))
self.metadata = obj
return self.metadata