-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_smart_collection.py
More file actions
83 lines (66 loc) · 2.89 KB
/
Copy pathrun_smart_collection.py
File metadata and controls
83 lines (66 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
"""
Run Smart YouTube Data Collection
Collects diverse video data focusing on different vibes and energy levels
"""
import os
import sys
from pathlib import Path
import json
# Add src to path
sys.path.append(str(Path(__file__).parent / "src"))
def main():
"""Main function"""
print("🎯 Smart YouTube Data Collection")
print("=" * 50)
# Check for API key
api_key = os.getenv('YOUTUBE_API_KEY')
if not api_key:
print("❌ No YouTube API key found!")
print("Please set your API key:")
print("export YOUTUBE_API_KEY='your_api_key_here'")
return
print(f"✅ API Key found: {api_key[:10]}...")
print("\n🚀 Starting smart data collection...")
print("This will collect videos with different vibes and energy levels.")
print("Estimated time: 20-40 minutes\n")
try:
# Import and run the smart collector
from smart_data_collector import SmartYouTubeDataCollector
# Initialize collector
collector = SmartYouTubeDataCollector(api_key)
# Collect diverse data
output_path = "data/diverse_vibe_data.json"
collected_data = collector.collect_diverse_training_data(output_path)
# Create smart training examples
print("\n🔄 Creating vibe-focused training examples...")
training_examples = collector.create_smart_training_examples(collected_data)
# Save training data
with open("data/smart_train_data.json", "w") as f:
json.dump(training_examples, f, indent=2, ensure_ascii=False)
print(f"✅ Created {len(training_examples)} smart training examples")
print(f"💾 Training data saved to: data/smart_train_data.json")
# Show statistics
print("\n📊 Collection Statistics:")
categories = {}
for video in collected_data:
cat = video['category']
categories[cat] = categories.get(cat, 0) + 1
for category, count in categories.items():
print(f" {category.replace('_', ' ').title()}: {count} videos")
print(f"\n🎯 Vibe Categories Collected:")
for category in categories.keys():
vibe_energy = collector._classify_vibe_energy(category)
print(f" {category.replace('_', ' ').title()}: {vibe_energy} energy")
print(f"\n🚀 Next steps:")
print(f" 1. Train your model: python src/train_model.py")
print(f" 2. Test search: python src/search_engine.py")
print(f" 3. Run full demo: python demo.py")
except ImportError as e:
print(f"❌ Import error: {e}")
print("Make sure smart_data_collector.py is in the src/ directory")
except Exception as e:
print(f"❌ Collection failed: {e}")
print("Check the error details above")
if __name__ == "__main__":
main()