Commit
·
d306e04
1
Parent(s):
1a65920
fixed video download issues
Browse files
backend/gradio_labanmovementanalysis/video_downloader.py
CHANGED
|
@@ -19,14 +19,16 @@ class VideoDownloader:
|
|
| 19 |
# Gradio component compatibility
|
| 20 |
events = {}
|
| 21 |
|
| 22 |
-
def __init__(self, temp_dir: Optional[str] = None):
|
| 23 |
"""
|
| 24 |
Initialize video downloader.
|
| 25 |
|
| 26 |
Args:
|
| 27 |
temp_dir: Directory for temporary files
|
|
|
|
| 28 |
"""
|
| 29 |
self.temp_dir = temp_dir or tempfile.mkdtemp(prefix="laban_video_")
|
|
|
|
| 30 |
self.supported_platforms = {
|
| 31 |
'youtube': self._download_youtube,
|
| 32 |
'vimeo': self._download_vimeo,
|
|
@@ -89,6 +91,8 @@ class VideoDownloader:
|
|
| 89 |
'no_warnings': True,
|
| 90 |
'extract_flat': False,
|
| 91 |
}
|
|
|
|
|
|
|
| 92 |
|
| 93 |
metadata = {}
|
| 94 |
|
|
@@ -128,11 +132,13 @@ class VideoDownloader:
|
|
| 128 |
|
| 129 |
# yt-dlp options
|
| 130 |
ydl_opts = {
|
| 131 |
-
'format': 'best
|
| 132 |
'outtmpl': output_path,
|
| 133 |
'quiet': True,
|
| 134 |
'no_warnings': True,
|
| 135 |
}
|
|
|
|
|
|
|
| 136 |
|
| 137 |
metadata = {}
|
| 138 |
|
|
|
|
| 19 |
# Gradio component compatibility
|
| 20 |
events = {}
|
| 21 |
|
| 22 |
+
def __init__(self, temp_dir: Optional[str] = None, cookies_path: Optional[str] = None):
|
| 23 |
"""
|
| 24 |
Initialize video downloader.
|
| 25 |
|
| 26 |
Args:
|
| 27 |
temp_dir: Directory for temporary files
|
| 28 |
+
cookies_path: Path to cookies.txt for yt-dlp authentication (optional)
|
| 29 |
"""
|
| 30 |
self.temp_dir = temp_dir or tempfile.mkdtemp(prefix="laban_video_")
|
| 31 |
+
self.cookies_path = cookies_path or os.environ.get("LABAN_YT_COOKIES")
|
| 32 |
self.supported_platforms = {
|
| 33 |
'youtube': self._download_youtube,
|
| 34 |
'vimeo': self._download_vimeo,
|
|
|
|
| 91 |
'no_warnings': True,
|
| 92 |
'extract_flat': False,
|
| 93 |
}
|
| 94 |
+
if self.cookies_path:
|
| 95 |
+
ydl_opts['cookiefile'] = self.cookies_path
|
| 96 |
|
| 97 |
metadata = {}
|
| 98 |
|
|
|
|
| 132 |
|
| 133 |
# yt-dlp options
|
| 134 |
ydl_opts = {
|
| 135 |
+
'format': 'best',
|
| 136 |
'outtmpl': output_path,
|
| 137 |
'quiet': True,
|
| 138 |
'no_warnings': True,
|
| 139 |
}
|
| 140 |
+
if self.cookies_path:
|
| 141 |
+
ydl_opts['cookiefile'] = self.cookies_path
|
| 142 |
|
| 143 |
metadata = {}
|
| 144 |
|