feat: telegram bot + normalize for mobile + nextcloud subcarpetas

This commit is contained in:
Renato
2026-07-02 17:28:39 +02:00
parent 5d8cfde527
commit d9310e904d
3 changed files with 226 additions and 1 deletions
+24 -1
View File
@@ -991,9 +991,25 @@ if __name__ == '__main__':
from concurrent.futures import ThreadPoolExecutor
swears_path = "/home/ren/viral/brainrotinator/assets/swears.txt"
nextcloud_dir = "/home/ren/nextcloud/html/data/renato97/files/viral_clips"
nextcloud_dir = os.environ.get(
"NEXTCLOUD_TARGET",
"/home/ren/nextcloud/html/data/renato97/files/viral_clips"
)
os.makedirs(nextcloud_dir, exist_ok=True)
def normalize_for_mobile(path):
temp = path + ".tmp.mp4"
cmd = [
'ffmpeg', '-y', '-i', path,
'-c:v', 'libx264', '-preset', 'fast', '-crf', '23',
'-pix_fmt', 'yuv420p', '-profile:v', 'high', '-level:v', '4.1',
'-movflags', '+faststart',
'-c:a', 'aac', '-b:a', '128k',
temp
]
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
os.replace(temp, path)
def process_clip(i, clip):
start = clip['start']
end = clip['end']
@@ -1057,6 +1073,13 @@ if __name__ == '__main__':
except Exception as e:
print(f" ⚠️ [Clip {i+1}] Subtitle burn failed: {e}")
# Normalize for mobile
print(f" 📱 [Clip {i+1}] Normalizing for mobile playback...")
try:
normalize_for_mobile(clip_final_path)
except Exception as e:
print(f" ⚠️ [Clip {i+1}] Normalization failed: {e}")
# Copy to Nextcloud
import shutil
nextcloud_dest = os.path.join(nextcloud_dir, clip_filename)