A privacy-focused, lightweight YouTube client built with pure PHP, HTML, CSS, and JavaScript. Watch YouTube videos without tracking, cookies, or data collection. https://lt.basicsites.ddns.net/
Find a file
RGBToaster f3a958bdca
Removed "failed to copy" alert.
The "failed to copy"-alert showed every time when copying, even after copying successfully.
2025-11-19 01:17:59 +01:00
results Updated the the new LiteTube version 2025-11-09 15:45:44 +01:00
watch Removed "failed to copy" alert. 2025-11-19 01:17:59 +01:00
index.php Updated the the new LiteTube version 2025-11-09 15:45:44 +01:00
LICENSE Added index.php, README.md and LICENSE 2025-10-06 00:51:35 +02:00
README.md Changed "Created by" line and added out-of-date info. 2025-11-09 16:03:01 +01:00

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.com for 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 false if 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, false otherwise

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 pagination
  • displaySearchResults(data, query): Renders initial search results
  • appendSearchResults(data): Appends results for infinity scroll
  • createVideoCard(video): Generates HTML for video cards

Video Playback:

  • openVideo(videoId): Opens video modal with YouTube-nocookie embed
  • closeModal(): Closes video modal and stops playback

Infinity Scroll:

  • handleScroll(): Detects when user approaches bottom of page
  • loadMoreVideos(): Triggers next page load

Share Functionality:

  • shareVideo(videoId): Opens share modal
  • openInYouTube(): Opens video on YouTube
  • openInLiteTube(): Opens video in LiteTube modal

Utility Functions:

  • escapeHtml(text): Prevents XSS attacks
  • addScrollAnimations(): Adds intersection observer for scroll animations

Security Features

  1. XSS Prevention: All user input is escaped using escapeHtml()
  2. Rate Limiting: Prevents API abuse and DoS attacks
  3. Server-side API Key: API key never exposed to client
  4. Input Validation: All API parameters are validated before use

Performance Optimizations

  1. Caching: 5-minute cache reduces API calls by ~80%
  2. Lazy Loading: Videos load on-demand via infinity scroll
  3. Debounced Scroll: Scroll handler prevents excessive function calls
  4. 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

  1. Go to Google Cloud Console
  2. Click "Select a project" → "New Project"
  3. Enter project name (e.g., "LiteTube") and click "Create"

Step 2: Enable YouTube Data API v3

  1. In the Cloud Console, go to "APIs & Services" → "Library"
  2. Search for "YouTube Data API v3"
  3. Click on it and press "Enable"

Step 3: Create API Credentials

  1. Go to "APIs & Services" → "Credentials"
  2. Click "Create Credentials" → "API Key"
  3. Copy the generated API key
  4. (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

  1. Open index.php
  2. Find line 4: define('YOUTUBE_API_KEY', 'YOUR_YOUTUBE_API_KEY_HERE');
  3. Replace YOUR_YOUTUBE_API_KEY_HERE with your API key
  4. 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

  1. Clone or download the repository

    git clone https://basicsites.ddns.net/git/RGBToaster/litetube.git
    cd litetube
    
  2. Configure API Key Edit index.php and add your YouTube API key (see section above)

  3. Set permissions

    chmod 755 ./
    mkdir cache
    chmod 755 cache
    
  4. Start the server

    Option A: PHP Built-in Server (Development)

    php -S localhost:8000
    

    Option B: Apache/Nginx (Production)

    • Point document root to the LiteTube directory
    • Ensure PHP is enabled
    • No additional configuration needed
  5. Access LiteTube Open your browser and navigate to:

    • Development: http://localhost:8000
    • Production: Your configured domain

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 features
  • Fix: for bug fixes
  • Update: for improvements to existing features
  • Refactor: for code restructuring
  • Docs: 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.