Update scripts/generate_playlist.py
Some checks failed
Generate M3U Playlist / build (push) Has been cancelled
Some checks failed
Generate M3U Playlist / build (push) Has been cancelled
This commit is contained in:
parent
f0846208bc
commit
1a0cbed4f1
1 changed files with 22 additions and 25 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/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
|
Enhanced debugging to find why channels.txt is empty
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -8,9 +8,17 @@ import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# Add parent directory to path so we can import from scripts
|
# FIXED: Change to root directory and add scripts to path
|
||||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
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
|
# Import our modular components
|
||||||
from config_manager import ConfigManager
|
from config_manager import ConfigManager
|
||||||
|
@ -51,9 +59,7 @@ def debug_file_system():
|
||||||
files_to_check = [
|
files_to_check = [
|
||||||
'bulk_import.m3u',
|
'bulk_import.m3u',
|
||||||
'channels.txt',
|
'channels.txt',
|
||||||
'playlist.m3u',
|
'playlist.m3u'
|
||||||
'../bulk_import.m3u',
|
|
||||||
'../channels.txt'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for file_path in files_to_check:
|
for file_path in files_to_check:
|
||||||
|
@ -79,7 +85,7 @@ def generate_playlist():
|
||||||
"""Main playlist generation function with enhanced debugging."""
|
"""Main playlist generation function with enhanced debugging."""
|
||||||
try:
|
try:
|
||||||
setup_logging()
|
setup_logging()
|
||||||
logging.info("Starting DEBUG playlist generation...")
|
logging.info("Starting DEBUG playlist generation from ROOT directory...")
|
||||||
|
|
||||||
# Debug file system first
|
# Debug file system first
|
||||||
debug_file_system()
|
debug_file_system()
|
||||||
|
@ -128,14 +134,15 @@ def generate_playlist():
|
||||||
# Step 4: Process imports (THE CRITICAL STEP)
|
# Step 4: Process imports (THE CRITICAL STEP)
|
||||||
logging.info("=== STEP 4: Processing imports ===")
|
logging.info("=== STEP 4: Processing imports ===")
|
||||||
|
|
||||||
# Extra debugging for import process
|
# Manual check for import file in current directory
|
||||||
import_file_paths = ['bulk_import.m3u', '../bulk_import.m3u']
|
if os.path.exists('bulk_import.m3u'):
|
||||||
for path in import_file_paths:
|
logging.info(f"✅ Found bulk_import.m3u in current directory")
|
||||||
if os.path.exists(path):
|
with open('bulk_import.m3u', 'r', encoding='utf-8') as f:
|
||||||
logging.info(f"Found import file at: {path}")
|
content = f.read()
|
||||||
# Temporarily update config to use this path
|
logging.info(f"Import file has {len(content)} characters")
|
||||||
config.import_file = path
|
logging.info(f"Import file first 200 chars: {content[:200]}")
|
||||||
break
|
else:
|
||||||
|
logging.error(f"❌ bulk_import.m3u NOT found in current directory")
|
||||||
|
|
||||||
imported_channels = processor.process_import()
|
imported_channels = processor.process_import()
|
||||||
stats['imported_channels'] = len(imported_channels)
|
stats['imported_channels'] = len(imported_channels)
|
||||||
|
@ -143,16 +150,6 @@ def generate_playlist():
|
||||||
|
|
||||||
if len(imported_channels) == 0:
|
if len(imported_channels) == 0:
|
||||||
logging.warning("NO CHANNELS IMPORTED! This is the problem.")
|
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
|
# Step 5: Load all channels
|
||||||
logging.info("=== STEP 5: Loading all channels ===")
|
logging.info("=== STEP 5: Loading all channels ===")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue