@@ -21,11 +21,13 @@ import org.koin.core.component.KoinComponent
21
21
import org.koin.core.component.inject
22
22
import uk.co.sentinelweb.cuer.app.orchestrator.OrchestratorContract.Source
23
23
import uk.co.sentinelweb.cuer.app.orchestrator.OrchestratorContract.Source.LOCAL
24
+ import uk.co.sentinelweb.cuer.app.orchestrator.OrchestratorContract.Source.REMOTE
24
25
import uk.co.sentinelweb.cuer.app.orchestrator.toGuidIdentifier
25
26
import uk.co.sentinelweb.cuer.app.service.remote.RemoteServerContract
26
27
import uk.co.sentinelweb.cuer.app.usecase.GetFolderListUseCase
27
28
import uk.co.sentinelweb.cuer.core.providers.PlayerConfigProvider
28
29
import uk.co.sentinelweb.cuer.core.wrapper.LogWrapper
30
+ import uk.co.sentinelweb.cuer.domain.PlaylistAndChildrenDomain
29
31
import uk.co.sentinelweb.cuer.domain.ext.deserialisePlaylistItem
30
32
import uk.co.sentinelweb.cuer.domain.ext.domainMessageJsonSerializer
31
33
import uk.co.sentinelweb.cuer.domain.ext.serialise
@@ -305,8 +307,9 @@ class JvmRemoteWebServer(
305
307
val postData = call.receiveText()
306
308
try {
307
309
(postData)
310
+ .also { logWrapper.d(" launchitem: postdata: ${it} " ) }
308
311
.let { deserialisePlaylistItem(it) }
309
- // .let {it.copy(media = it.media.copy()) }
312
+ .also { logWrapper.d( " launchitem: ${ it.id?.serialise()} " ) }
310
313
.let { item ->
311
314
remotePlayerLaunchHost.launchVideo(
312
315
item,
@@ -326,6 +329,7 @@ class JvmRemoteWebServer(
326
329
val path = call.parameters[FOLDER_LIST_API .P_PARAM ]
327
330
logWrapper.d(" Folder: $path " )
328
331
getFolderListUseCase.getFolderList(path)
332
+ ?.let { rewriteIdsToRemote(it) } // todo rewrite platformid -> http
329
333
?.let { ResponseDomain (it) }
330
334
?.apply { call.respondText(serialise(), ContentType .Application .Json ) }
331
335
? : apply {
@@ -336,7 +340,7 @@ class JvmRemoteWebServer(
336
340
get(" /video-stream/{filePath}" ) {
337
341
val filePath = call.parameters[" filePath" ]
338
342
// ?.substring("/video-stream".length)
339
- ?.replace(" :::::" ," /" )
343
+ ?.replace(" :::::" , " /" )
340
344
if (filePath == null ) {
341
345
call.respond(HttpStatusCode .BadRequest , " File filePath is missing" )
342
346
return @get
@@ -345,8 +349,8 @@ class JvmRemoteWebServer(
345
349
346
350
val parentPath = filePath.substring(0 , filePath.lastIndexOf(" /" ))
347
351
val item = getFolderListUseCase.getFolderList(parentPath)
348
- ?.children?.filter { it.platformId?.endsWith(filePath)? : false }
349
- val fullPath = getFolderListUseCase.truncatedToFullFolderPath(filePath)
352
+ ?.children?.filter { it.platformId?.endsWith(filePath) ? : false }
353
+ val fullPath = getFolderListUseCase.truncatedToFullFolderPath(filePath)
350
354
logWrapper.d(" /video-stream/filepath: $fullPath " )
351
355
352
356
val file = File (fullPath)
@@ -379,6 +383,43 @@ class JvmRemoteWebServer(
379
383
}
380
384
}
381
385
}
386
+
387
+ private fun rewriteIdsToRemote (it : PlaylistAndChildrenDomain ) = it.copy(
388
+ playlist = it.playlist.copy(
389
+ id = it.playlist.id?.copy(
390
+ source = REMOTE ,
391
+ locator = localRepository.localNode.locator()
392
+ ),
393
+ items = it.playlist.items.map {
394
+ it.copy(
395
+ id = it.id?.copy(
396
+ source = REMOTE ,
397
+ locator = localRepository.localNode.locator()
398
+ ),
399
+ media = it.media.copy(
400
+ id = it.media.id?.copy(
401
+ source = REMOTE ,
402
+ locator = localRepository.localNode.locator()
403
+ ),
404
+ channelData = it.media.channelData.copy(
405
+ id = it.media.channelData.id?.copy(
406
+ source = REMOTE ,
407
+ locator = localRepository.localNode.locator()
408
+ )
409
+ )
410
+ )
411
+ )
412
+ }
413
+ ),
414
+ children = it.children.map { child ->
415
+ child.copy(
416
+ id = child.id?.copy(
417
+ source = REMOTE ,
418
+ locator = localRepository.localNode.locator()
419
+ )
420
+ )
421
+ }
422
+ )
382
423
}
383
424
384
425
0 commit comments