Kackle commited on
Commit
cd135cb
·
verified ·
1 Parent(s): 20eed7d

metadata for video switch

Browse files
Files changed (1) hide show
  1. video_parser.py +24 -0
video_parser.py CHANGED
@@ -61,6 +61,30 @@ class VideoParser:
61
 
62
  return audio_path
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  def cleanup(self):
65
  """Clean up temporary files"""
66
  import shutil
 
61
 
62
  return audio_path
63
 
64
+ def get_youtube_metadata(self, url: str) -> dict:
65
+ """Extract YouTube video metadata without downloading"""
66
+ try:
67
+ ydl_opts = {
68
+ 'quiet': True,
69
+ 'no_download': True,
70
+ 'extract_flat': False
71
+ }
72
+
73
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
74
+ info = ydl.extract_info(url, download=False)
75
+
76
+ return {
77
+ 'title': info.get('title', 'Unknown'),
78
+ 'description': info.get('description', '')[:500],
79
+ 'duration': info.get('duration', 0),
80
+ 'view_count': info.get('view_count', 0),
81
+ 'upload_date': info.get('upload_date', 'Unknown'),
82
+ 'uploader': info.get('uploader', 'Unknown')
83
+ }
84
+
85
+ except Exception as e:
86
+ return {'error': str(e)}
87
+
88
  def cleanup(self):
89
  """Clean up temporary files"""
90
  import shutil