Merge with develop branch and no pytube required
This commit is contained in:
1 parent
1f48c53a74
commit
d9ff36b034
5 files changed
+21
-13
No files matched your search
@@ -6,6 +6,7 @@ from os import name
|
||||
from pathlib import Path
|
||||
from subprocess import Popen
|
||||
|
||||
import ffmpeg
|
||||
from prawcore import ResponseException
|
||||
from utils.console import print_substep
|
||||
from reddit.subreddit import get_subreddit_threads
|
||||
@@ -57,7 +58,11 @@ def main(POST_ID=None) -> None:
|
||||
download_background_video(bg_config["video"])
|
||||
download_background_audio(bg_config["audio"])
|
||||
chop_background(bg_config, length, reddit_object)
|
||||
make_final_video(number_of_comments, length, reddit_object, bg_config)
|
||||
try:
|
||||
make_final_video(number_of_comments, length, reddit_object, bg_config)
|
||||
except ffmpeg.Error as e:
|
||||
print(e.stderr.decode("utf8"))
|
||||
exit(1)
|
||||
|
||||
|
||||
def run_many(times) -> None:
|
||||
@@ -131,4 +136,4 @@ if __name__ == "__main__":
|
||||
f"Error: {err} \n"
|
||||
f'Config: {config["settings"]}'
|
||||
)
|
||||
raise err
|
||||
raise err
|
||||
@@ -5,7 +5,6 @@ moviepy==1.0.3
|
||||
playwright==1.23.0
|
||||
praw==7.6.1
|
||||
prawcore~=2.3.0
|
||||
pytube==12.1.0
|
||||
requests==2.28.1
|
||||
rich==13.3.1
|
||||
toml==0.10.2
|
||||
|
||||
@@ -43,11 +43,11 @@ background_thumbnail_font_size = { optional = true, type = "int", default = 96,
|
||||
background_thumbnail_font_color = { optional = true, default = "255,255,255", example = "255,255,255", explanation = "Font color in RGB format for the thumbnail text" }
|
||||
|
||||
[settings.tts]
|
||||
voice_choice = { optional = false, default = "tiktok", options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
|
||||
voice_choice = { optional = false, default = "streamlabspolly", options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
|
||||
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" }
|
||||
streamlabs_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for Streamlabs Polly" }
|
||||
tiktok_voice = { optional = true, default = "en_us_001", example = "en_us_006", explanation = "The voice used for TikTok TTS" }
|
||||
tiktok_sessionid = { optional = true, example = "c76bcc3a7625abcc27b508c7db457ff1", explanation = "TikTok sessionid needed for the TTS API request. Check documentation if you don't know how to obtain it." }
|
||||
tiktok_sessionid = { optional = true, example = "c76bcc3a7625abcc27b508c7db457ff1", explanation = "TikTok sessionid needed if you're using the TikTok TTS. Check documentation if you don't know how to obtain it." }
|
||||
python_voice = { optional = false, default = "1", example = "1", explanation = "The index of the system tts voices (can be downloaded externally, run ptt.py to find value, start from zero)" }
|
||||
py_voice_num = { optional = false, default = "2", example = "2", explanation = "The number of system voices (2 are pre-installed in Windows)" }
|
||||
silence_duration = { optional = true, example = "0.1", explanation = "Time in seconds between TTS comments", default = 0.3, type = "float" }
|
||||
|
||||
@@ -7,7 +7,6 @@ from typing import Any, Tuple,Dict
|
||||
|
||||
from moviepy.editor import VideoFileClip,AudioFileClip
|
||||
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
||||
from pytube import YouTube
|
||||
from pytube.cli import on_progress
|
||||
from utils import settings
|
||||
from utils.console import print_step, print_substep
|
||||
@@ -104,9 +103,18 @@ def download_background_audio(background_config: Tuple[str, str, str]):
|
||||
)
|
||||
print_substep("Downloading the backgrounds audio... please be patient 🙏 ")
|
||||
print_substep(f"Downloading {filename} from {uri}")
|
||||
YouTube(uri, on_progress_callback=on_progress).streams.filter(
|
||||
only_audio=True
|
||||
).first().download("assets/backgrounds/audio", filename=f"{credit}-{filename}")
|
||||
ydl_opts = {
|
||||
'outtmpl': f'./assets/backgrounds/audio/{credit}-{filename}',
|
||||
'format': 'bestaudio/best',
|
||||
'postprocessors': [{
|
||||
'preferredcodec': 'mp3',
|
||||
'preferredquality': '192',
|
||||
}],
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([uri])
|
||||
|
||||
print_substep("Background audio downloaded successfully! 🎉", style="bold green")
|
||||
|
||||
|
||||
|
||||
@@ -398,12 +398,8 @@ def make_final_video(
|
||||
)
|
||||
old_percentage = pbar.n
|
||||
pbar.update(100 - old_percentage)
|
||||
|
||||
pbar.close()
|
||||
|
||||
|
||||
|
||||
|
||||
save_data(subreddit, filename + ".mp4", title, idx, background_config['video'][2])
|
||||
print_step("Removing temporary files 🗑")
|
||||
cleanups = cleanup(reddit_id)
|
||||
|
||||
Reference in new issue
Block a user