### Get Admin Configuration via API Source: https://context7.com/mtvpls/moontvplus/llms.txt Retrieves the current site configuration settings by sending a GET request to the /api/admin/config endpoint. Requires an authentication token in the Cookie header. ```bash curl -X GET "https://your-domain.com/api/admin/config" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` -------------------------------- ### Storage Adapter Pattern Example (TypeScript) Source: https://context7.com/mtvpls/moontvplus/llms.txt Demonstrates the use of the Storage Adapter pattern with a Redis implementation. It shows how to interact with different storage backends through a unified IStorage interface for operations like saving play records, retrieving all records, and migrating data. It also includes user management with v2 schema. ```typescript // Example: Redis Storage Adapter import { RedisStorage } from '@/lib/redis.db'; import { IStorage, PlayRecord, Favorite } from '@/lib/types'; const storage: IStorage = new RedisStorage(); // All methods return promises await storage.savePlayRecord('user1', 'netflix', 'movie123', { title: 'The Matrix', source_name: 'Netflix', index: 1, time: 0, duration: 8100, save_time: Date.now() }); // Supports batch operations const records = await storage.getAllPlayRecords('user1'); // Handles migrations automatically await storage.migratePlayRecords('user1'); await storage.migrateFavorites('user1'); // User management with v2 schema await storage.createUserV2('alice', 'hashedPass', 'user', ['vip'], null, ['all']); const userInfo = await storage.getUserInfoV2('alice'); // Returns: { role: 'user', banned: false, tags: ['vip'], enabledApis: ['all'], ... } ``` -------------------------------- ### Get Video Details Source: https://context7.com/mtvpls/moontvplus/llms.txt Retrieves detailed information about a specific video including episode lists, metadata, and playback URLs. Supports multiple sources including OpenList, Emby, and standard CMS APIs. ```APIDOC ## GET /api/detail ### Description Retrieves detailed information about a specific video. ### Method GET ### Endpoint /api/detail #### Query Parameters - **id** (string) - Required - The unique identifier of the video. - **source** (string) - Required - The source of the video content. #### Headers - **Cookie** (string) - Required - Authentication token (e.g., `auth=YOUR_AUTH_TOKEN`). ### Response #### Success Response (200) - **source** (string) - The source of the media content. - **source_name** (string) - The name of the content source. - **id** (string) - Unique identifier for the media. - **title** (string) - The title of the media. - **poster** (string) - URL to the media's poster image. - **year** (string) - The release year of the media. - **douban_id** (integer) - The Douban ID of the media, if available. - **desc** (string) - A brief description of the media. - **episodes** (array) - List of playback URLs for episodes. - **episodes_titles** (array) - List of episode titles. - **proxyMode** (boolean) - Indicates if proxy mode is enabled. ### Response Example { "source": "api_site_key", "source_name": "Example Source", "id": "12345", "title": "Breaking Bad", "poster": "https://example.com/poster.jpg", "year": "2008", "douban_id": 0, "desc": "A high school chemistry teacher...", "episodes": [ "https://video-cdn.com/s01e01.m3u8", "https://video-cdn.com/s01e02.m3u8" ], "episodes_titles": ["Pilot", "Cat's in the Bag..."], "proxyMode": false } ``` -------------------------------- ### Storage Adapter Pattern (lib/types & lib/redis.db) Source: https://context7.com/mtvpls/moontvplus/llms.txt Illustrates the use of the Storage Adapter pattern, where different storage backends implement a common `IStorage` interface. ```APIDOC ## Storage Adapter Pattern (lib/types & lib/redis.db) ### Description This pattern ensures a consistent API for data access regardless of the underlying storage technology. The `IStorage` interface defines methods for operations like saving play records, retrieving user info, etc. Concrete implementations (e.g., `RedisStorage`) handle the specifics of interacting with their respective databases. ### Interface (`IStorage`) Defines the contract for all storage adapters, including methods for: - User management (`getUserInfoV2`, `createUserV2`, etc.) - Play record management (`savePlayRecord`, `getAllPlayRecords`, etc.) - Favorite management (`saveFavorite`, `getAllFavorites`, etc.) - Configuration management (`getAdminConfig`, `saveAdminConfig`, etc.) - Migration utilities (`migratePlayRecords`, `migrateFavorites`) ### Example Implementation (`RedisStorage`) ### Example Usage (TypeScript) ```typescript import { RedisStorage } from '@/lib/redis.db'; import { IStorage, PlayRecord, Favorite } from '@/lib/types'; const storage: IStorage = new RedisStorage(); // All methods return promises await storage.savePlayRecord('user1', 'netflix', 'movie123', { title: 'The Matrix', source_name: 'Netflix', index: 1, time: 0, duration: 8100, save_time: Date.now() }); // Supports batch operations const records = await storage.getAllPlayRecords('user1'); // Handles migrations automatically await storage.migratePlayRecords('user1'); await storage.migrateFavorites('user1'); // User management with v2 schema await storage.createUserV2('alice', 'hashedPass', 'user', ['vip'], null, ['all']); const userInfo = await storage.getUserInfoV2('alice'); // Returns: { role: 'user', banned: false, tags: ['vip'], enabledApis: ['all'], ... } ``` ``` -------------------------------- ### Apply Video Upscaling via Anime4K WebGPU Source: https://context7.com/mtvpls/moontvplus/llms.txt Utilizes WebGPU-powered shaders to upscale video content in real-time. Requires browser support for WebGPU and allows dynamic adjustment of scaling and quality modes. ```typescript import { Anime4K } from 'anime4k-webgpu'; const anime4k = new Anime4K({ scale: 2, mode: 'fast', denoise: true, deblur: true }); const videoElement = document.querySelector('video'); await anime4k.attach(videoElement); anime4k.enable(); anime4k.setScale(3); ``` -------------------------------- ### Authenticate User Source: https://context7.com/mtvpls/moontvplus/llms.txt Handles user login by validating credentials against environmental or database stores. Returns a JWT-style token along with refresh tokens for session management. ```bash curl -X POST "https://your-domain.com/api/login" \ -H "Content-Type: application/json" \ -d '{ "username": "admin", "password": "secure_password", "turnstileToken": "optional_turnstile_token" }' ``` -------------------------------- ### Database Manager (lib/db) Source: https://context7.com/mtvpls/moontvplus/llms.txt Provides a unified interface for interacting with various storage backends for user data, play records, favorites, and configurations. ```APIDOC ## Database Operations (lib/db) ### Description This module provides a `db` object that abstracts interactions with different storage backends (e.g., Redis, KVrocks, Upstash, D1, Postgres, LocalStorage). ### Methods #### User Operations - **getUserInfoV2(username)**: Retrieves user information. - **verifyUserV2(username, password)**: Verifies user credentials. - **createUserV2(username, password, role, tags, metadata, enabledApis)**: Creates a new user. - **updateUserV2(username, updates)**: Updates an existing user's properties. #### Play Record Operations - **getPlayRecord(username, source, videoId)**: Retrieves a specific play record. - **savePlayRecord(username, source, videoId, recordDetails)**: Saves or updates a play record. - **getAllPlayRecords(username)**: Retrieves all play records for a user. #### Favorite Operations - **getFavorite(username, source, videoId)**: Retrieves a specific favorite item. - **saveFavorite(username, source, videoId, favoriteDetails)**: Saves or updates a favorite item. - **getAllFavorites(username)**: Retrieves all favorite items for a user. #### Configuration Operations - **getAdminConfig()**: Retrieves the admin configuration. - **saveAdminConfig(config)**: Saves the admin configuration. ### Example Usage (TypeScript) ```typescript import { db } from '@/lib/db'; // User operations const userInfo = await db.getUserInfoV2('username'); const isValid = await db.verifyUserV2('username', 'password'); await db.createUserV2('newuser', 'password', 'user', ['tag1'], undefined, ['api1']); await db.updateUserV2('username', { banned: false, role: 'admin' }); // Play records const playRecord = await db.getPlayRecord('username', 'source', 'videoId'); await db.savePlayRecord('username', 'source', 'videoId', { title: 'Video Title', source_name: 'Source Name', index: 1, time: 123.45, duration: 3600, save_time: Date.now() }); const allRecords = await db.getAllPlayRecords('username'); // Favorites const favorite = await db.getFavorite('username', 'source', 'videoId'); await db.saveFavorite('username', 'source', 'videoId', { title: 'Movie Title', source_name: 'Source', poster: 'https://example.com/poster.jpg', save_time: Date.now() }); const allFavorites = await db.getAllFavorites('username'); // Configuration const config = await db.getAdminConfig(); await db.saveAdminConfig({ SiteConfig: {}, SourceConfig: [] }); ``` ``` -------------------------------- ### Retrieve Video Details Source: https://context7.com/mtvpls/moontvplus/llms.txt Fetches comprehensive metadata for a specific media item, including episode lists and direct playback URLs. Requires a valid source identifier and video ID. ```bash curl -X GET "https://your-domain.com/api/detail?id=12345&source=api_site_key" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` -------------------------------- ### Manage User Favorites Source: https://context7.com/mtvpls/moontvplus/llms.txt Provides CRUD operations for user-specific favorite media. Supports individual key-based retrieval, additions, and deletions with automatic legacy data migration. ```bash # Get all favorites curl -X GET "https://your-domain.com/api/favorites" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" # Add favorite curl -X POST "https://your-domain.com/api/favorites" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "key": "api_site+12345", "favorite": { "title": "Inception", "source_name": "Example Source", "poster": "https://example.com/poster.jpg", "save_time": 1709284800000 } }' # Delete favorite curl -X DELETE "https://your-domain.com/api/favorites?key=api_site%2B12345" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` -------------------------------- ### Admin Configuration Management API Source: https://context7.com/mtvpls/moontvplus/llms.txt Endpoints for retrieving and updating administrative configurations, including site settings, video sources, and custom categories. ```APIDOC ## GET /api/admin/config ### Description Retrieves the current administrative configuration settings for the site. ### Method GET ### Endpoint /api/admin/config ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "https://your-domain.com/api/admin/config" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` ### Response #### Success Response (200) Returns the current configuration object, including site settings, source configurations, and custom categories. #### Response Example ```json { "Role": "owner", "Config": { "SiteConfig": { "DisableYellowFilter": false, "LoginRequireTurnstile": false, "TurnstileSecretKey": "" }, "SourceConfig": [ { "key": "example_source", "api": "https://api.example.com/api.php/provide/vod", "name": "Example Video Source", "weight": 10, "proxyMode": false } ], "CustomCategory": [], "Lives": [], "OpenListConfig": null, "EmbyServers": [] } } ``` ## POST /api/admin/config ### Description Updates the administrative configuration settings for the site. ### Method POST ### Endpoint /api/admin/config ### Parameters #### Query Parameters None #### Request Body - **SiteConfig** (object) - Optional - Site-wide settings. - **DisableYellowFilter** (boolean) - Whether to disable the yellow filter. - **LoginRequireTurnstile** (boolean) - Whether to require Turnstile for login. - **SourceConfig** (array) - Optional - An array of video source configurations. - **key** (string) - Required - Unique key for the source. - **api** (string) - Required - The API endpoint for the source. - **name** (string) - Required - The display name of the source. - **weight** (number) - Optional - The weight or priority of the source. - **proxyMode** (boolean) - Optional - Whether to use proxy mode for the source. - **CustomCategory** (array) - Optional - An array of custom category configurations. - **name** (string) - Required - The name of the category. - **type** (string) - Required - The type of content (e.g., "movie"). - **query** (string) - Required - The query string for the category. ### Request Example ```json { "SiteConfig": { "DisableYellowFilter": false, "LoginRequireTurnstile": false }, "SourceConfig": [ { "key": "example_source", "api": "https://api.example.com/api.php/provide/vod", "name": "Example Video Source", "weight": 10, "proxyMode": false } ], "CustomCategory": [ { "name": "Action Movies", "type": "movie", "query": "action" } ] } ``` ### Response #### Success Response (200) Returns the updated configuration object or a success confirmation. #### Response Example ```json { "Role": "owner", "Config": { "SiteConfig": { "DisableYellowFilter": false, "LoginRequireTurnstile": false, "TurnstileSecretKey": "" }, "SourceConfig": [ { "key": "example_source", "api": "https://api.example.com/api.php/provide/vod", "name": "Example Video Source", "weight": 10, "proxyMode": false } ], "CustomCategory": [], "Lives": [], "OpenListConfig": null, "EmbyServers": [] } } ``` ``` -------------------------------- ### Update Admin Configuration via API Source: https://context7.com/mtvpls/moontvplus/llms.txt Updates the site configuration by sending a POST request to the /api/admin/config endpoint with a JSON payload. Requires an authentication token and specifies new settings for SiteConfig, SourceConfig, and CustomCategory. ```bash curl -X POST "https://your-domain.com/api/admin/config" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ \ "SiteConfig": { \ "DisableYellowFilter": false, \ "LoginRequireTurnstile": false \ }, \ "SourceConfig": [ \ { \ "key": "example_source", \ "api": "https://api.example.com/api.php/provide/vod", \ "name": "Example Video Source", \ "weight": 10, \ "proxyMode": false \ } \ ], \ "CustomCategory": [ \ { \ "name": "Action Movies", \ "type": "movie", \ "query": "action" \ } \ ] \ }' ``` -------------------------------- ### Configure Role-Based Access Control and User Permissions Source: https://context7.com/mtvpls/moontvplus/llms.txt Manages user creation with specific roles (owner, admin, user) and enforces access restrictions on API endpoints based on user roles and status. ```typescript import { db } from '@/lib/db'; await db.createUserV2('owner_user', 'pass123', 'owner'); await db.createUserV2('admin_user', 'pass456', 'admin', ['moderator']); await db.createUserV2('regular_user', 'pass789', 'user', [], undefined, ['source1', 'source2']); const authInfo = getAuthInfoFromCookie(request); if (authInfo.username === process.env.USERNAME) { console.log('Owner authenticated'); } else { const userInfo = await db.getUserInfoV2(authInfo.username); if (userInfo.role === 'admin' && !userInfo.banned) { console.log('Admin authenticated'); } else if (userInfo.role === 'user' && !userInfo.banned) { console.log('User authenticated'); } else { return NextResponse.json({ error: 'Access denied' }, { status: 403 }); } } ``` -------------------------------- ### Integrate ArtPlayer with HLS.js Streaming Source: https://context7.com/mtvpls/moontvplus/llms.txt Initializes the ArtPlayer video player with HLS.js for adaptive streaming support. Includes custom type handling and configuration for external player protocol launching. ```typescript import Artplayer from 'artplayer'; import Hls from 'hls.js'; const player = new Artplayer({ container: '.artplayer-app', url: 'https://example.com/video.m3u8', type: 'm3u8', customType: { m3u8: function(video: HTMLMediaElement, url: string) { if (Hls.isSupported()) { const hls = new Hls({ enableWorker: true, lowLatencyMode: true }); hls.loadSource(url); hls.attachMedia(video); } else if (video.canPlayType('application/vnd.apple.mpegurl')) { video.src = url; } } } }); const externalPlayerUrl = `/api/proxy-m3u8?url=${encodeURIComponent(videoUrl)}&token=${proxyToken}`; window.location.href = `potplayer://${externalPlayerUrl}`; ``` -------------------------------- ### Database Manager Operations (TypeScript) Source: https://context7.com/mtvpls/moontvplus/llms.txt Performs various database operations including user management, saving and retrieving play records and favorites, and managing admin configuration using the DbManager. This library automatically selects the storage backend based on environment variables. ```typescript import { db } from '@/lib/db'; // Automatically uses the storage backend defined in NEXT_PUBLIC_STORAGE_TYPE // Supported: 'redis', 'kvrocks', 'upstash', 'd1', 'postgres', 'localstorage' // User operations const userInfo = await db.getUserInfoV2('username'); const isValid = await db.verifyUserV2('username', 'password'); await db.createUserV2('newuser', 'password', 'user', ['tag1'], undefined, ['api1']); await db.updateUserV2('username', { banned: false, role: 'admin' }); // Play records const playRecord = await db.getPlayRecord('username', 'source', 'videoId'); await db.savePlayRecord('username', 'source', 'videoId', { title: 'Video Title', source_name: 'Source Name', index: 1, time: 123.45, duration: 3600, save_time: Date.now() }); const allRecords = await db.getAllPlayRecords('username'); // Favorites const favorite = await db.getFavorite('username', 'source', 'videoId'); await db.saveFavorite('username', 'source', 'videoId', { title: 'Movie Title', source_name: 'Source', poster: 'https://example.com/poster.jpg', save_time: Date.now() }); const allFavorites = await db.getAllFavorites('username'); // Configuration const config = await db.getAdminConfig(); await db.saveAdminConfig({ SiteConfig: {}, SourceConfig: [] }); ``` -------------------------------- ### Search Media Content via API Source: https://context7.com/mtvpls/moontvplus/llms.txt Performs a multi-source search for video content. It aggregates, filters, and deduplicates results from configured CMS APIs, Emby, and OpenList servers. ```bash curl -X GET "https://your-domain.com/api/search?q=Inception" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` -------------------------------- ### Manage User Favorites Source: https://context7.com/mtvpls/moontvplus/llms.txt Add, retrieve, or delete favorite videos. Supports automatic migration from legacy storage format to new per-user database structure. ```APIDOC ## API for User Favorites ### Description Manages user's favorite videos, allowing for adding, retrieving, and deleting entries. ### Method GET, POST, DELETE ### Endpoint /api/favorites #### Query Parameters (for GET requests) - **key** (string) - Optional - The unique key of a specific favorite to retrieve or delete (e.g., `source+id`). #### Headers - **Cookie** (string) - Required - Authentication token (e.g., `auth=YOUR_AUTH_TOKEN`). #### Request Body (for POST requests) - **key** (string) - Required - The unique key for the favorite (e.g., `api_site+12345`). - **favorite** (object) - Required - The favorite item details. - **title** (string) - The title of the favorite video. - **source_name** (string) - The name of the source providing the video. - **poster** (string) - URL to the video's poster image. - **save_time** (integer) - Timestamp when the item was favorited. ### Response #### Success Response (200 - GET All/Specific) - Returns an object where keys are favorite item keys and values are favorite item details. - **key** (string) - The unique key of the favorite item. - **title** (string) - The title of the favorite video. - **source_name** (string) - The name of the source providing the video. - **poster** (string) - URL to the video's poster image. - **save_time** (integer) - Timestamp when the item was favorited. ### Response Example (GET All/Specific) ```json { "api_site+12345": { "title": "Inception", "source_name": "Example Source", "poster": "https://example.com/poster.jpg", "save_time": 1709284800000 } } ``` ### Response Example (POST/DELETE) - Typically returns the added/deleted favorite item or a success confirmation. ``` -------------------------------- ### User Authentication Source: https://context7.com/mtvpls/moontvplus/llms.txt Authenticates users and issues JWT-style tokens with refresh token support. Supports both owner (environment variable) and database user authentication with optional Turnstile verification. ```APIDOC ## POST /api/login ### Description Authenticates users and issues JWT-style tokens with refresh token support. ### Method POST ### Endpoint /api/login #### Request Body - **username** (string) - Required - The user's username. - **password** (string) - Required - The user's password. - **turnstileToken** (string) - Optional - Turnstile verification token. ### Request Example ```json { "username": "admin", "password": "secure_password", "turnstileToken": "optional_turnstile_token" } ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the login was successful. - **token** (string) - The JWT authentication token. - **auth** (object) - Authentication details. - **username** (string) - The authenticated user's username. - **role** (string) - The user's role (e.g., 'owner'). - **timestamp** (integer) - The timestamp of the authentication. - **tokenId** (string) - The unique ID for the authentication session. - **refreshToken** (string) - The token used for refreshing the JWT. - **refreshExpires** (integer) - The expiration timestamp for the refresh token. ### Response Example ```json { "ok": true, "token": "eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6Im93bmVyIiwidGltZXN0YW1wIjoxNzA5Mjg0ODAwMDAwfQ==", "auth": { "username": "admin", "role": "owner", "timestamp": 1709284800000, "tokenId": "abc123", "refreshToken": "xyz789", "refreshExpires": 1714468800000 } } ``` ``` -------------------------------- ### Implement Token-based Authentication and Refresh Flow in TypeScript Source: https://context7.com/mtvpls/moontvplus/llms.txt Handles middleware-based authentication checks for API routes and manages the lifecycle of refresh tokens. It validates user sessions, roles, and ban status before granting access. ```typescript import { getAuthInfoFromCookie } from '@/lib/auth'; import { generateRefreshToken, storeRefreshToken } from '@/lib/refresh-token'; export async function GET(request: NextRequest) { const authInfo = getAuthInfoFromCookie(request); if (!authInfo || !authInfo.username) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } if (authInfo.role !== 'owner' && authInfo.role !== 'admin') { return NextResponse.json({ error: 'Forbidden' }, { status: 403 }); } const userInfo = await db.getUserInfoV2(authInfo.username); if (userInfo?.banned) { return NextResponse.json({ error: 'User banned' }, { status: 403 }); } return NextResponse.json({ data: 'Success' }); } const tokenId = generateTokenId(); const refreshToken = generateRefreshToken(); await storeRefreshToken('username', tokenId, { token: refreshToken, deviceInfo: 'Chrome on Windows', createdAt: Date.now(), expiresAt: Date.now() + 60 * 24 * 60 * 60 * 1000, lastUsed: Date.now() }); ``` -------------------------------- ### Track Playback Records Source: https://context7.com/mtvpls/moontvplus/llms.txt Retrieves user playback progress. The system automatically enforces record limits per user to maintain data sanity. ```bash curl -X GET "https://your-domain.com/api/playrecords" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` -------------------------------- ### Search for Media Content Source: https://context7.com/mtvpls/moontvplus/llms.txt Aggregates search results from multiple video sources including API sites, Emby servers, and OpenList private libraries. Results are weighted, filtered, and deduplicated before returning to the client. ```APIDOC ## GET /api/search ### Description Aggregates search results from multiple video sources. ### Method GET ### Endpoint /api/search #### Query Parameters - **q** (string) - Required - The search query string. #### Headers - **Cookie** (string) - Required - Authentication token (e.g., `auth=YOUR_AUTH_TOKEN`). ### Response #### Success Response (200) - **results** (array) - A list of search results. - **id** (string) - Unique identifier for the media. - **source** (string) - The source of the media content. - **source_name** (string) - The name of the content source. - **title** (string) - The title of the media. - **poster** (string) - URL to the media's poster image. - **episodes** (array) - List of episode identifiers. - **episodes_titles** (array) - List of episode titles. - **year** (string) - The release year of the media. - **desc** (string) - A brief description of the media. - **douban_id** (integer) - The Douban ID of the media, if available. ### Response Example { "results": [ { "id": "12345", "source": "api_site_key", "source_name": "Example Video Source", "title": "Inception", "poster": "https://example.com/poster.jpg", "episodes": [], "episodes_titles": [], "year": "2010", "desc": "A thief who steals corporate secrets...", "douban_id": 3541415 } ] } ``` -------------------------------- ### Play Record API Source: https://context7.com/mtvpls/moontvplus/llms.txt Endpoints for managing user play records, including saving new records and deleting existing ones. ```APIDOC ## POST /api/playrecords ### Description Saves a user's play record, including details like title, source, playback time, and duration. ### Method POST ### Endpoint /api/playrecords ### Parameters #### Query Parameters None #### Request Body - **key** (string) - Required - Unique identifier for the play record (e.g., "api_site+12345"). - **record** (object) - Required - An object containing the play record details: - **title** (string) - Required - The title of the content. - **source_name** (string) - Required - The name of the source providing the content. - **index** (number) - Required - The index or sequence number of the content. - **time** (number) - Required - The current playback time in seconds. - **duration** (number) - Required - The total duration of the content in seconds. - **save_time** (number) - Required - The timestamp when the record was saved (milliseconds). ### Request Example ```json { "key": "api_site+12345", "record": { "title": "Breaking Bad", "source_name": "Example Source", "index": 5, "time": 1234.5, "duration": 2700, "save_time": 1709284800000 } } ``` ### Response #### Success Response (200) Returns an empty object or a success confirmation upon successful saving. #### Response Example ```json {} ``` ## DELETE /api/playrecords ### Description Deletes a user's play record based on a provided key. ### Method DELETE ### Endpoint /api/playrecords ### Parameters #### Query Parameters - **key** (string) - Required - The unique identifier of the play record to delete (e.g., "api_site+12345"). #### Request Body None ### Request Example ```bash curl -X DELETE "https://your-domain.com/api/playrecords?key=api_site%2B12345" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` ### Response #### Success Response (200) Returns an empty object or a success confirmation upon successful deletion. #### Response Example ```json {} ``` ``` -------------------------------- ### Save Play Record via API Source: https://context7.com/mtvpls/moontvplus/llms.txt Saves a user's play record by sending a POST request to the /api/playrecords endpoint. Requires an authentication token in the Cookie header and a JSON payload containing the record details. ```bash curl -X POST "https://your-domain.com/api/playrecords" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ \ "key": "api_site+12345", \ "record": { \ "title": "Breaking Bad", \ "source_name": "Example Source", \ "index": 5, \ "time": 1234.5, \ "duration": 2700, \ "save_time": 1709284800000 \ } \ }' ``` -------------------------------- ### Track Play Records Source: https://context7.com/mtvpls/moontvplus/llms.txt Save and retrieve video playback progress with automatic cleanup of old records based on MAX_PLAY_RECORDS_PER_USER threshold. ```APIDOC ## GET /api/playrecords ### Description Retrieves a list of video playback records for the authenticated user. ### Method GET ### Endpoint /api/playrecords #### Headers - **Cookie** (string) - Required - Authentication token (e.g., `auth=YOUR_AUTH_TOKEN`). ### Response #### Success Response (200) - Returns an array of playback records. The exact structure of each record is not detailed in the provided text, but it would typically include video identifiers, progress information, and timestamps. ``` -------------------------------- ### Delete Play Record via API Source: https://context7.com/mtvpls/moontvplus/llms.txt Deletes a user's play record by sending a DELETE request to the /api/playrecords endpoint with a key query parameter. Requires an authentication token in the Cookie header. ```bash curl -X DELETE "https://your-domain.com/api/playrecords?key=api_site%2B12345" \ -H "Cookie: auth=YOUR_AUTH_TOKEN" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.