Skip to content

Commit

Permalink
add env var for tmdb metadata language
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzyGrim committed Mar 30, 2024
1 parent 99d63c4 commit e92dbc5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -38,9 +38,10 @@ Alternatively, if you need a PostgreSQL database, you can use the `docker-compos
| Name | Type | Description | Required | Default | Notes |
| --------------- | ------ | ------------------------------ | ----------- | ---------- | --------------------------------------------------------------------------------------------------- |
| TMDB_API | String | The Movie Database API key | Recommended | "61...f60" | Required for movies and tv shows |
| MAL_API | String | MyAnimeList API key | Recommended | "25...691" | Required for anime and manga |
| TMDB_NSFW | Bool | The Movie Database NSFW filter | No | False | Set to true to include adult content in tv and movie searches |
| MAL_NSFW | Bool | MyAnimeList NSFW filter | No | False | Set to true to include adult content in anime and manga searches |
| TMDB_LANG | String | The Movie Database language | No | "en-US" | Language code in ISO 639-1 and country code in ISO 3166-1 |
| MAL_API | String | MyAnimeList API key | Recommended | "25...691" | Required for anime and manga |
| MAL_NSFW | Bool | MyAnimeList NSFW filter | No | False | Set to true to include adult content in anime and manga searches |
| REDIS_URL | String | Redis URL | Recommended | None | Redis is recommended for better performance |
| SECRET | String | Django secret key | Recommended | "secret" | [SECRET_KEY](https://docs.djangoproject.com/en/stable/ref/settings/#secret-key) |
| ALLOWED_HOSTS | List | Base IP / Domain | No | "\*" | Set this to your domain name if exposing to the public |
Expand Down
5 changes: 5 additions & 0 deletions src/app/providers/tmdb.py
Expand Up @@ -15,6 +15,7 @@ def search(media_type, query):
params = {
"api_key": settings.TMDB_API,
"query": query,
"language": settings.TMDB_LANG,
}

if settings.TMDB_NSFW:
Expand Down Expand Up @@ -46,6 +47,7 @@ def movie(media_id):
url = f"{base_url}/movie/{media_id}"
params = {
"api_key": settings.TMDB_API,
"language": settings.TMDB_LANG,
"append_to_response": "recommendations",
}
response = services.api_request("TMDB", "GET", url, params=params)
Expand Down Expand Up @@ -84,6 +86,7 @@ def tv_with_seasons(media_id, season_numbers):
append_text = ",".join([f"season/{season}" for season in season_numbers])
params = {
"api_key": settings.TMDB_API,
"language": settings.TMDB_LANG,
"append_to_response": f"recommendations,{append_text}",
}

Expand Down Expand Up @@ -124,6 +127,7 @@ def tv(media_id):
url = f"{base_url}/tv/{media_id}"
params = {
"api_key": settings.TMDB_API,
"language": settings.TMDB_LANG,
"append_to_response": "recommendations",
}
response = services.api_request("TMDB", "GET", url, params=params)
Expand Down Expand Up @@ -173,6 +177,7 @@ def season(tv_id, season_number):
url = f"{base_url}/tv/{tv_id}/season/{season_number}"
params = {
"api_key": settings.TMDB_API,
"language": settings.TMDB_LANG,
}
response = services.api_request("TMDB", "GET", url, params=params)
data = process_season(response)
Expand Down
5 changes: 3 additions & 2 deletions src/config/settings.py
Expand Up @@ -117,14 +117,14 @@
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": config("REDIS_URL"),
"TIMEOUT": 18000, # 5 hours
"TIMEOUT": 18000, # 5 hours
},
}
else:
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"TIMEOUT": 18000, # 5 hours
"TIMEOUT": 18000, # 5 hours
},
}

Expand Down Expand Up @@ -226,6 +226,7 @@

TMDB_API = config("TMDB_API", default="61572be02f0a068658828f6396aacf60")
TMDB_NSFW = config("TMDB_NSFW", default=False, cast=bool)
TMDB_LANG = config("TMDB_LANG", default="en-US")

MAL_API = config("MAL_API", default="25b5581dafd15b3e7d583bb79e9a1691")
MAL_NSFW = config("MAL_NSFW", default=False, cast=bool)
Expand Down

0 comments on commit e92dbc5

Please sign in to comment.