Skip to content

Commit

Permalink
add check simulcast config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Dec 30, 2024
1 parent de8bd79 commit 53de9d5
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 44 deletions.
77 changes: 35 additions & 42 deletions src/main/kotlin/fr/shikkanime/entities/enums/ConfigPropertyKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,50 @@ package fr.shikkanime.entities.enums

enum class ConfigPropertyKey(val key: String) {
SIMULCAST_RANGE("simulcast_range"),
DISCORD_TOKEN("discord_token"),
SEO_DESCRIPTION("seo_description"),
SOCIAL_NETWORK_EPISODES_SIZE_LIMIT("social_network_episodes_size_limit"),
GOOGLE_SITE_VERIFICATION_ID("google_site_verification_id"),

// Twitter API
TWITTER_CONSUMER_KEY("twitter_consumer_key"),
TWITTER_CONSUMER_SECRET("twitter_consumer_secret"),
TWITTER_ACCESS_TOKEN("twitter_access_token"),
TWITTER_ACCESS_TOKEN_SECRET("twitter_access_token_secret"),
TWITTER_FIRST_MESSAGE("twitter_first_message"),
TWITTER_SECOND_MESSAGE("twitter_second_message"),

// Threads API
THREADS_APP_ID("threads_app_id"),
THREADS_APP_SECRET("threads_app_secret"),
THREADS_ACCESS_TOKEN("threads_access_token"),
THREADS_FIRST_MESSAGE("threads_first_message"),
THREADS_SECOND_MESSAGE("threads_second_message"),

// Bsky API
SIMULCAST_RANGE_DELAY("simulcast_range_delay"),
ADMIN_EMAIL("admin_email"),
ADDITIONAL_HEAD_TAGS("additional_head_tags"),
ANIMATION_DITIGAL_NETWORK_SIMULCAST_DETECTION_REGEX("animation_digital_network_simulcast_detection_regex"),
ANIME_EPISODES_SIZE_LIMIT("anime_episodes_size_limit"),
AUTHORIZED_DOMAINS("authorized_domains"),
BOT_ADDITIONAL_REGEX("bot_additional_regex"),
BSKY_FIRST_MESSAGE("bsky_first_message"),
BSKY_IDENTIFIER("bsky_identifier"),
BSKY_PASSWORD("bsky_password"),
BSKY_SESSION_TIMEOUT("bsky_session_timeout"),
BSKY_FIRST_MESSAGE("bsky_first_message"),
BSKY_SECOND_MESSAGE("bsky_second_message"),

SIMULCAST_RANGE_DELAY("simulcast_range_delay"),
BSKY_SESSION_TIMEOUT("bsky_session_timeout"),
CHECK_PREVIOUS_AND_NEXT_EPISODES("check_previous_and_next_episodes"),
CHECK_SIMULCAST("check_simulcast"),
CRUNCHYROLL_FETCH_API_SIZE("crunchyroll_fetch_api_size"),
ANIMATION_DITIGAL_NETWORK_SIMULCAST_DETECTION_REGEX("animation_digital_network_simulcast_detection_regex"),
ANIME_EPISODES_SIZE_LIMIT("anime_episodes_size_limit"),
DISABLE_BOT_DETECTION("disable_bot_detection"),
DISCORD_TOKEN("discord_token"),
DISNEY_PLUS_AUTHORIZATION("disney_plus_authorization"),
DISNEY_PLUS_REFRESH_TOKEN("disney_plus_refresh_token"),
LAST_FETCH_OLD_EPISODES("last_fetch_old_episodes"),
FETCH_OLD_EPISODES_RANGE("fetch_old_episodes_range"),
FETCH_OLD_EPISODES_LIMIT("fetch_old_episodes_limit"),
ADMIN_EMAIL("admin_email"),
EMAIL_HOST("email_host"),
EMAIL_PASSWORD("email_password"),
EMAIL_PORT("email_port"),
EMAIL_USERNAME("email_username"),
EMAIL_PASSWORD("email_password"),
USE_SECURITY_HEADERS("use_security_headers"),
UPDATE_EPISODE_DELAY("update_episode_delay"),
UPDATE_EPISODE_SIZE("update_episode_size"),
FETCH_OLD_EPISODES_LIMIT("fetch_old_episodes_limit"),
FETCH_OLD_EPISODES_RANGE("fetch_old_episodes_range"),
GOOGLE_SITE_VERIFICATION_ID("google_site_verification_id"),
LAST_FETCH_OLD_EPISODES("last_fetch_old_episodes"),
PREVIOUS_NEXT_EPISODES_DEPTH("previous_next_episodes_depth"),
SEO_DESCRIPTION("seo_description"),
SOCIAL_NETWORK_EPISODES_SIZE_LIMIT("social_network_episodes_size_limit"),
THREADS_ACCESS_TOKEN("threads_access_token"),
THREADS_APP_ID("threads_app_id"),
THREADS_APP_SECRET("threads_app_secret"),
THREADS_FIRST_MESSAGE("threads_first_message"),
THREADS_SECOND_MESSAGE("threads_second_message"),
TWITTER_ACCESS_TOKEN("twitter_access_token"),
TWITTER_ACCESS_TOKEN_SECRET("twitter_access_token_secret"),
TWITTER_CONSUMER_KEY("twitter_consumer_key"),
TWITTER_CONSUMER_SECRET("twitter_consumer_secret"),
TWITTER_FIRST_MESSAGE("twitter_first_message"),
TWITTER_SECOND_MESSAGE("twitter_second_message"),
UPDATE_ANIME_DELAY("update_anime_delay"),
UPDATE_ANIME_SIZE("update_anime_size"),
CHECK_PREVIOUS_AND_NEXT_EPISODES("check_previous_and_next_episodes"),
PREVIOUS_NEXT_EPISODES_DEPTH("previous_next_episodes_depth"),

AUTHORIZED_DOMAINS("authorized_domains"),
ADDITIONAL_HEAD_TAGS("additional_head_tags"),
BOT_ADDITIONAL_REGEX("bot_additional_regex"),
DISABLE_BOT_DETECTION("disable_bot_detection"),
UPDATE_EPISODE_DELAY("update_episode_delay"),
UPDATE_EPISODE_SIZE("update_episode_size"),
USE_SECURITY_HEADERS("use_security_headers"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AnimationDigitalNetworkPlatform :

api.forEach {
try {
list.addAll(convertEpisode(countryCode, it, zonedDateTime))
list.addAll(convertEpisode(countryCode, it, zonedDateTime, needSimulcast = configCacheService.getValueAsBoolean(ConfigPropertyKey.CHECK_SIMULCAST, true)))
} catch (_: AnimeException) {
// Ignore
} catch (_: NotSimulcastedMediaException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CrunchyrollPlatform : AbstractPlatform<CrunchyrollConfiguration, CountryCo
browseObject: AbstractCrunchyrollWrapper.BrowseObject
) {
try {
list.add(convertEpisode(countryCode, browseObject))
list.add(convertEpisode(countryCode, browseObject, needSimulcast = configCacheService.getValueAsBoolean(ConfigPropertyKey.CHECK_SIMULCAST, true)))
} catch (_: EpisodeException) {
// Ignore
} catch (_: AnimeException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ConfigCacheService : AbstractCacheService {
fun getValueAsBoolean(configPropertyKey: ConfigPropertyKey) =
findByName(configPropertyKey.key)?.propertyValue?.toBoolean() == true

fun getValueAsBoolean(configPropertyKey: ConfigPropertyKey, defaultValue: Boolean) =
findByName(configPropertyKey.key)?.propertyValue?.toBoolean() ?: defaultValue

fun getValueAsStringList(configPropertyKey: ConfigPropertyKey) =
findByName(configPropertyKey.key)?.propertyValue?.split(",") ?: emptyList()
}
22 changes: 22 additions & 0 deletions src/main/resources/db/changelog/2024/12/04-changelog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<property global="false" name="id" value="1735567599275"/>
<property global="false" name="author" value="Ziedelth"/>

<changeSet id="${id}-1" author="${author}" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*)
FROM config
WHERE property_key = 'check_simulcast'</sqlCheck>
</preConditions>

<insert tableName="config">
<column name="uuid" valueComputed="gen_random_uuid()"/>
<column name="property_key" value="check_simulcast"/>
<column name="property_value" value="true"/>
</insert>
</changeSet>
</databaseChangeLog>
1 change: 1 addition & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@
<include file="/db/changelog/2024/12/01-changelog.xml"/>
<include file="/db/changelog/2024/12/02-changelog.xml"/>
<include file="/db/changelog/2024/12/03-changelog.xml"/>
<include file="/db/changelog/2024/12/04-changelog.xml"/>
</databaseChangeLog>

0 comments on commit 53de9d5

Please sign in to comment.