Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
53 changes: 53 additions & 0 deletions core/all_download_methods/download_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import os
import sys
from yt_dlp import YoutubeDL
from datetime import datetime

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from config import YTB_RESOLUTION

def download_videos_from_channel(channel_url, start_date, resolution=YTB_RESOLUTION, save_path='D:\\20.my-gptpilot-workspace\\gpt-pilot\\workspace\\vediolingo-web\\YouTube_Videos'):
os.makedirs(save_path, exist_ok=True)

ydl_opts = {
'format': 'bestvideo+bestaudio/best' if resolution == 'best' else f'bestvideo[height<={resolution}]+bestaudio/best[height<={resolution}]',
'outtmpl': f'{save_path}/%(title)s/%(title)s.%(ext)s', # 在以视频名称命名的文件夹中保存视频文件
'noplaylist': True,
'dateafter': start_date.strftime('%Y%m%d'),
'writethumbnail': True,
'postprocessors': [{
'key': 'FFmpegThumbnailsConvertor',
'format': 'jpg',
},
],
'retries': 5,
'socket_timeout': 60,
}

with YoutubeDL(ydl_opts) as ydl:
try:
ydl.download([channel_url])
except Exception as e:
print(f"Error downloading videos: {str(e)}")
return

# Organize thumbnails into folders named after the video titles
for root, dirs, files in os.walk(save_path):
for file in files:
if file.endswith('.jpg'):
video_name = os.path.splitext(file)[0]
video_folder = os.path.join(save_path, video_name)
if not os.path.exists(video_folder):
os.makedirs(video_folder)
os.rename(os.path.join(root, file), os.path.join(video_folder, file))

print(f"Download complete. Videos saved in {save_path}")

if __name__ == '__main__':
channel_url = input('Please enter the URL of the YouTube channel: ')
start_date_str = input('Please enter the start date (YYYY-MM-DD): ')
start_date = datetime.strptime(start_date_str, '%Y-%m-%d')
resolution = input(f'Please enter the desired resolution (360/720/1080/best, default {YTB_RESOLUTION}): ')
resolution = resolution if resolution else YTB_RESOLUTION

download_videos_from_channel(channel_url, start_date, resolution)
44 changes: 44 additions & 0 deletions st_auto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import streamlit as st
from datetime import datetime
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from st_components.i18n import get_localized_string as gls
from core.all_download_methods.download_channel import download_videos_from_channel
from config import YTB_RESOLUTION

def main():
st.set_page_config(page_title="VideoLingo Bulk Download", page_icon="🎥")

st.title(gls("bulk_download_title"))

# Language selection
language_options = ["Chinese", "English", "Auto"]
selected_language = st.selectbox(gls("select_language"), options=language_options)

# YouTube channel URL input
channel_url = st.text_input(gls("enter_channel_url"), placeholder="https://www.youtube.com/channel/...")

# Start date input
start_date = st.date_input(gls("start_date"), datetime.now())

# Resolution selection
resolution_options = ["360", "720", "1080", "best"]
selected_resolution = st.selectbox(gls("select_resolution"), options=resolution_options, index=resolution_options.index(YTB_RESOLUTION))

if st.button(gls("start_download")):
if channel_url:
try:
with st.spinner(gls("downloading_videos")):
save_path = os.path.join('vediolingo-web', 'YouTube_Videos')
download_videos_from_channel(channel_url, start_date, resolution=selected_resolution, save_path=save_path)
st.success(gls("download_complete"))
st.info(f"{gls('videos_saved_in')} {save_path}")
except Exception as e:
st.error(f"{gls('download_error')}: {str(e)}")
else:
st.error(gls("enter_valid_url"))

if __name__ == "__main__":
main()
70 changes: 40 additions & 30 deletions st_components/locales.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ locale,key,value
en_US,app_title,"VideoLingo: Connecting Every Frame Across the World"
zh_CN,app_title,"VideoLingo: 连接世界的每一帧"
en_US,app_description,"Hello, thank you for visiting VideoLingo. This project is currently under construction. If you encounter any issues, please feel free to ask questions on Github or in the QQ group! We will present more features in the near future. Thank you for your understanding!"
zh_CN,app_description,"哈喽,感谢访问 VideoLingo. 目前该项目还在建设中,遇到任何问题可以在 Github 或 QQ 群提问!我们将在不久的未来呈现更多功能,感谢理解!"
zh_CN,app_description,"👏 欢迎来到 VideoLingo. 目前该项目还在建设中,遇到任何问题可以在 Github 或 QQ 群提问!也可以自行查看 Github 本地安装指南~"
en_US,translate_generate_subtitle,"Translate and Generate Subtitles"
zh_CN,translate_generate_subtitle,"翻译并生成字幕"
en_US,text_processing_steps,"This stage includes the following steps:"
zh_CN,text_processing_steps,"该阶段包括以下步骤:"
en_US,step1,"1. Whisper word-level transcription"
zh_CN,step1,"1. Whisper 单词级转录"
en_US,step2,"2. Sentence segmentation using Spacy and Claude"
zh_CN,step2,"2. Spacy 和 Claude 分割句子"
en_US,step1,"1. WhisperX word-level transcription"
zh_CN,step1,"1. 使用 WhisperX 单词级转录"
en_US,step2,"2. Sentence segmentation using NLP and LLM"
zh_CN,step2,"2. 使用 NLP 和 LLM 分割句子"
en_US,step3,"3. Summarization and multi-step translation"
zh_CN,step3,"3. 总结和多步翻译"
zh_CN,step3,"3. 总结提取术语和多步翻译"
en_US,step4,"4. Cutting and aligning long subtitles"
zh_CN,step4,"4. 切割对齐长字幕"
zh_CN,step4,"4. 二次切割长字幕并对齐"
en_US,step5,"5. Generating timeline and subtitles"
zh_CN,step5,"5. 生成时间轴和字幕"
en_US,step6,"6. Merging subtitles into the video"
zh_CN,step6,"6. 将字幕合并到视频中"
zh_CN,step6,"6. 将字幕压制到视频中"
en_US,start_processing_subtitles,"Start Processing Subtitles"
zh_CN,start_processing_subtitles,"开始处理字幕"
en_US,linux_warning,"Currently, merging Chinese subtitles on Linux displays garbled characters. Please download the srt file and process it yourself."
zh_CN,linux_warning,"目前 Linux 下合并中文字幕展示乱码,请下载 srt 文件自行压制处理~"
en_US,subtitle_translation_complete,"Subtitle translation is complete! It's recommended to download the srt file and process it yourself."
zh_CN,subtitle_translation_complete,"字幕翻译已完成! 建议下载 srt 文件自行压制 ~"
zh_CN,subtitle_translation_complete,"字幕翻译已完成! 建议下载 srt 文件自行调整样式压制 ~"
en_US,download_all_subtitles,"Download All Subtitles"
zh_CN,download_all_subtitles,"下载所有字幕"
en_US,archive_to_history,"Archive to 'history'"
Expand All @@ -35,8 +35,8 @@ en_US,audio_processing_steps,"This stage includes the following steps:"
zh_CN,audio_processing_steps,"该阶段包括以下步骤:"
en_US,audio_step1,"1. Generate audio tasks"
zh_CN,audio_step1,"1. 生成音频任务"
en_US,audio_step2,"2. UVR5 noise reduction"
zh_CN,audio_step2,"2. UVR5降噪"
en_US,audio_step2,"2. UVR5 人声分离"
zh_CN,audio_step2,"2. UVR5 人声分离"
en_US,audio_step3,"3. Generate audio"
zh_CN,audio_step3,"3. 生成音频"
en_US,audio_step4,"4. Merge audio into the video"
Expand All @@ -46,7 +46,7 @@ zh_CN,audio_processing_complete_emoji,"配音处理完成!🎇"
en_US,start_audio_processing,"Start Audio Processing"
zh_CN,start_audio_processing,"开始配音处理"
en_US,audio_processing_complete,"Audio processing is complete! You can check the audio files in the `output` folder."
zh_CN,audio_processing_complete,"配音处理已完成! 可以在`output`文件夹下查看音频文件 ~"
zh_CN,audio_processing_complete,"配音处理已完成! 可以在 `output` 文件夹下查看音频文件 ~"
en_US,upload_video,"Upload Video"
zh_CN,upload_video,"上传视频"
en_US,download_or_upload_video,"Download or Upload Video"
Expand All @@ -65,30 +65,16 @@ en_US,base_url_help,"No need to add v1 suffix, it will be automatically appended
zh_CN,base_url_help,"不需要添加 v1 后缀,会自动补充 /v1/chat/completions"
en_US,subtitle_settings,"Transcription and Subtitle Settings"
zh_CN,subtitle_settings,"转录与字幕设置"
en_US,whisper_method,"Whisper Method:"
zh_CN,whisper_method,"Whisper 方法:"
en_US,whisper_method,"WhisperX Method:"
zh_CN,whisper_method,"WhisperX 方法:"
en_US,replicate_api_token,"Replicate API Token:"
zh_CN,replicate_api_token,"Replicate API Token:"
en_US,replicate_api_token_help,"Used for calling whisperX api, get it from: https://replicate.com/account/api-tokens"
zh_CN,replicate_api_token_help,"调用whisperX api用,获取地址:https://replicate.com/account/api-tokens"
en_US,whisper_recognition_language,"Transcription Language:"
zh_CN,whisper_recognition_language,"转录语言:"
en_US,whisper_recognition_language_help,"'auto' for automatic recognition, 'en' for forced English transcription"
zh_CN,whisper_recognition_language_help,"auto 为自动识别,en 为强制转译为英文"
en_US,translation_target_language,"Translation Target Language:"
zh_CN,translation_target_language,"翻译目标语言:"
en_US,translation_target_language_help,"Use natural language description, e.g.: Simplified Chinese, Traditional Chinese, English, Japanese"
zh_CN,translation_target_language_help,"使用自然语言描述即可,如:简体中文,繁体中文,English,日本語"
en_US,subtitle_line_length_settings,"Subtitle Line Length Settings:"
zh_CN,subtitle_line_length_settings,"字幕行长度设置:"
en_US,max_characters_per_line,"Maximum Characters Per Line:"
zh_CN,max_characters_per_line,"单行最大字符数:"
en_US,max_characters_per_line_help,"Maximum number of characters per line of subtitles, calculated based on English. For Chinese, it will be automatically multiplied by 1.75. Default is 75"
zh_CN,max_characters_per_line_help,"每一行字幕的最大字符数,按照英文计算,中文会自动乘以1.75,默认 75"
en_US,translation_length_multiplier,"Translation Length Multiplier:"
zh_CN,translation_length_multiplier,"翻译长度倍数:"
en_US,translation_length_multiplier_help,"Considering the audience, translated subtitles are usually larger than the original language. Default is set to 1.5 times the length"
zh_CN,translation_length_multiplier_help,"考虑到受众,翻译字幕一般比原语言字号大,默认设置为长度上的1.5倍"
en_US,video_resolution,"Video Compression Options:"
zh_CN,video_resolution,"压制视频选项:"
en_US,remember_save_settings,"Remember to click the 'Save' button below"
Expand Down Expand Up @@ -135,8 +121,10 @@ en_US,tts_method,"TTS Method"
zh_CN,tts_method,"TTS 方法"
en_US,openai_voice,"OpenAI Voice"
zh_CN,openai_voice,"OpenAI 语音"
en_US,edge_tts_voice,"Edge TTS Voice"
zh_CN,edge_tts_voice,"Edge TTS 语音"
en_US,fish_tts_api_key,"FishTTS API"
zh_CN,fish_tts_api_key,"FishTTS API"
en_US,fish_tts_character,"FishTTS Character"
zh_CN,fish_tts_character,"FishTTS 角色"
en_US,azure_key,"Azure Key"
zh_CN,azure_key,"Azure 密钥"
en_US,azure_region,"Azure Region"
Expand All @@ -157,3 +145,25 @@ en_US,refer_mode,"Reference Audio Mode"
zh_CN,refer_mode,"参考音频模式"
en_US,delete_dubbing_files,"Delete dubbing files"
zh_CN,delete_dubbing_files,"删除此步配音文件"
en_US,bulk_download_title,"VideoLingo Bulk Download"
zh_CN,bulk_download_title,"VideoLingo 批量下载"
en_US,select_language,"Select Language"
zh_CN,select_language,"选择语言"
en_US,enter_channel_url,"Enter YouTube channel URL:"
zh_CN,enter_channel_url,"输入YouTube频道URL:"
en_US,start_date,"Start Date"
zh_CN,start_date,"开始日期"
en_US,select_resolution,"Select Resolution"
zh_CN,select_resolution,"选择分辨率"
en_US,start_download,"Start Download"
zh_CN,start_download,"开始下载"
en_US,downloading_videos,"Downloading videos..."
zh_CN,downloading_videos,"正在下载视频..."
en_US,download_complete,"Download complete"
zh_CN,download_complete,"下载完成"
en_US,videos_saved_in,"Videos saved in"
zh_CN,videos_saved_in,"视频保存在"
en_US,download_error,"Download error"
zh_CN,download_error,"下载错误"
en_US,enter_valid_url,"Please enter a valid URL"
zh_CN,enter_valid_url,"请输入有效的URL"