-
Notifications
You must be signed in to change notification settings - Fork 0
Clean up code #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up code #1244
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -466,12 +466,10 @@ class UpdateEpisodeMappingJob : AbstractJob { | |
| updateIdentifier(episodeVariant, id, episode.id.toString(), identifiers) | ||
| updateUrl(episodeVariant, episode.url) | ||
|
|
||
| episodes.add( | ||
| episodes.addAll( | ||
| netflixPlatform.convertEpisode( | ||
| countryCode, | ||
| StringUtils.EMPTY_STRING, | ||
| episode, | ||
| episodeVariant.audioLocale!! | ||
| ) | ||
| ) | ||
| } | ||
|
|
@@ -570,7 +568,7 @@ class UpdateEpisodeMappingJob : AbstractJob { | |
|
|
||
| // Fetch episodes by series and find the previous episode | ||
| logger.warning("Previous episode not found in season, searching by series...") | ||
| return runCatching { CrunchyrollCachedWrapper.getEpisodesBySeriesId(countryCode.locale, episode.seriesId) }.getOrNull() | ||
| runCatching { CrunchyrollCachedWrapper.getEpisodesBySeriesId(countryCode.locale, episode.seriesId) }.getOrNull() | ||
| ?.sortedWith(compareBy({ it.episodeMetadata!!.seasonSequenceNumber }, { it.episodeMetadata!!.sequenceNumber })) | ||
| ?.lastOrNull { it.episodeMetadata!!.index() < episode.index() } | ||
| ?.id | ||
|
|
@@ -619,7 +617,7 @@ class UpdateEpisodeMappingJob : AbstractJob { | |
|
|
||
| // Fetch episodes by series and find the next episode | ||
| logger.warning("Next episode not found in season, searching by series...") | ||
| return runCatching { CrunchyrollCachedWrapper.getEpisodesBySeriesId(countryCode.locale, episode.seriesId) }.getOrNull() | ||
| runCatching { CrunchyrollCachedWrapper.getEpisodesBySeriesId(countryCode.locale, episode.seriesId) }.getOrNull() | ||
| ?.sortedWith(compareBy({ it.episodeMetadata!!.seasonSequenceNumber }, { it.episodeMetadata!!.sequenceNumber })) | ||
| ?.firstOrNull { it.episodeMetadata!!.index() > episode.index() } | ||
| ?.id | ||
|
Comment on lines
+620
to
623
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my comment on finding the previous episode, the logic here for finding the next episode is now duplicated since |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,5 @@ | ||
| package fr.shikkanime.platforms.configuration | ||
|
|
||
| import fr.shikkanime.utils.StringUtils | ||
| import io.ktor.http.* | ||
|
|
||
| class NetflixConfiguration : PlatformConfiguration<NetflixConfiguration.NetflixSimulcastDay>() { | ||
| data class NetflixSimulcastDay( | ||
| var audioLocales: MutableSet<String> = mutableSetOf("ja-JP"), | ||
| var audioLocaleHasDelay: MutableSet<String> = mutableSetOf(), | ||
| ) : ReleaseDayPlatformSimulcast() { | ||
| override fun of(parameters: Parameters) { | ||
| super.of(parameters) | ||
| parameters["audioLocales"]?.let { audioLocales = it.split(StringUtils.COMMA_STRING).toMutableSet() } | ||
| parameters["audioLocaleHasDelay"]?.let { audioLocaleHasDelay = it.split(StringUtils.COMMA_STRING).toMutableSet() } | ||
| } | ||
|
|
||
| override fun toConfigurationFields() = super.toConfigurationFields().apply { | ||
| add( | ||
| ConfigurationField( | ||
| label = "Audio Locales", | ||
| name = "audioLocales", | ||
| type = "text", | ||
| value = audioLocales.joinToString(StringUtils.COMMA_STRING), | ||
| ) | ||
| ) | ||
| add( | ||
| ConfigurationField( | ||
| label = "Audio Locale Delays", | ||
| caption = "Format: locale (e.g. fr-FR)", | ||
| name = "audioLocaleHasDelay", | ||
| type = "text", | ||
| value = audioLocaleHasDelay.joinToString(StringUtils.COMMA_STRING), | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| override fun equals(other: Any?): Boolean { | ||
| if (this === other) return true | ||
| if (other !is NetflixSimulcastDay) return false | ||
| if (!super.equals(other)) return false | ||
|
|
||
| if (audioLocales != other.audioLocales) return false | ||
| if (audioLocaleHasDelay != other.audioLocaleHasDelay) return false | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| override fun hashCode(): Int { | ||
| var result = super.hashCode() | ||
| result = 31 * result + audioLocales.hashCode() | ||
| result = 31 * result + audioLocaleHasDelay.hashCode() | ||
| return result | ||
| } | ||
| } | ||
|
|
||
| override fun newPlatformSimulcast() = NetflixSimulcastDay() | ||
| class NetflixConfiguration : PlatformConfiguration<ReleaseDayPlatformSimulcast>() { | ||
| override fun newPlatformSimulcast() = ReleaseDayPlatformSimulcast() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the addition of
retrievePreviousEpisodeinAbstractCrunchyrollWrapper, the logic here for finding the previous episode for Crunchyroll is now duplicated and overly complex. You can simplify theretrievePreviousEpisodesmethod in this file to directly call the new wrapper method.This would make the code much cleaner and easier to maintain, which aligns with the goal of this pull request.