The Games tab in PluginStream provides users with access to a curated collection of web-based games. The system features intelligent caching, offline support, and a modern UI with search functionality and featured game highlights.
- Main Fragment:
app/src/main/java/com/lagradost/cloudstream3/ui/game/GameFragment.kt - ViewModel:
app/src/main/java/com/lagradost/cloudstream3/ui/game/GameViewModel.kt - Data Models:
app/src/main/java/com/lagradost/cloudstream3/ui/game/GameModel.kt - Cache Manager:
app/src/main/java/com/lagradost/cloudstream3/ui/game/GameCacheManager.kt - Game Player:
app/src/main/java/com/lagradost/cloudstream3/ui/game/GamePlayerFragment.kt - Adapter:
app/src/main/java/com/lagradost/cloudstream3/ui/game/GameAdapter.kt
- Main Layout:
app/src/main/res/layout/fragment_game.xml - Game Player:
app/src/main/res/layout/fragment_game_player.xml - Game Items:
app/src/main/res/layout/item_game_normal.xml,app/src/main/res/layout/item_game_large.xml - Shimmer:
app/src/main/res/layout/shimmer_game_grid.xml
- Icons:
app/src/main/res/drawable/ic_game_selector.xml,app/src/main/res/drawable/ic_game_placeholder.xml
- Games JSON:
https://cdn.jsdelivr.net/gh/am-abdulmueed/PluginStream-Games@refs/heads/main/psgames.json - GitHub API:
https://api.github.com/repos/am-abdulmueed/PluginStream-Games/commits
data class GameResponse(
val title: String? = null,
val total_count: Int? = null,
val hits: List<GameModel>? = null,
val games: List<GameModel>? = null
)data class GameModel(
val id: String? = null,
val slug: String? = null,
val title: String = "",
val description: String? = null,
val howToPlayText: String? = null,
val gameURL: String = "",
val playgamaGameUrl: String? = null,
val genres: List<String> = emptyList(),
val tags: List<String> = emptyList(),
val images: Any? = null, // List<String>, Map<String, String>, or GameImages
val videos: List<String> = emptyList(),
val mobileReady: List<String> = emptyList(),
val gender: List<String> = emptyList(),
val inGamePurchases: String? = null,
val supportedLanguages: List<String> = emptyList(),
val screenOrientation: ScreenOrientation? = null,
val embed: String? = null,
val isFeatured: Boolean = false,
var isFavorite: Boolean = false
)- Search Bar: Real-time game filtering by title and genres
- Grid Layout: Responsive grid with featured games (every 5th game)
- Shimmer Loading: Skeleton loading animation for better UX
- Offline Support: Shows cached games when offline
- Navigation: Direct link to Offers section
- WebView Integration: Embedded web browser for game playback
- Fullscreen Support: Immersive gaming experience
- Network Detection: Handles online/offline states
- Progress Indicator: Loading states for game initialization
- Featured Games: Large poster cards every 5th game (Premium pattern)
- Normal Games: Compact card layout with icon and title
- Search Functionality: Instant filtering with debounced input
- Empty States: Proper handling for no results and offline scenarios
- Primary URL:
https://cdn.jsdelivr.net/gh/am-abdulmueed/PluginStream-Games@refs/heads/main/psgames.json - Version Control: GitHub API for commit hash checking
- Update Detection: Smart cache invalidation based on file changes
The GameCacheManager implements intelligent caching:
- Local Storage: Games cached in SharedPreferences
- Update Detection: GitHub commit hash comparison
- Offline Support: Works completely offline with cached data
- Auto-Refresh: Updates only when GitHub file changes
KEY_CACHED_GAMES: Main games JSON dataKEY_LAST_COMMIT: Last known GitHub commit hashKEY_CACHE_TIMESTAMP: Cache creation time
- First Launch: Download from GitHub and cache locally
- Subsequent Launches: Check GitHub for updates
- If Updated: Download new data and update cache
- If No Updates: Use cached data immediately
- Offline Mode: Use cached data regardless of updates
- View:
GameFragmenthandles UI and user interactions - ViewModel:
GameViewModelmanages state and business logic - Repository:
GameCacheManagerhandles data persistence and API calls
- LiveData: Reactive UI updates for game list, loading states, and errors
- Coroutines: Asynchronous operations for network calls and caching
- Single Source of Truth: ViewModel maintains the canonical game list
fun filterGames(query: String): List<GameModel> {
val currentGames = _allGames.value ?: emptyList()
if (query.isBlank()) return currentGames
return currentGames.filter { game ->
game.title.contains(query, ignoreCase = true) ||
game.genres.any { it.contains(query, ignoreCase = true) }
}
}GameFragment→GameViewModel.fetchGamesIfNeeded()GameViewModel→GameCacheManager.fetchGamesWithCache()GameCacheManager→ Check cache validity- If needed: Download from GitHub → Cache locally → Return data
- If not needed: Return cached data immediately
- User types in search bar
GameFragment→GameViewModel.filterGames(query)GameViewModel→ Filter cached games locally- Update UI with filtered results instantly
- User clicks on game
- Navigate to
GamePlayerFragmentwith game URL and title GamePlayerFragment→ Initialize WebView with game URL- Load game in fullscreen mode
- GitHub Integration: Automatic update detection via commit hashes
- Offline First: Complete offline functionality with cached data
- Efficient Updates: Only downloads when file actually changes
- Fallback Support: Graceful degradation when network fails
- Instant Loading: Cached data loads immediately
- Background Updates: Checks for updates in background
- Memory Efficient: Uses SharedPreferences for persistence
- Network Optimized: Minimizes unnecessary API calls
// Clear cache (force refresh)
fun clearCache(context: Context)
// Check if cache exists
fun hasCache(context: Context): Boolean
// Get cache information
fun getCacheInfo(context: Context): CacheInfo- Graceful Fallback: Use cached data when network fails
- User Feedback: Show appropriate error messages
- Retry Logic: Automatic retry with exponential backoff
- Loading States: Shimmer animations during data fetch
- Empty States: Proper messaging for no games found
- Offline Mode: Clear indication when working offline
- Cache Clear: Manual cache clearing option for troubleshooting
- Network Detection: Automatic offline mode detection
- Fallback Content: Always show cached games when available
- RecyclerView: Efficient list rendering with view recycling
- Image Loading: Optimized image caching and loading
- Shimmer Effects: Smooth loading animations
- Lazy Loading: Games loaded on demand
- Smart Caching: Minimizes network requests
- Compression: Efficient JSON data transfer
- Background Updates: Non-blocking cache updates
- Connection Reuse: HTTP client optimization
- ViewModel Lifecycle: Proper memory cleanup
- WebView Management: Proper resource cleanup in game player
- Image Optimization: Efficient memory usage for game thumbnails
- Cache Operations: Detailed logging for cache hits/misses
- Network Calls: Request/response logging for debugging
- Error Tracking: Comprehensive error logging
// Get cache info for debugging
val cacheInfo = GameCacheManager.getCacheInfo(context)
Log.d("Games", "Cache exists: ${cacheInfo.hasCache}")
Log.d("Games", "Last update: ${cacheInfo.lastUpdateTimestamp}")
Log.d("Games", "Commit hash: ${cacheInfo.lastCommitHash}")- Premium Layout: Every 5th game gets large poster treatment
- Automatic Detection:
isFeatured = (index + 1) % 5 == 0 - Visual Hierarchy: Featured games stand out in the grid
- Multi-field Search: Searches both titles and genres
- Case Insensitive: User-friendly search experience
- Instant Results: Real-time filtering as user types
- Theme Adaptive: Uses app theme colors and styles
- Responsive Design: Works across different screen sizes
- Material Design: Follows Material Design 3 guidelines
- HTTPS Only: Games loaded over secure connections
- Sandbox Mode: WebView runs in secure sandbox
- Content Security: Proper content security policies
- Local Storage: Games cached in secure SharedPreferences
- Network Security: SSL/TLS for all network communications
- Input Validation: Proper validation of game URLs and data
- Game Launches: Track which games are played most
- Search Queries: Analyze user search patterns
- Cache Performance: Monitor cache hit rates
- Load Times: Track game loading performance
- Network Usage: Monitor data transfer efficiency
- Error Rates: Track and analyze error occurrences
- Game Categories: Advanced filtering by game genres
- Favorites System: User favorite games functionality
- Recent Games: Track recently played games
- Game Statistics: Play time and achievement tracking
- Advanced Caching: More sophisticated cache strategies
- Offline Sync: Background synchronization when online
- Performance Monitoring: Real-time performance metrics
- A/B Testing: Feature experimentation framework
{
"title": "Optimized Games List",
"total_count": 1493,
"hits": [
{
"title": "Fruits into Baskets",
"gameURL": "https://playgama.com/export/game/fruits-into-baskets?clid=p_db0585d2-2da5-4641-b768-657993e9122d",
"genres": ["puzzle", "food", "logic", "easy"],
"images": {
"icon": "https://playgama.com/cdn-cgi/imagedelivery/LN2S-4p3-GgZvEx3IPaKUA/9071a445-5cd8-4965-3bba-3fb1ff08d900/enlarged",
"poster": "https://playgama.com/cdn-cgi/imagedelivery/LN2S-4p3-GgZvEx3IPaKUA/537e972d-b7f4-449a-2795-0c63e717a200/enlarged"
}
}
]
}[
{
"sha": "abc123def456",
"commit": {
"message": "Update games list",
"author": {
"date": "2026-05-08T12:00:00Z"
}
}
}
]This document explains how the game list is optimized using .ps1 (PowerShell) and .bat (Batch) scripts.
To ensure an efficient and up-to-date game list, the following scripts are utilized:
PowerShell scripts are used for more advanced and flexible automation tasks. These scripts typically handle:
- Dynamic Game Detection: Scanning specified directories for new game installations or updates.
- Metadata Extraction: Extracting game names, executable paths, and other relevant information from game files or configuration files.
- API Integration: Potentially interacting with game APIs (if applicable) to fetch additional details, artwork, or update information.
- Data Transformation: Processing and formatting the collected game data into a structured format suitable for the game launcher/application.
- Error Handling and Logging: Providing robust error handling and logging mechanisms to track issues during the optimization process.
Batch scripts are used for simpler, sequential command execution and often act as wrappers or initiators for PowerShell scripts or other executables. Their typical uses include:
- Initiating Optimization: Launching the main PowerShell script or a sequence of scripts to start the optimization process.
- Environment Setup: Setting up necessary environment variables or checking for prerequisites before running more complex scripts.
- Scheduled Tasks: Being scheduled to run at specific intervals (e.g., daily, weekly) to keep the game list optimized automatically.
- Basic File Operations: Performing simple file management tasks like moving, copying, or deleting temporary files generated during the process.
To optimize the game list:
- Navigate to the directory containing the
.ps1and.batscripts. - Run the primary
.batscript (e.g.,optimize_games.bat) or the main.ps1script (e.g.,UpdateGameList.ps1) directly. - The scripts will automatically detect, process, and update the game list.
- Review any logs generated by the scripts for successful completion or error messages.
This setup ensures that your game library remains organized and ready for use with minimal manual intervention.
The games_final_lite.json file is created through an optimization process that transforms raw game data into a lightweight, app-ready format.
- Playgama API: Primary source for game metadata
- Game Directories: Local game installation directories
- Configuration Files: Game settings and metadata files
- Image Assets: Game icons and poster images
# Example PowerShell snippet for data collection
$games = Get-ChildItem -Path $gameDirectory -Recurse -Filter "*.exe"
foreach ($game in $games) {
$metadata = Extract-GameMetadata $game.FullName
$gameList += @{
title = $metadata.Name
gameURL = $metadata.URL
genres = $metadata.Genres
images = @{
icon = $metadata.IconURL
poster = $metadata.PosterURL
}
}
}- Duplicate Removal: Eliminate duplicate game entries
- URL Validation: Ensure all game URLs are accessible
- Image Verification: Check that icon and poster URLs are valid
- Genre Standardization: Normalize genre names to consistent format
- Image Compression: Optimize image URLs for faster loading
- Metadata Trimming: Remove unnecessary fields
- JSON Minification: Reduce file size while maintaining readability
- Cache Optimization: Structure data for efficient caching
The optimized JSON contains only the essential four fields for each game:
{
"title": "Fruits into Baskets",
"gameURL": "https://playgama.com/export/game/fruits-into-baskets?clid=p_db0585d2-2da5-4641-b768-657993e9122d",
"genres": ["puzzle", "food", "logic", "easy"],
"images": {
"icon": "https://playgama.com/cdn-cgi/imagedelivery/LN2S-4p3-GgZvEx3IPaKUA/9071a445-5cd8-4965-3bba-3fb1ff08d900/enlarged",
"poster": "https://playgama.com/cdn-cgi/imagedelivery/LN2S-4p3-GgZvEx3IPaKUA/537e972d-b7f4-449a-2795-0c63e717a200/enlarged"
}
}- Main Script:
PluginStream-Games/UpdateGameList.ps1 - Optimizer:
PluginStream-Games/optimize_games.bat - Raw Data:
PluginStream-Games/games.json - Optimized Output:
PluginStream-Games/games_final_lite.json
- Reduced File Size: Optimized JSON loads faster in the app
- Better Performance: Fewer fields mean quicker parsing
- Consistent Format: Standardized structure across all games
- Easy Maintenance: Automated updates reduce manual work
- Cache Duration: Games are cached until GitHub file changes
- Offline Support: Full offline functionality with cached games
- Featured Pattern: Every 5th game gets featured treatment
- Network Optimization: Smart caching minimizes data usage
- Error Recovery: Graceful fallback to cached data
- Performance: Instant loading with cached data
- Security: All games load in secure WebView sandbox
- Automation: Scripts ensure game list stays current with minimal manual intervention
- Optimization: Lite JSON format reduces app loading time and data usage
Licensed under the MIT License © 2026 Abdul Mueed