How to Enable or Disable Content Filtering in LunaTV: A Complete Guide
To enable or disable content filtering in LunaTV, set the DisableYellowFilter boolean flag in your site configuration via the NEXT_PUBLIC_DISABLE_YELLOW_FILTER environment variable or the Admin API endpoint POST /api/admin/site.
LunaTV, an open-source streaming platform maintained by MoonTechLab, implements a "yellow" content filtering system that controls the visibility of search results and suggestions containing specific flagged keywords. This guide explains the exact mechanisms for toggling this filter using environment variables, API calls, and the built-in admin interface.
Understanding the DisableYellowFilter Configuration Flag
LunaTV reads the content filtering state during the configuration build process. In src/lib/config.ts, the SiteConfig object defines the DisableYellowFilter property that determines whether the yellow filter is active:
// src/lib/config.ts – lines 217-219
SiteConfig: {
...
DisableYellowFilter:
process.env.NEXT_PUBLIC_DISABLE_YELLOW_FILTER === 'true',
...
},
When DisableYellowFilter evaluates to true, the filtering system is disabled and all content—including items containing yellow-listed words—is visible. When set to false or undefined, the filter is enabled and yellow-listed content is hidden from search results and suggestions.
Method 1: Toggle Content Filtering via Environment Variables
The most direct way to control content filtering is through the NEXT_PUBLIC_DISABLE_YELLOW_FILTER environment variable. Changes require an application restart to take effect since the configuration is built at startup.
Add the following to your .env file in the project root:
# To disable filtering (show all results including yellow-listed content)
NEXT_PUBLIC_DISABLE_YELLOW_FILTER=true
# To enable filtering (hide yellow-listed content)
NEXT_PUBLIC_DISABLE_YELLOW_FILTER=false
After updating the environment file, restart the LunaTV application to rebuild the SiteConfig with the new filtering preference.
Method 2: Enable or Disable Filtering via the Admin API
For runtime configuration changes without restarting the server, use the Admin API endpoint defined in src/app/api/admin/site/route.ts. This endpoint accepts JSON payloads to update the DisableYellowFilter flag dynamically.
Enable the filter (hide yellow-listed content):
curl -X POST https://your-lunatv.com/api/admin/site \
-H "Content-Type: application/json" \
-d '{"DisableYellowFilter": false}'
Disable the filter (show all content):
curl -X POST https://your-lunatv.com/api/admin/site \
-H "Content-Type: application/json" \
-d '{"DisableYellowFilter": true}'
The web administration interface (Admin → Site Settings) provides a toggle labeled "Disable Yellow Filter" that interfaces with this same API endpoint, offering a graphical alternative to command-line configuration.
Programmatic Implementation Examples
Node.js Configuration Script
For automated deployments or management scripts, implement the API call using Node.js:
import fetch from 'node-fetch';
async function setYellowFilter(enabled) {
const response = await fetch('https://your-lunatv.com/api/admin/site', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ DisableYellowFilter: !enabled })
});
const data = await response.json();
console.log('Filter configuration updated:', data);
}
// Enable content filtering
setYellowFilter(true);
// Disable content filtering
setYellowFilter(false);
React Component for Admin Dashboard
If building a custom settings interface, implement the toggle using React state and the fetch API:
import { useState } from 'react';
export default function ContentFilterToggle() {
const [isDisabled, setIsDisabled] = useState(false);
const toggleFilter = async () => {
await fetch('/api/admin/site', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ DisableYellowFilter: !isDisabled })
});
setIsDisabled(!isDisabled);
};
return (
<button onClick={toggleFilter}>
{isDisabled ? 'Enable' : 'Disable'} Content Filter
</button>
);
}
Key Source Files and Implementation Details
The content filtering system relies on three primary files in the MoonTechLab/LunaTV repository:
-
src/lib/config.ts– Defines theSiteConfig.DisableYellowFilterboolean and initializes it fromprocess.env.NEXT_PUBLIC_DISABLE_YELLOW_FILTERat build time (lines 217-219). -
src/app/api/admin/site/route.ts– Implements the administrative endpoint that persistsDisableYellowFilterchanges to the site configuration database. -
.env.example– Documents the available environment variable options for initial deployment configuration.
Summary
- Environment Variable Method: Set
NEXT_PUBLIC_DISABLE_YELLOW_FILTER=truein.envto disable filtering, orfalseto enable it. Requires application restart. - API Method: POST to
/api/admin/sitewith{"DisableYellowFilter": true}to disable filtering orfalseto enable it. Changes take effect immediately without restart. - UI Method: Use the Admin Dashboard's "Disable Yellow Filter" toggle for graphical configuration.
- Source Location: The flag is defined in
src/lib/config.tsand managed throughsrc/app/api/admin/site/route.ts.
Frequently Asked Questions
What is the yellow filter in LunaTV?
The yellow filter is LunaTV's content moderation system that hides search results and suggestions containing specific flagged keywords from the yellow list. When enabled (the default state when DisableYellowFilter is false), users cannot see content tagged with these restricted terms.
Do I need to restart LunaTV after changing the environment variable?
Yes. Because src/lib/config.ts evaluates process.env.NEXT_PUBLIC_DISABLE_YELLOW_FILTER during the build/startup process, you must restart the Node.js application for environment variable changes to take effect. Runtime updates should use the Admin API instead.
Can I toggle content filtering without restarting the server?
Yes. Use the Admin API endpoint POST /api/admin/site with a JSON body containing the DisableYellowFilter boolean. This updates the persisted configuration immediately without requiring an application restart, making it ideal for production environments.
Where is the DisableYellowFilter setting stored?
The initial value is sourced from the NEXT_PUBLIC_DISABLE_YELLOW_FILTER environment variable during startup. Runtime changes made via the Admin API are stored in LunaTV's site configuration database and override the environment default until the next configuration rebuild.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →