diff options
| author | Astounds <kirito@disroot.org> | 2026-03-27 20:47:44 -0500 |
|---|---|---|
| committer | Astounds <kirito@disroot.org> | 2026-03-27 20:47:44 -0500 |
| commit | 22c72aa842efa6d1dca3bb95eeb47122537ce12a (patch) | |
| tree | a94cf15bd0d7748db0532f56ddefde1fda74a33d /youtube/ytdlp_integration.py | |
| parent | 56ecd6cb1b461bd3622c669936050fa7e4d83542 (diff) | |
| download | yt-local-22c72aa842efa6d1dca3bb95eeb47122537ce12a.tar.lz yt-local-22c72aa842efa6d1dca3bb95eeb47122537ce12a.tar.xz yt-local-22c72aa842efa6d1dca3bb95eeb47122537ce12a.zip | |
remove yt-dlp, fix captions PO Token issue, fix 429 retry logic
- Remove yt-dlp entirely (modules, routes, settings, dependency)
Was blocking page loads by running synchronously in gevent
- Fix captions: use Android client caption URLs (no PO Token needed)
instead of web timedtext URLs that YouTube now blocks
- Fix 429 retry: fail immediately without Tor (same IP = pointless retry)
Was causing ~27s delays with exponential backoff
- Accept ytdlp_enabled as legacy setting to avoid warning on startup
Diffstat (limited to 'youtube/ytdlp_integration.py')
| -rw-r--r-- | youtube/ytdlp_integration.py | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/youtube/ytdlp_integration.py b/youtube/ytdlp_integration.py deleted file mode 100644 index f520e64..0000000 --- a/youtube/ytdlp_integration.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 -""" -yt-dlp integration wrapper for backward compatibility. - -This module now uses the centralized ytdlp_service for all operations. -""" -import logging -from youtube.ytdlp_service import ( - extract_video_info, - get_language_name, - clear_cache, - get_cache_info, -) - -logger = logging.getLogger(__name__) - - -def extract_video_info_ytdlp(video_id): - """ - Extract video information using yt-dlp (with caching). - - This is a wrapper around ytdlp_service.extract_video_info() - for backward compatibility. - - Args: - video_id: YouTube video ID - - Returns: - Dictionary with audio_tracks, formats, title, duration - """ - logger.debug(f'Extracting video info (legacy API): {video_id}') - - info = extract_video_info(video_id) - - # Convert to legacy format for backward compatibility - return { - 'audio_tracks': info.get('audio_tracks', []), - 'all_audio_formats': info.get('formats', []), - 'formats': info.get('formats', []), - 'title': info.get('title', ''), - 'duration': info.get('duration', 0), - 'error': info.get('error'), - } - - -def get_audio_formats_for_language(video_id, language='en'): - """ - Get available audio formats for a specific language. - - Args: - video_id: YouTube video ID - language: Language code (default: 'en') - - Returns: - List of audio format dicts - """ - info = extract_video_info_ytdlp(video_id) - - if 'error' in info: - logger.warning(f'Cannot get audio formats: {info["error"]}') - return [] - - audio_formats = [] - for track in info.get('audio_tracks', []): - if track['language'] == language: - audio_formats.append(track) - - logger.debug(f'Found {len(audio_formats)} {language} audio formats') - return audio_formats - - -__all__ = [ - 'extract_video_info_ytdlp', - 'get_audio_formats_for_language', - 'get_language_name', - 'clear_cache', - 'get_cache_info', -] |
