From cd52d295b060b22a40342fe6c46fe8c3f90d0ff1 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 7 Sep 2017 23:47:11 +0200 Subject: [PATCH 1/5] Now both Media and Media.Part in the JSON object about a stream is a list and need to index the first element of the stream to get this info. --- seasoned_api/src/plex/convertPlexToStream.js | 8 +++++--- seasoned_api/src/plex/convertStreamToMediaInfo.js | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/seasoned_api/src/plex/convertPlexToStream.js b/seasoned_api/src/plex/convertPlexToStream.js index 46ddfcd..1e82173 100644 --- a/seasoned_api/src/plex/convertPlexToStream.js +++ b/seasoned_api/src/plex/convertPlexToStream.js @@ -5,11 +5,13 @@ const convertStreamToUser = require('src/plex/stream/convertStreamToUser'); const ConvertStreamToPlayback = require('src/plex/stream/convertStreamToPlayback'); function convertPlexToStream(plexStream) { - const stream = convertPlexToSeasoned(plexStream); - stream.mediaInfo = convertStreamToMediaInfo(plexStream.Media); + const stream = convertPlexToSeasoned(plexStream) + const plexStreamMedia = plexStream.Media[0] + stream.mediaInfo = convertStreamToMediaInfo(plexStreamMedia); stream.player = convertStreamToPlayer(plexStream.Player); + stream.user = convertStreamToUser(plexStream.User); - stream.playback = new ConvertStreamToPlayback(plexStream.Media.Part); + stream.playback = new ConvertStreamToPlayback(plexStreamMedia.Part[0]); return stream; } diff --git a/seasoned_api/src/plex/convertStreamToMediaInfo.js b/seasoned_api/src/plex/convertStreamToMediaInfo.js index cd55477..3844fa9 100644 --- a/seasoned_api/src/plex/convertStreamToMediaInfo.js +++ b/seasoned_api/src/plex/convertStreamToMediaInfo.js @@ -15,6 +15,8 @@ function convertStreamToMediaInfo(plexStream) { mediaInfo.container = plexStream.container; mediaInfo.audioCodec = plexStream.audioCodec; + console.log(mediaInfo) + return mediaInfo; } From a8c6850863a00cd83218495524f098f8648b4819 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 7 Sep 2017 23:48:06 +0200 Subject: [PATCH 2/5] For some reason this was player info, but it is now been replaced with all the variables specific for mediaInfo --- seasoned_api/src/media_classes/mediaInfo.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/seasoned_api/src/media_classes/mediaInfo.js b/seasoned_api/src/media_classes/mediaInfo.js index c3cb52f..3019f25 100644 --- a/seasoned_api/src/media_classes/mediaInfo.js +++ b/seasoned_api/src/media_classes/mediaInfo.js @@ -1,12 +1,14 @@ class MediaInfo { - constructor(device, platform) { - this.device = undefined; - this.platform = undefined; - this.ip = undefined; - this.product = undefined; - this.title = undefined; - this.state = undefined; - + constructor() { + this.duration = undefined; + this.height = undefined; + this.width = undefined; + this.bitrate = undefined; + this.resolution = undefined; + this.framerate = undefined; + this.protocol = undefined; + this.container = undefined; + this.audioCodec = undefined; } } From 3eb2bbe54e4c20f68128858657c06a5154c1579a Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 7 Sep 2017 23:49:21 +0200 Subject: [PATCH 3/5] Removed a console log --- seasoned_api/src/plex/convertStreamToMediaInfo.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/seasoned_api/src/plex/convertStreamToMediaInfo.js b/seasoned_api/src/plex/convertStreamToMediaInfo.js index 3844fa9..60d6c1d 100644 --- a/seasoned_api/src/plex/convertStreamToMediaInfo.js +++ b/seasoned_api/src/plex/convertStreamToMediaInfo.js @@ -6,6 +6,7 @@ function convertStreamToMediaInfo(plexStream) { mediaInfo.duration = plexStream.duration; mediaInfo.height = plexStream.height; mediaInfo.width = plexStream.width; + if (plexStream.bitrate) { mediaInfo.bitrate = plexStream.bitrate; } @@ -15,8 +16,6 @@ function convertStreamToMediaInfo(plexStream) { mediaInfo.container = plexStream.container; mediaInfo.audioCodec = plexStream.audioCodec; - console.log(mediaInfo) - return mediaInfo; } From 0370f051bcaddd2e257005fa5de4652d2f8ef69f Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 7 Sep 2017 23:51:22 +0200 Subject: [PATCH 4/5] Changed the error message returned if something goes wrong when fetching playing --- seasoned_api/src/plex/plexRepository.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seasoned_api/src/plex/plexRepository.js b/seasoned_api/src/plex/plexRepository.js index 0de89c6..25645a8 100644 --- a/seasoned_api/src/plex/plexRepository.js +++ b/seasoned_api/src/plex/plexRepository.js @@ -51,7 +51,7 @@ class PlexRepository { } }) .catch((err) => { - throw new Error(err); + throw new Error('Error handling plex playing. Error: ' + err); }) } } From eb2de340a3bc833b403c263f0c1bd98c4c1969d8 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 7 Sep 2017 23:52:05 +0200 Subject: [PATCH 5/5] Added variables for audioProfile, videoProfile, duration and container for a playback. --- seasoned_api/src/plex/stream/convertStreamToPlayback.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/seasoned_api/src/plex/stream/convertStreamToPlayback.js b/seasoned_api/src/plex/stream/convertStreamToPlayback.js index 555a07e..f4fae2d 100644 --- a/seasoned_api/src/plex/stream/convertStreamToPlayback.js +++ b/seasoned_api/src/plex/stream/convertStreamToPlayback.js @@ -4,6 +4,11 @@ class convertStreamToPlayback { this.width = plexStream.width; this.height = plexStream.height; this.decision = plexStream.decision; + this.audioProfile = plexStream.audioProfile; + this.videoProfile = plexStream.videoProfile; + this.duration = plexStream.duration; + this.container = plexStream.container; + } }