Skip to content

Commit

Permalink
Fix DisneyPlusPlatform.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Jun 23, 2024
1 parent 477f202 commit 271af66
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
21 changes: 12 additions & 9 deletions src/main/kotlin/fr/shikkanime/platforms/DisneyPlusPlatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,25 @@ class DisneyPlusPlatform :
val animeDescription =
animeDetails.getAsJsonObject("description")?.getAsString("full")?.replace('\n', ' ') ?: ""

val season = requireNotNull(jsonObject.getAsInt("seasonNumber")) { "Season is null" }
val number = jsonObject.getAsInt("episodeNumber") ?: -1
val id = jsonObject.getAsString("id")
val title = jsonObject.getAsString("episodeTitle")?.ifBlank { null }
val url = "https://www.disneyplus.com/${countryCode.locale.lowercase()}/video/$id"
val imageId = jsonObject.getAsJsonObject("artwork")?.getAsJsonObject("standard")?.getAsJsonObject("thumbnail")
val visualsObject = jsonObject.getAsJsonObject("visuals")

val season = requireNotNull(visualsObject.getAsInt("seasonNumber")) { "Season is null" }
val number = visualsObject.getAsInt("episodeNumber") ?: -1
val id = jsonObject.getAsString("id") ?: throw Exception("Id is null")
val title = visualsObject.getAsString("episodeTitle")?.ifBlank { null }
val url = "https://www.disneyplus.com/${countryCode.locale.lowercase()}/play/$id"
val imageId =
visualsObject.getAsJsonObject("artwork")?.getAsJsonObject("standard")?.getAsJsonObject("thumbnail")
?.getAsJsonObject("1.78")?.getAsString("imageId") ?: throw Exception("Image is null")
val image = DisneyPlusWrapper.getImageUrl(imageId)
var duration = jsonObject.getAsLong("durationMs", -1)
var duration = visualsObject.getAsLong("durationMs", -1)

if (duration != -1L) {
duration /= 1000
}

val description =
jsonObject.getAsJsonObject("description")?.getAsString("medium")?.replace('\n', ' ')?.ifBlank { null }
visualsObject.getAsJsonObject("description")?.getAsString("medium")?.replace('\n', ' ')?.ifBlank { null }
val releaseDateTimeUTC =
zonedDateTime.withUTC().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "T${simulcast.releaseTime}Z"
val releaseDateTime = ZonedDateTime.parse(releaseDateTimeUTC)
Expand All @@ -143,7 +146,7 @@ class DisneyPlusPlatform :
image = image,
platform = getPlatform(),
audioLocale = "ja-JP",
id = id.toString(),
id = id,
url = url,
uncensored = false
)
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/fr/shikkanime/services/EpisodeMappingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ class EpisodeMappingService : AbstractService<EpisodeMapping, EpisodeMappingRepo
variant.releaseDateTime = ZonedDateTime.parse(variantDto.releaseDateTime)
}

if (variantDto.identifier.isNotBlank() && variantDto.identifier != variant.identifier.toString()) {
variant.identifier = variantDto.identifier
}

if (variantDto.url.isNotBlank() && variantDto.url != variant.url.toString()) {
variant.url = variantDto.url
}

if (variantDto.uncensored != variant.uncensored) {
variant.uncensored = variantDto.uncensored
}

oldList.removeIf { it.uuid == variantDto.uuid }
episodeVariantService.update(variant)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object DisneyPlusWrapper {

jsonObject.getAsJsonArray("items")
.filter { it.asJsonObject.getAsString("type") == "view" }
.forEach { episodes.add(it.asJsonObject.getAsJsonObject("visuals")) }
.forEach { episodes.add(it.asJsonObject) }
} while (hasMore)

return episodes
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/admin/episodes/edit.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@
<label for="variantIdentifier" class="form-label">Identifier</label>
<input type="text" class="form-control" id="variantIdentifier"
name="variantIdentifier"
x-model="variant.identifier" disabled>
x-model="variant.identifier">
</div>
<div class="col-md-auto">
<label for="variantUrl" class="form-label">URL</label>

<div class="input-group">
<input type="text" class="form-control" id="variantUrl" name="variantUrl"
x-model="variant.url" aria-label="Image"
aria-describedby="basic-addon" disabled>
aria-describedby="basic-addon">

<a class="input-group-text" id="basic-addon" style="cursor: pointer"
target="_blank" :href="variant.url">
Expand All @@ -208,7 +208,7 @@
<div class="col-md-auto">
<input type="checkbox" class="form-check-input" id="variantUncensored"
name="variantUncensored"
x-model="variant.uncensored" disabled>
x-model="variant.uncensored">
<label for="variantUncensored" class="form-label">Uncensored</label>
</div>
<div class="col-md-auto">
Expand Down

0 comments on commit 271af66

Please sign in to comment.