Fix for mistake with merge conflicts

pull/1410/head
Simon 3 years ago
parent 45f1a752d6
commit ceb1cff7d0

@ -105,19 +105,19 @@ def make_final_video(
audio_clips.insert(1, AudioFileClip(f"assets/temp/{id}/mp3/postaudio.mp3")) audio_clips.insert(1, AudioFileClip(f"assets/temp/{id}/mp3/postaudio.mp3"))
elif settings.config["settings"]["storymodemethod"] == 1: elif settings.config["settings"]["storymodemethod"] == 1:
audio_clips = [ audio_clips = [
AudioFileClip(f"assets/temp/{id}/mp3/postaudio-{i}.mp3") AudioFileClip(f"assets/temp/{reddit_id}/mp3/postaudio-{i}.mp3")
for i in track( for i in track(
range(number_of_clips + 1), "Collecting the audio files..." range(number_of_clips + 1), "Collecting the audio files..."
) )
] ]
audio_clips.insert(0, AudioFileClip(f"assets/temp/{id}/mp3/title.mp3")) audio_clips.insert(0, AudioFileClip(f"assets/temp/{reddit_id}/mp3/title.mp3"))
else: else:
audio_clips = [ audio_clips = [
AudioFileClip(f"assets/temp/{id}/mp3/{i}.mp3") AudioFileClip(f"assets/temp/{reddit_id}/mp3/{i}.mp3")
for i in range(number_of_clips) for i in range(number_of_clips)
] ]
audio_clips.insert(0, AudioFileClip(f"assets/temp/{id}/mp3/title.mp3")) audio_clips.insert(0, AudioFileClip(f"assets/temp/{reddit_id}/mp3/title.mp3"))
audio_concat = concatenate_audioclips(audio_clips) audio_concat = concatenate_audioclips(audio_clips)
audio_composite = CompositeAudioClip([audio_concat]) audio_composite = CompositeAudioClip([audio_concat])
@ -129,12 +129,12 @@ def make_final_video(
new_transition = ( new_transition = (
0 if transition is None or float(transition) > 2 else float(transition) 0 if transition is None or float(transition) > 2 else float(transition)
) )
screenshow_width = int((W * 90) // 100) screenshot_width = int((W * 90) // 100)
image_clips.insert( image_clips.insert(
0, 0,
ImageClip(f"assets/temp/{reddit_id}/png/title.png") ImageClip(f"assets/temp/{reddit_id}/png/title.png")
.set_duration(audio_clips[0].duration) .set_duration(audio_clips[0].duration)
.resize(width=screenshow_width) .resize(width=screenshot_width)
.set_opacity(new_opacity) .set_opacity(new_opacity)
.crossfadein(new_transition) .crossfadein(new_transition)
.crossfadeout(new_transition), .crossfadeout(new_transition),
@ -143,10 +143,10 @@ def make_final_video(
if settings.config["settings"]["storymodemethod"] == 0: if settings.config["settings"]["storymodemethod"] == 0:
image_clips.insert( image_clips.insert(
1, 1,
ImageClip(f"assets/temp/{id}/png/story_content.png") ImageClip(f"assets/temp/{reddit_id}/png/story_content.png")
.set_duration(audio_clips[1].duration) .set_duration(audio_clips[1].duration)
.set_position("center") .set_position("center")
.resize(width=W - 100) .resize(width=screenshot_width)
.set_opacity(float(opacity)), .set_opacity(float(opacity)),
) )
elif settings.config["settings"]["storymodemethod"] == 1: elif settings.config["settings"]["storymodemethod"] == 1:
@ -154,9 +154,9 @@ def make_final_video(
range(0, number_of_clips + 1), "Collecting the image files..." range(0, number_of_clips + 1), "Collecting the image files..."
): ):
image_clips.append( image_clips.append(
ImageClip(f"assets/temp/{id}/png/img{i}.png") ImageClip(f"assets/temp/{reddit_id}/png/img{i}.png")
.set_duration(audio_clips[i + 1].duration) .set_duration(audio_clips[i + 1].duration)
.resize(width=W - 100) .resize(width=screenshot_width)
.set_opacity(new_opacity) .set_opacity(new_opacity)
# .crossfadein(new_transition) # .crossfadein(new_transition)
# .crossfadeout(new_transition) # .crossfadeout(new_transition)
@ -164,9 +164,9 @@ def make_final_video(
else: else:
for i in range(0, number_of_clips): for i in range(0, number_of_clips):
image_clips.append( image_clips.append(
ImageClip(f"assets/temp/{id}/png/comment_{i}.png") ImageClip(f"assets/temp/{reddit_id}/png/comment_{i}.png")
.set_duration(audio_clips[i + 1].duration) .set_duration(audio_clips[i + 1].duration)
.resize(width=W - 100) .resize(width=screenshot_width)
.set_opacity(new_opacity) .set_opacity(new_opacity)
.crossfadein(new_transition) .crossfadein(new_transition)
.crossfadeout(new_transition) .crossfadeout(new_transition)
@ -216,8 +216,8 @@ def make_final_video(
thumbnail = Image.open(f"assets/backgrounds/{first_image}") thumbnail = Image.open(f"assets/backgrounds/{first_image}")
width, height = thumbnail.size width, height = thumbnail.size
thumbnailSave = create_thumbnail(thumbnail, font_family, font_size, font_color, width, height, title_thumb) thumbnailSave = create_thumbnail(thumbnail, font_family, font_size, font_color, width, height, title_thumb)
thumbnailSave.save(f"./assets/temp/{id}/thumbnail.png") thumbnailSave.save(f"./assets/temp/{reddit_id}/thumbnail.png")
print_substep(f"Thumbnail - Building Thumbnail in assets/temp/{id}/thumbnail.png") print_substep(f"Thumbnail - Building Thumbnail in assets/temp/{reddit_id}/thumbnail.png")
# create a tumbnail for the video # create a tumbnail for the video
settingsbackground = settings.config["settings"]["background"] settingsbackground = settings.config["settings"]["background"]
@ -246,8 +246,8 @@ def make_final_video(
thumbnail = Image.open(f"assets/backgrounds/{first_image}") thumbnail = Image.open(f"assets/backgrounds/{first_image}")
width, height = thumbnail.size width, height = thumbnail.size
thumbnailSave = create_thumbnail(thumbnail, font_family, font_size, font_color, width, height, title_thumb) thumbnailSave = create_thumbnail(thumbnail, font_family, font_size, font_color, width, height, title_thumb)
thumbnailSave.save(f"./assets/temp/{id}/thumbnail.png") thumbnailSave.save(f"./assets/temp/{reddit_id}/thumbnail.png")
print_substep(f"Thumbnail - Building Thumbnail in assets/temp/{id}/thumbnail.png") print_substep(f"Thumbnail - Building Thumbnail in assets/temp/{reddit_id}/thumbnail.png")
# if settings.config["settings"]['background']["background_audio"] and exists(f"assets/backgrounds/background.mp3"): # if settings.config["settings"]['background']["background_audio"] and exists(f"assets/backgrounds/background.mp3"):
# audioclip = mpe.AudioFileClip(f"assets/backgrounds/background.mp3").set_duration(final.duration) # audioclip = mpe.AudioFileClip(f"assets/backgrounds/background.mp3").set_duration(final.duration)
@ -269,6 +269,7 @@ def make_final_video(
audio_bitrate="192k", audio_bitrate="192k",
verbose=False, verbose=False,
threads=multiprocessing.cpu_count(), threads=multiprocessing.cpu_count(),
preset="ultrafast", #TODO debug
) )
ffmpeg_extract_subclip( ffmpeg_extract_subclip(
f"assets/temp/{reddit_id}/temp.mp4", f"assets/temp/{reddit_id}/temp.mp4",

@ -33,14 +33,12 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
# ! Make sure the reddit screenshots folder exists # ! Make sure the reddit screenshots folder exists
Path(f"assets/temp/{reddit_id}/png").mkdir(parents=True, exist_ok=True) Path(f"assets/temp/{reddit_id}/png").mkdir(parents=True, exist_ok=True)
def download(cookie_file, num=None): screenshot_num: int
screenshot_num = num with sync_playwright() as p:
with sync_playwright() as p: print_substep("Launching Headless Browser...")
print_substep("Launching Headless Browser...")
browser = p.chromium.launch() # headless=False #to check for chrome view
context = browser.new_context()
browser = p.chromium.launch() # headless=False #to check for chrome view
context = browser.new_context()
# Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots # Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots
# When the dsf is 1, the width of the screenshot is 600 pixels # When the dsf is 1, the width of the screenshot is 600 pixels
# so we need a dsf such that the width of the screenshot is greater than the final resolution of the video # so we need a dsf such that the width of the screenshot is greater than the final resolution of the video
@ -52,7 +50,11 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
viewport=ViewportSize(width=W, height=H), viewport=ViewportSize(width=W, height=H),
device_scale_factor=dsf, device_scale_factor=dsf,
) )
if settings.config["settings"]["storymodemethod"] == 1:
# for idx,item in enumerate(reddit_object["thread_post"]):
bgcolor = (255, 255, 255, 255)
txtcolor = (0, 0, 0)
imagemaker(theme=bgcolor, reddit_obj=reddit_object, txtclr=txtcolor)
# set the theme and disable non-essential cookies # set the theme and disable non-essential cookies
if settings.config["settings"]["theme"] == "dark": if settings.config["settings"]["theme"] == "dark":
cookie_file = open( cookie_file = open(
@ -104,15 +106,15 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath)
if storymode: if storymode:
page.locator('[data-click-id="text"]').screenshot( page.locator('[data-click-id="text"]').first.screenshot(
path=f"assets/temp/{reddit_id}/png/story_content.png" path=f"assets/temp/{reddit_id}/png/story_content.png"
) )
else: else:
for idx, comment in enumerate( for idx, comment in enumerate(
track( track(
reddit_object["comments"][:screenshot_num], reddit_object["comments"][:screenshot_num],
"Downloading screenshots...", "Downloading screenshots...",
) )
): ):
# Stop if we have reached the screenshot_num # Stop if we have reached the screenshot_num
if idx >= screenshot_num: if idx >= screenshot_num:
@ -147,4 +149,6 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
# close browser instance when we are done using it # close browser instance when we are done using it
browser.close() browser.close()
print_substep("Screenshots downloaded Successfully.", style="bold green") print_substep("Screenshots downloaded Successfully.", style="bold green")
Loading…
Cancel
Save