diff --git a/scripts/generate_playlist.py b/scripts/generate_playlist.py index dc70266..ba3bc0f 100644 --- a/scripts/generate_playlist.py +++ b/scripts/generate_playlist.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -IPTV Playlist Generator - Debug Version +IPTV Playlist Generator - FIXED to run from root directory Enhanced debugging to find why channels.txt is empty """ @@ -8,9 +8,17 @@ import logging import os import sys from datetime import datetime +from pathlib import Path -# Add parent directory to path so we can import from scripts -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +# FIXED: Change to root directory and add scripts to path +script_dir = Path(__file__).parent +root_dir = script_dir.parent + +# Change working directory to root +os.chdir(root_dir) + +# Add scripts directory to Python path +sys.path.insert(0, str(script_dir)) # Import our modular components from config_manager import ConfigManager @@ -51,9 +59,7 @@ def debug_file_system(): files_to_check = [ 'bulk_import.m3u', 'channels.txt', - 'playlist.m3u', - '../bulk_import.m3u', - '../channels.txt' + 'playlist.m3u' ] for file_path in files_to_check: @@ -79,7 +85,7 @@ def generate_playlist(): """Main playlist generation function with enhanced debugging.""" try: setup_logging() - logging.info("Starting DEBUG playlist generation...") + logging.info("Starting DEBUG playlist generation from ROOT directory...") # Debug file system first debug_file_system() @@ -128,14 +134,15 @@ def generate_playlist(): # Step 4: Process imports (THE CRITICAL STEP) logging.info("=== STEP 4: Processing imports ===") - # Extra debugging for import process - import_file_paths = ['bulk_import.m3u', '../bulk_import.m3u'] - for path in import_file_paths: - if os.path.exists(path): - logging.info(f"Found import file at: {path}") - # Temporarily update config to use this path - config.import_file = path - break + # Manual check for import file in current directory + if os.path.exists('bulk_import.m3u'): + logging.info(f"✅ Found bulk_import.m3u in current directory") + with open('bulk_import.m3u', 'r', encoding='utf-8') as f: + content = f.read() + logging.info(f"Import file has {len(content)} characters") + logging.info(f"Import file first 200 chars: {content[:200]}") + else: + logging.error(f"❌ bulk_import.m3u NOT found in current directory") imported_channels = processor.process_import() stats['imported_channels'] = len(imported_channels) @@ -143,16 +150,6 @@ def generate_playlist(): if len(imported_channels) == 0: logging.warning("NO CHANNELS IMPORTED! This is the problem.") - logging.info("Checking import file details...") - - # Manual check of import file - for path in ['bulk_import.m3u', '../bulk_import.m3u']: - if os.path.exists(path): - with open(path, 'r', encoding='utf-8') as f: - content = f.read() - logging.info(f"Import file {path} has {len(content)} characters") - logging.info(f"Import file first 200 chars: {content[:200]}") - break # Step 5: Load all channels logging.info("=== STEP 5: Loading all channels ===")