Skip to content

CodeWithRoni/YOUTUBE-DOWNLOADER-PYTHON

Repository files navigation

import os
import json
import base64
import hashlib
import datetime
import uuid

# --- CONFIGURATION ---
# Change this key to something unique for your app to prevent hacking
SECRET_KEY = "ComputerPlus_SecretSalt_2026_Secure" 
APP_NAME = "YouTubeDownloaderPro"
TRIAL_DAYS = 30

class LicenseSystem:
    def __init__(self):
        # Save license in hidden AppData folder (C:\Users\Name\AppData\Roaming\...)
        self.path = os.path.join(os.environ["APPDATA"], APP_NAME, "license.dat")
        self.ensure_folder_exists()

    def ensure_folder_exists(self):
        folder = os.path.dirname(self.path)
        if not os.path.exists(folder):
            os.makedirs(folder)

    def get_hwid(self):
        """ Get unique Hardware ID to lock license to one PC """
        return str(uuid.getnode())

    def generate_hash(self, data_string):
        """ Create a signature so users cannot edit the file manually """
        mixed = data_string + SECRET_KEY + self.get_hwid()
        return hashlib.sha256(mixed.encode()).hexdigest()

    def load_data(self):
        if not os.path.exists(self.path):
            return self.create_fresh_trial()

        try:
            with open(self.path, "r") as f:
                content = f.read()
                decoded = base64.b64decode(content).decode()
                data = json.loads(decoded)

                # Security Check: Verify Hash
                expected_hash = self.generate_hash(f"{data['install_date']}|{data['activated']}")
                if data['signature'] != expected_hash:
                    return self.create_fresh_trial() # File tampered, reset it
                
                return data
        except:
            return self.create_fresh_trial()

    def create_fresh_trial(self):
        data = {
            "install_date": datetime.datetime.now().isoformat(),
            "activated": False,
            "signature": ""
        }
        self.save_data(data)
        return data

    def save_data(self, data):
        data['signature'] = self.generate_hash(f"{data['install_date']}|{data['activated']}")
        json_str = json.dumps(data)
        encoded = base64.b64encode(json_str.encode()).decode()
        with open(self.path, "w") as f:
            f.write(encoded)

    def check_status(self):
        """ Returns: ('FULL', 0) or ('TRIAL', days_left) or ('EXPIRED', 0) """
        data = self.load_data()
        
        if data['activated']:
            return "FULL", 0

        install_date = datetime.datetime.fromisoformat(data['install_date'])
        days_used = (datetime.datetime.now() - install_date).days
        days_left = TRIAL_DAYS - days_used

        if days_left < 0:
            return "EXPIRED", 0
        return "TRIAL", days_left

    def activate_product(self, key):
        # LIST OF VALID KEYS (You can sell these)
        valid_keys = [
            "LIFETIME-USER-001",
            "LIFETIME-USER-002",
            "LIFETIME-USER-003",
            "LIFETIME-USER-004",
            "LIFETIME-USER-005",
            "LIFETIME-USER-006",
            "LIFETIME-USER-007",
            "LIFETIME-USER-008",
            "LIFETIME-USER-009",
            "LIFETIME-USER-0010",
            ]
        
        if key in valid_keys:
            data = self.load_data()
            data['activated'] = True
            self.save_data(data)
            return True
        return False

About

Download YouTube videos instantly with this custom Python tool! πŸš€ Supports high-quality video and audio extraction. Features include playlist downloading, resolution selection, and a simple interface. Perfect for offline viewing and archiving content. Fast, lightweight, and open-source!

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages