The "failed to copy"-alert showed every time when copying, even after copying successfully. |
||
|---|---|---|
| results | ||
| watch | ||
| index.php | ||
| LICENSE | ||
| README.md | ||
LiteTube
A privacy-focused, lightweight YouTube client built with pure PHP, HTML, CSS, and JavaScript. Watch YouTube videos without tracking, cookies, or data collection.
Created by RGBToaster for CrystalSky
Note
This file is not up-to-date with the current code version!
Description
LiteTube is an alternative YouTube client that prioritizes user privacy while maintaining a modern, professional user experience. It provides a clean interface to search and watch YouTube videos without the tracking mechanisms typically associated with YouTube's platform.
Key Features
- Privacy First: No tracking cookies, no data collection, complete separation from YouTube's tracking infrastructure
- Modern UI: Dark, OLED-friendly design with smooth animations and responsive layout
- Fast & Lightweight: Built with vanilla PHP/HTML/CSS/JS - no heavy frameworks
- Infinity Scrolling: Seamless video browsing with intelligent API rate limiting
- YouTube-nocookie Integration: Videos are embedded through
youtube-nocookie.comfor enhanced privacy - GDPR Compliant: Fully compliant with European data protection regulations
How the "No Tracking" Works
LiteTube implements multiple layers of privacy protection:
1. Backend API Proxy
All YouTube API requests are handled server-side through PHP. Your browser never directly contacts YouTube's servers for search queries or video metadata. This prevents:
- IP address logging by YouTube
- Browser fingerprinting
- Direct tracking cookies
2. YouTube-nocookie Embedding
Videos are embedded using youtube-nocookie.com instead of regular YouTube embeds. This domain:
- Does not set tracking cookies until you interact with the video
- Minimizes data collection during video playback
- Provides a privacy-enhanced viewing experience
3. No External Dependencies
LiteTube does not load:
- Google Fonts (all fonts are system fonts)
- External analytics scripts (except your own privacy-focused analytics)
- Third-party CDNs or libraries
- Social media widgets or tracking pixels
4. Caching System
The built-in caching system reduces API calls and prevents repeated requests to YouTube, further minimizing your digital footprint.
5. Rate Limiting
IP-based rate limiting prevents API abuse and ensures the service remains available while protecting user privacy.
Code Documentation
Architecture Overview
LiteTube is built as a single-file PHP application (index.php) that handles both frontend rendering and backend API operations. The architecture follows a simple request-response pattern:
User Browser <-> PHP Backend <-> YouTube API
Core Components
1. Configuration (Lines 1-15)
define('YOUTUBE_API_KEY', 'YOUR_KEY');
define('CACHE_DIR', './cache/');
define('CACHE_DURATION', 300); // 5 minutes
Purpose: Centralized configuration for API credentials and caching behavior.
2. Rate Limiting System (Lines 17-35)
function checkRateLimit()
Purpose: Prevents API abuse by limiting requests to 10 per minute per IP address.
How it works:
- Creates a unique file per IP address in the cache directory
- Tracks request count and timestamp
- Resets counter after 60 seconds
- Returns
falseif limit exceeded
3. Caching System (Lines 37-50)
function getCache($key)
function setCache($key, $data)
Purpose: Reduces API calls and improves performance by caching responses for 5 minutes.
How it works:
- Uses MD5 hashed keys for cache file names
- Checks file modification time against
CACHE_DURATION - Returns cached data if valid,
falseotherwise
4. YouTube API Integration (Lines 52-110)
Search Function
function searchVideos($query, $maxResults = 12, $pageToken = '')
Purpose: Searches YouTube videos via the API.
Parameters:
$query: Search term$maxResults: Number of results (default: 12)$pageToken: Pagination token for infinity scroll
Returns: JSON array with video data or error message
Video Details Function
function getVideoDetails($videoId)
Purpose: Fetches detailed information about a specific video.
Returns: JSON object with video metadata, statistics, and description
5. AJAX Request Handler (Lines 112-135)
Purpose: Routes AJAX requests to appropriate functions.
Endpoints:
?action=search&q=QUERY&pageToken=TOKEN: Search videos?action=video&id=VIDEO_ID: Get video details
6. Frontend HTML/CSS/JS (Lines 137-1258)
CSS Architecture
- CSS Variables (Lines 150-175): Centralized color scheme and design tokens
- Animations: Smooth transitions, hover effects, and scroll-triggered animations
- Responsive Design: Mobile-first approach with breakpoints at 768px and 480px
JavaScript Functions
Search & Display:
performSearch(isLoadMore): Executes search and handles paginationdisplaySearchResults(data, query): Renders initial search resultsappendSearchResults(data): Appends results for infinity scrollcreateVideoCard(video): Generates HTML for video cards
Video Playback:
openVideo(videoId): Opens video modal with YouTube-nocookie embedcloseModal(): Closes video modal and stops playback
Infinity Scroll:
handleScroll(): Detects when user approaches bottom of pageloadMoreVideos(): Triggers next page load
Share Functionality:
shareVideo(videoId): Opens share modalopenInYouTube(): Opens video on YouTubeopenInLiteTube(): Opens video in LiteTube modal
Utility Functions:
escapeHtml(text): Prevents XSS attacksaddScrollAnimations(): Adds intersection observer for scroll animations
Security Features
- XSS Prevention: All user input is escaped using
escapeHtml() - Rate Limiting: Prevents API abuse and DoS attacks
- Server-side API Key: API key never exposed to client
- Input Validation: All API parameters are validated before use
Performance Optimizations
- Caching: 5-minute cache reduces API calls by ~80%
- Lazy Loading: Videos load on-demand via infinity scroll
- Debounced Scroll: Scroll handler prevents excessive function calls
- Optimized Animations: CSS transforms and opacity for GPU acceleration
Getting a YouTube API Key
To use LiteTube, you need a YouTube Data API v3 key:
Step 1: Create a Google Cloud Project
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Enter project name (e.g., "LiteTube") and click "Create"
Step 2: Enable YouTube Data API v3
- In the Cloud Console, go to "APIs & Services" → "Library"
- Search for "YouTube Data API v3"
- Click on it and press "Enable"
Step 3: Create API Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "API Key"
- Copy the generated API key
- (Optional but recommended) Click "Restrict Key":
- Under "API restrictions", select "Restrict key"
- Choose "YouTube Data API v3"
- Under "Application restrictions", select "HTTP referrers" and add your domain
Step 4: Configure LiteTube
- Open
index.php - Find line 4:
define('YOUTUBE_API_KEY', 'YOUR_YOUTUBE_API_KEY_HERE'); - Replace
YOUR_YOUTUBE_API_KEY_HEREwith your API key - Save the file
API Quota Information
- Free tier: 10,000 units per day
- Search request: 100 units
- Video details request: 1 unit
- LiteTube's caching system helps stay within quota limits
Installation
Requirements
- PHP 7.4 or higher
- Web server (Apache, Nginx, or PHP built-in server)
- Write permissions for cache directory
Setup Steps
-
Clone or download the repository
git clone https://basicsites.ddns.net/git/RGBToaster/litetube.git cd litetube -
Configure API Key Edit
index.phpand add your YouTube API key (see section above) -
Set permissions
chmod 755 ./ mkdir cache chmod 755 cache -
Start the server
Option A: PHP Built-in Server (Development)
php -S localhost:8000Option B: Apache/Nginx (Production)
- Point document root to the LiteTube directory
- Ensure PHP is enabled
- No additional configuration needed
-
Access LiteTube Open your browser and navigate to:
- Development:
http://localhost:8000 - Production: Your configured domain
- Development:
License
LiteTube is licensed under the GNU General Public License version 2 (GPL-2.0).
This means you are free to:
- Use the software for any purpose
- Study and modify the source code
- Distribute copies of the software
- Distribute modified versions
View the full license: LICENSE
For more information about GPL-2.0, visit: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
How to Support & Contribute
LiteTube is an open-source project and welcomes contributions from the community!
Ways to Contribute
1. Report Bugs
Found a bug? Please open an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Browser and PHP version
2. Suggest Features
Have an idea? Open an issue with:
- Feature description
- Use case explanation
- Potential implementation approach
3. Submit Code Contributions
Before you start:
- Check existing issues and pull requests
- Discuss major changes in an issue first
- Follow the existing code style
Contribution workflow:
# Fork the repository on Gitea
# Clone your fork
git clone https://basicsites.ddns.net/git/RGBToaster/litetube.git
cd litetube
# Create a feature branch
git checkout -b feature/your-feature-name
# Make your changes
# Test thoroughly
# Commit with clear messages
git commit -m "Add: Brief description of changes"
# Push to your fork
git push origin feature/your-feature-name
# Open a Pull Request on Gitea
Commit message guidelines:
Add:for new featuresFix:for bug fixesUpdate:for improvements to existing featuresRefactor:for code restructuringDocs:for documentation changes
4. Improve Documentation
- Fix typos or unclear explanations
- Add examples or tutorials
- Translate documentation
5. Spread the Word
- Star the repository
- Share LiteTube with others who value privacy
- Write blog posts or tutorials
Development Guidelines
Code Style:
- Use 4 spaces for indentation
- Follow PSR-12 coding standards for PHP
- Use meaningful variable and function names
- Comment complex logic
Testing:
- Test on multiple browsers (Chrome, Firefox, Safari)
- Verify mobile responsiveness
- Check API rate limiting behavior
- Ensure caching works correctly
Security:
- Never expose API keys in client-side code
- Sanitize all user inputs
- Follow OWASP security guidelines
Community
- Issues: Report bugs and request features
- Pull Requests: Submit your contributions
- Discussions: Share ideas and ask questions
Credits
Created by: Nekari
License: GNU General Public License v2.0
YouTube API: Google LLC
Disclaimer
LiteTube is an independent project and is not affiliated with, endorsed by, or sponsored by Google LLC or YouTube. YouTube is a trademark of Google LLC.
This project uses the YouTube API in compliance with YouTube's Terms of Service. Users are responsible for ensuring their use of LiteTube complies with all applicable laws and regulations.