Separate unset and disabled for watch providers

Previously these were covered by the same `""` value for the region.
This led to poor discoverability of the feature, since it was not visible
on the media page until configured.

Now there is a new `UNSET` value for region, which is the default for
the model. When region is `UNSET` the watch provider box is displayed
on the media page, with a message that it is not configured yet. The
user can then go to the prefrences and set a region, or disable the
feature if they don't like it.
This commit is contained in:
Andreas Bro Kolstø
2026-02-17 17:34:09 +01:00
parent 29fdc7c74f
commit 4370176614
7 changed files with 18 additions and 7 deletions

View File

@@ -781,7 +781,7 @@ def watch_provider_regions():
except requests.exceptions.HTTPError as error:
handle_error(error)
data = [("", "No Region")]
data = [("", "Disabled")]
regions = response.get("results", [])
for region in sorted(regions, key=lambda r: r.get("english_name", "")):
key = region.get("iso_3166_1")

View File

@@ -228,6 +228,7 @@ def media_details(request, source, media_type, media_id, title): # noqa: ARG001
"user_medias": user_medias,
"current_instance": current_instance,
"watch_providers": watch_providers,
"watch_provider_region": request.user.watch_provider_region,
}
return render(request, "app/media_details.html", context)
@@ -286,6 +287,7 @@ def season_details(request, source, media_id, title, season_number): # noqa: AR
"watch_providers": tmdb.filter_providers(
season_metadata.get("providers"), request.user.watch_provider_region
),
"watch_provider_region": request.user.watch_provider_region,
}
return render(request, "app/media_details.html", context)

View File

@@ -435,11 +435,18 @@
{# Media Details #}
<h2 class="text-xl font-bold mb-4">Details</h2>
{% if watch_providers is not None %}
{% if watch_provider_region == "UNSET" or watch_providers is not None %}
<div class="bg-[#2a2f35] p-4 rounded-lg my-4">
<h3 class="text-sm font-semibold text-gray-400 mb-2">STREAMING</h3>
<div class="flex flex-wrap items-center gap-2 place-content-evenly">
{% if watch_providers %}
{% if watch_provider_region == "UNSET" %}
{% url 'preferences' as preferences_url %}
<p class="text-sm">
Watch provider region is not configured. Set a region or disable this feature in the
<a href="{{ preferences_url }}"
class="hover:text-indigo-500 hover:underline">preferences</a>.
</p>
{% elif watch_providers %}
{% for provider in watch_providers %}
<img class="size-10 rounded-md"
src="{{ provider.image }}"

View File

@@ -177,7 +177,9 @@
{% include "app/icons/globe.svg" with classes="w-5 h-5 mr-2" %}
<span class="text-sm font-medium">Watch provider region</span>
</div>
<p class="text-xs text-gray-400 ml-7">Choose the region to show watch providers for.</p>
<p class="text-xs text-gray-400 ml-7">
Choose the region to show watch providers for. Setting this to disabled will hide the box from the media page.
</p>
</div>
<select name="watch_provider_region"
class="ml-4 p-2 bg-[#39404b] rounded-md text-white text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-400">

View File

@@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='user',
name='watch_provider_region',
field=models.CharField(default='', help_text='Region to show watch providers for', max_length=5),
field=models.CharField(default='UNSET', help_text='Region to show watch providers for', max_length=5),
),
]

View File

@@ -333,7 +333,7 @@ class User(AbstractUser):
# Watch provider region
watch_provider_region = models.CharField(
max_length=5,
default="",
default="UNSET",
help_text="Region to show watch providers for",
)

View File

@@ -259,7 +259,7 @@ def preferences(request):
if provider_region in [region[0] for region in watch_provider_regions]:
request.user.watch_provider_region = provider_region
else:
request.user.watch_provider_region = ""
request.user.watch_provider_region = "UNSET"
# Update user preferences for each media type
for media_type in media_types: