feat: Add dependency management tools and enhance logging features
- Introduced `check_dependencies.py` to automate dependency checks and provide installation guidance. - Created `install_dependencies.py` for automatic installation of missing dependencies. - Updated `config.json` to include new logging settings for log retention and date-based log file management. - Added `DEPENDENCY_GUIDE.md` and `DEPENDENCY_FIXES_REPORT.md` for comprehensive documentation on dependency management and fixes. - Enhanced logging functionality in `douyin_logging.py` to support date-based log files and automatic cleanup of old logs.
This commit is contained in:
1 parent
2cd81c05a3
commit
1a63852bde
23 files changed
+8784
-902
No files matched your search
@@ -905,6 +905,7 @@ class underlying_operations:
|
||||
if not pic_path or not os.path.exists(pic_path):
|
||||
return ""
|
||||
|
||||
img = None # Initialize img to avoid unbound variable
|
||||
try:
|
||||
img = Image.open(pic_path)
|
||||
img.verify()
|
||||
@@ -912,6 +913,9 @@ class underlying_operations:
|
||||
except (IOError, OSError, UnidentifiedImageError):
|
||||
return ""
|
||||
|
||||
if img is None:
|
||||
return ""
|
||||
|
||||
if change_color in (1, 2):
|
||||
img = img.convert("L")
|
||||
if change_color == 1:
|
||||
@@ -933,6 +937,8 @@ class underlying_operations:
|
||||
|
||||
from PIL import ImageEnhance
|
||||
|
||||
# Initialize img1 to avoid unbound variable
|
||||
img1 = img
|
||||
try:
|
||||
img_sharpened = img.filter(
|
||||
ImageFilter.UnsharpMask(radius=1, percent=150, threshold=3)
|
||||
@@ -941,7 +947,10 @@ class underlying_operations:
|
||||
contrast_factor = 1.25 if max(w, h) < 300 else 1.15
|
||||
img1 = enhancer.enhance(contrast_factor)
|
||||
except Exception:
|
||||
img1 = img.filter(ImageFilter.SHARPEN)
|
||||
try:
|
||||
img1 = img.filter(ImageFilter.SHARPEN)
|
||||
except Exception:
|
||||
img1 = img # Fallback to original image
|
||||
|
||||
img_np = np.array(img1)
|
||||
|
||||
@@ -954,6 +963,8 @@ class underlying_operations:
|
||||
return ""
|
||||
text = self.extract_ocr_content(result)
|
||||
|
||||
# Initialize variables to avoid unbound variable issues
|
||||
img1 = img # img1 is used later, initialize from img
|
||||
img2 = None
|
||||
text2 = None
|
||||
if (not text) and max(w, h) <= 1200:
|
||||
@@ -1000,6 +1011,9 @@ class underlying_operations:
|
||||
try:
|
||||
import douyin_screenshot_manager
|
||||
|
||||
# Ensure img1 is defined before use
|
||||
if "img1" not in locals():
|
||||
img1 = img
|
||||
img_for_attempt = (
|
||||
img2 if (img2 is not None and text2 and text2.strip()) else img1
|
||||
)
|
||||
@@ -1027,6 +1041,9 @@ class underlying_operations:
|
||||
|
||||
success_path = os.path.join(category_dir, f"{picname}_success.png")
|
||||
try:
|
||||
# Ensure img1 is defined before use
|
||||
if "img1" not in locals():
|
||||
img1 = img
|
||||
if img2 is not None and text2 and text2.strip():
|
||||
img_to_save = img2
|
||||
else:
|
||||
@@ -1042,7 +1059,8 @@ class underlying_operations:
|
||||
img_to_save.save(success_path)
|
||||
except Exception:
|
||||
try:
|
||||
img.save(success_path)
|
||||
if img is not None:
|
||||
img.save(success_path)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
@@ -1194,7 +1212,7 @@ class underlying_operations:
|
||||
t = t.translate(trans)
|
||||
return t
|
||||
|
||||
def _parse_seconds(text: str) -> int | None:
|
||||
def _parse_seconds(text: str) -> Optional[int]:
|
||||
t = _norm(text)
|
||||
if not t:
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user