yt-dlp
This commit is contained in:
@@ -6,6 +6,9 @@ import settings
|
||||
|
||||
from flask import request
|
||||
import flask
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
import json
|
||||
import gevent
|
||||
@@ -685,6 +688,18 @@ def get_watch_page(video_id=None):
|
||||
pair_sources = source_info['pair_sources']
|
||||
uni_idx, pair_idx = source_info['uni_idx'], source_info['pair_idx']
|
||||
|
||||
# Extract audio tracks using yt-dlp for multi-language support
|
||||
audio_tracks = []
|
||||
try:
|
||||
from youtube import ytdlp_integration
|
||||
ytdlp_info = ytdlp_integration.extract_video_info_ytdlp(video_id)
|
||||
audio_tracks = ytdlp_info.get('audio_tracks', [])
|
||||
if audio_tracks:
|
||||
logger.info(f'Found {len(audio_tracks)} audio tracks for video {video_id}')
|
||||
except Exception as e:
|
||||
logger.warning(f'Failed to extract audio tracks: {e}')
|
||||
audio_tracks = []
|
||||
|
||||
pair_quality = yt_data_extract.deep_get(pair_sources, pair_idx, 'quality')
|
||||
uni_quality = yt_data_extract.deep_get(uni_sources, uni_idx, 'quality')
|
||||
|
||||
@@ -808,7 +823,9 @@ def get_watch_page(video_id=None):
|
||||
'playlist': info['playlist'],
|
||||
'related': info['related_videos'],
|
||||
'playability_error': info['playability_error'],
|
||||
'audio_tracks': audio_tracks,
|
||||
},
|
||||
audio_tracks = audio_tracks,
|
||||
font_family = youtube.font_choices[settings.font], # for embed page
|
||||
**source_info,
|
||||
using_pair_sources = using_pair_sources,
|
||||
@@ -884,3 +901,18 @@ def get_transcript(caption_path):
|
||||
|
||||
return flask.Response(result.encode('utf-8'),
|
||||
mimetype='text/plain;charset=UTF-8')
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# yt-dlp Integration Routes
|
||||
# ============================================================================
|
||||
|
||||
@yt_app.route('/ytl-api/video-with-audio/<video_id>')
|
||||
def proxy_video_with_audio(video_id):
|
||||
"""
|
||||
Proxy para servir video con audio específico usando yt-dlp
|
||||
"""
|
||||
from youtube import ytdlp_proxy
|
||||
audio_lang = request.args.get('lang', 'en')
|
||||
max_quality = int(request.args.get('quality', 720))
|
||||
return ytdlp_proxy.stream_video_with_audio(video_id, audio_lang, max_quality)
|
||||
|
||||
Reference in New Issue
Block a user