Update scripts/generate_playlist.py
All checks were successful
Generate M3U Playlist with Auto-Organization / build-and-organize (push) Successful in 20s
All checks were successful
Generate M3U Playlist with Auto-Organization / build-and-organize (push) Successful in 20s
This commit is contained in:
parent
a84e840798
commit
4dc0866217
1 changed files with 34 additions and 3 deletions
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
IPTV Playlist Generator - Guaranteed Working Version
|
||||
Has enhanced country detection built-in, no complex imports needed
|
||||
IPTV Playlist Generator - Enhanced Country Detection
|
||||
FIXED: Properly handles working directory for Forgejo
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
# FIXED: Ensure we're in the right directory
|
||||
script_dir = Path(__file__).parent
|
||||
root_dir = script_dir.parent
|
||||
|
||||
# Change to root directory where channels.txt should be
|
||||
os.chdir(root_dir)
|
||||
|
||||
def setup_directories():
|
||||
"""Create required directories."""
|
||||
|
@ -101,18 +110,40 @@ def detect_country_enhanced(channel_name, epg_id="", logo_url=""):
|
|||
|
||||
return "🌍 International"
|
||||
|
||||
def debug_current_directory():
|
||||
"""Debug what files are available in current directory."""
|
||||
current_dir = os.getcwd()
|
||||
print(f"🗂️ Current working directory: {current_dir}")
|
||||
|
||||
files = os.listdir('.')
|
||||
print(f"📁 Files in directory: {len(files)} items")
|
||||
|
||||
# Check for our key files
|
||||
key_files = ['channels.txt', 'playlist.m3u', 'bulk_import.m3u']
|
||||
for file in key_files:
|
||||
if os.path.exists(file):
|
||||
size = os.path.getsize(file)
|
||||
print(f"✅ Found {file} ({size} bytes)")
|
||||
else:
|
||||
print(f"❌ Missing {file}")
|
||||
|
||||
def load_channels():
|
||||
"""Load existing channels from channels.txt."""
|
||||
channels = []
|
||||
|
||||
# Debug first
|
||||
debug_current_directory()
|
||||
|
||||
if not os.path.exists('channels.txt'):
|
||||
print("No existing channels.txt found")
|
||||
print("❌ No existing channels.txt found")
|
||||
return channels
|
||||
|
||||
try:
|
||||
with open('channels.txt', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
print(f"📄 channels.txt size: {len(content)} characters")
|
||||
|
||||
blocks = content.split('\n\n')
|
||||
|
||||
for block in blocks:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue