Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>
This commit is contained in:
parent
03d5fbf4c4
commit
b473dbf329
54862
data/channel_cache.json
54862
data/channel_cache.json
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
https://www.youtube.com/@SingKingKaraoke/videos
|
||||
https://www.youtube.com/@karafun/videos
|
||||
https://www.youtube.com/@KaraokeOnVEVO/videos
|
||||
https://www.youtube.com/@StingrayKaraoke/videos
|
||||
https://www.youtube.com/@CCKaraoke/videos
|
||||
https://www.youtube.com/@AtomicKaraoke/videos
|
||||
|
||||
56
data/cleanup_recent_tracking.py
Normal file
56
data/cleanup_recent_tracking.py
Normal file
@ -0,0 +1,56 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from datetime import datetime, time
|
||||
|
||||
def cleanup_recent_tracking(tracking_path="data/songlist_tracking.json", cutoff_time_str="11:00"):
|
||||
"""Remove entries from songlist_tracking.json that were added after the specified time today."""
|
||||
tracking_file = Path(tracking_path)
|
||||
if not tracking_file.exists():
|
||||
print(f"File not found: {tracking_path}")
|
||||
return
|
||||
|
||||
# Parse cutoff time
|
||||
try:
|
||||
cutoff_hour, cutoff_minute = map(int, cutoff_time_str.split(":"))
|
||||
cutoff_time = time(cutoff_hour, cutoff_minute)
|
||||
except ValueError:
|
||||
print(f"Invalid time format: {cutoff_time_str}. Use HH:MM format.")
|
||||
return
|
||||
|
||||
# Load current tracking data
|
||||
with open(tracking_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
print(f"📋 Loaded {len(data)} entries from songlist_tracking.json")
|
||||
print(f"⏰ Removing entries newer than {cutoff_time_str} today...")
|
||||
|
||||
# Find entries to remove
|
||||
entries_to_remove = []
|
||||
for key, entry in data.items():
|
||||
downloaded_at = entry.get('downloaded_at')
|
||||
if downloaded_at:
|
||||
try:
|
||||
# Parse the ISO timestamp
|
||||
dt = datetime.fromisoformat(downloaded_at.replace('Z', '+00:00'))
|
||||
entry_time = dt.time()
|
||||
|
||||
# Check if entry is newer than cutoff time
|
||||
if entry_time > cutoff_time:
|
||||
entries_to_remove.append(key)
|
||||
print(f"🗑️ Will remove: {entry['artist']} - {entry['title']} (downloaded at {entry_time})")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not parse timestamp for {key}: {e}")
|
||||
|
||||
# Remove the entries
|
||||
for key in entries_to_remove:
|
||||
del data[key]
|
||||
|
||||
# Save the cleaned data
|
||||
with open(tracking_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, indent=2, ensure_ascii=False)
|
||||
|
||||
print(f"✅ Removed {len(entries_to_remove)} entries")
|
||||
print(f"📋 {len(data)} entries remaining in songlist_tracking.json")
|
||||
|
||||
if __name__ == "__main__":
|
||||
cleanup_recent_tracking()
|
||||
@ -306,9 +306,18 @@ class KaraokeDownloader:
|
||||
print(f"📥 Downloading {downloaded_count + 1} of {total_to_download} songlist songs...")
|
||||
print(f"🎯 Found on channel: {channel_name}")
|
||||
# Download this song from this channel
|
||||
# Create a shorter, safer filename
|
||||
# Create a shorter, safer filename - do this ONCE and use consistently
|
||||
safe_title = title.replace("(From ", "").replace(")", "").replace(" - ", " ").replace(":", "").replace("'", "").replace('"', "")
|
||||
safe_artist = artist.replace("'", "").replace('"', "")
|
||||
# Remove all Windows-invalid characters
|
||||
invalid_chars = ['?', ':', '*', '"', '<', '>', '|', '/', '\\']
|
||||
for char in invalid_chars:
|
||||
safe_title = safe_title.replace(char, "")
|
||||
safe_artist = safe_artist.replace(char, "")
|
||||
# Also remove any other potentially problematic characters
|
||||
safe_title = safe_title.replace("...", "").replace("..", "").replace(".", "").strip()
|
||||
safe_artist = safe_artist.strip()
|
||||
|
||||
filename = f"{safe_artist} - {safe_title}.mp4"
|
||||
# Limit filename length to avoid Windows path issues
|
||||
if len(filename) > 100:
|
||||
@ -324,10 +333,26 @@ class KaraokeDownloader:
|
||||
"--ignore-errors",
|
||||
"--no-warnings",
|
||||
"-o", str(output_path),
|
||||
"-f", "best", # TEMP: Simplified format for debugging
|
||||
"-f", self.config["download_settings"]["format"],
|
||||
video_url
|
||||
]
|
||||
print(f"🔧 Running command: {' '.join(dlp_cmd)}")
|
||||
print(f"📺 Resolution settings: {self.config.get('download_settings', {}).get('preferred_resolution', 'Unknown')}")
|
||||
print(f"🎬 Format string: {self.config.get('download_settings', {}).get('format', 'Unknown')}")
|
||||
|
||||
# Debug: Show available formats (optional)
|
||||
if self.config.get('debug_show_formats', False):
|
||||
print(f"🔍 Checking available formats for: {video_url}")
|
||||
format_cmd = [
|
||||
str(self.yt_dlp_path),
|
||||
"--list-formats",
|
||||
video_url
|
||||
]
|
||||
try:
|
||||
format_result = subprocess.run(format_cmd, capture_output=True, text=True, timeout=30)
|
||||
print(f"📋 Available formats:\n{format_result.stdout}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not check formats: {e}")
|
||||
try:
|
||||
result = subprocess.run(dlp_cmd, capture_output=True, text=True, check=True)
|
||||
print(f"✅ yt-dlp completed successfully")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user