import os
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
django.setup()

from core.models import Category, Channel, Video
from django.contrib.auth.models import User

# Create categories
categories = ['Music', 'Gaming', 'Technology', 'Education', 'Entertainment']
for cat_name in categories:
    Category.objects.get_or_create(name=cat_name)

# Create a sample user and channel if none exist
user, created = User.objects.get_or_create(username='admin')
if created:
    user.set_password('admin123')
    user.is_staff = True
    user.is_superuser = True
    user.save()

Channel.objects.get_or_create(
    user=user,
    defaults={
        'name': 'Live Verse Official',
        'handle': '@liveverse',
        'description': 'Welcome to the official Live Verse channel!'
    }
)

print("Seed data created successfully.")
