saq1b commited on
Commit
dc713f8
·
verified ·
1 Parent(s): e690756

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -4
main.py CHANGED
@@ -6,6 +6,7 @@ import json
6
  import logging
7
  import tempfile
8
  import numpy as np
 
9
 
10
  from pydantic import BaseModel
11
  from typing import List, Optional
@@ -22,6 +23,8 @@ from PIL import Image, ImageDraw
22
  import google.generativeai as genai
23
  from google.generativeai.types import HarmBlockThreshold, HarmCategory
24
 
 
 
25
  # Import your RedDownloader (ensure it’s installed/in your PYTHONPATH)
26
  from RedDownloader import RedDownloader
27
 
@@ -50,8 +53,9 @@ live_log_handler = LiveLogHandler()
50
  live_log_handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
51
  logging.getLogger().addHandler(live_log_handler)
52
 
53
- # Change ImageMagick binary path (adjust as needed)
54
- change_settings({"IMAGEMAGICK_BINARY": r"C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe"})
 
55
 
56
  # Constants and paths
57
  BACKGROUND_IMAGE = "background.png"
@@ -81,7 +85,6 @@ class VideoItem(BaseModel):
81
  thumbnail: Optional[str] = None
82
 
83
  # Limit the number of workers to a reasonable number (e.g., 2 or 4) to avoid overwhelming your system.
84
- from concurrent.futures import ProcessPoolExecutor
85
  process_executor = ProcessPoolExecutor(max_workers=2)
86
 
87
  # ------------------ Helper Functions (largely re‐using your code) ------------------
@@ -387,7 +390,7 @@ async def get_videos():
387
  reddit_video = post.media.get("reddit_video")
388
  if reddit_video and "fallback_url" in reddit_video:
389
  preview_video = reddit_video["fallback_url"]
390
- except Exception as e:
391
  preview_video = None
392
 
393
  video_info = {
 
6
  import logging
7
  import tempfile
8
  import numpy as np
9
+ import platform
10
 
11
  from pydantic import BaseModel
12
  from typing import List, Optional
 
23
  import google.generativeai as genai
24
  from google.generativeai.types import HarmBlockThreshold, HarmCategory
25
 
26
+ from concurrent.futures import ProcessPoolExecutor
27
+
28
  # Import your RedDownloader (ensure it’s installed/in your PYTHONPATH)
29
  from RedDownloader import RedDownloader
30
 
 
53
  live_log_handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
54
  logging.getLogger().addHandler(live_log_handler)
55
 
56
+ if platform.system() == "Windows":
57
+ # Change ImageMagick binary path (adjust as needed)
58
+ change_settings({"IMAGEMAGICK_BINARY": r"C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe"})
59
 
60
  # Constants and paths
61
  BACKGROUND_IMAGE = "background.png"
 
85
  thumbnail: Optional[str] = None
86
 
87
  # Limit the number of workers to a reasonable number (e.g., 2 or 4) to avoid overwhelming your system.
 
88
  process_executor = ProcessPoolExecutor(max_workers=2)
89
 
90
  # ------------------ Helper Functions (largely re‐using your code) ------------------
 
390
  reddit_video = post.media.get("reddit_video")
391
  if reddit_video and "fallback_url" in reddit_video:
392
  preview_video = reddit_video["fallback_url"]
393
+ except Exception:
394
  preview_video = None
395
 
396
  video_info = {