File size: 3,066 Bytes
34ad4eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

import os

html_path = 'e:/Deepfake/deepfake_detector/templates/index.html'
with open(html_path, 'r', encoding='utf-8') as f:
    content = f.read()

# 1. Update progress messages
content = content.replace('ic=["Preparing image', 'ic=["Preparing media')

# 2. Update onDrop validation to be more robust (accept any video)
# Original: p&&(p.type.startsWith("image/")||p.name.toLowerCase().endsWith(".mp4"))&&a(p)
content = content.replace('p.name.toLowerCase().endsWith(".mp4")', 'p.type.startsWith("video/")')

# 3. Update analyzing state preview
# Original: E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"})
# Note: There are two img tags with almost same props. Let's find them specifically.

# Pattern for analyzing state
# ...children:[E.jsxs("div",{className:"relative aspect-[4/3] overflow-hidden",children:[E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"}),E.jsx("div",{className:"absolute inset-0 bg-charcoal/30"}),...
analyzing_img = 'E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"})'
analyzing_video = '(l?.type.startsWith("video/")?E.jsx("video",{src:a,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0}):E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"}))'
content = content.replace(analyzing_img, analyzing_video)

# 4. Update result state preview
result_img = 'E.jsx("img",{src:a,alt:"Analyzed",className:"w-full h-full object-cover"})'
result_video = '(l?.type.startsWith("video/")?E.jsx("video",{src:a,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0}):E.jsx("img",{src:a,alt:"Analyzed",className:"w-full h-full object-cover"}))'
content = content.replace(result_img, result_video)

# 4.5 Update preview state (Ready for analysis)
preview_img = 'E.jsx("img",{src:a,alt:"Uploaded image",className:"w-full h-full object-cover"})'
preview_video = '(l?.type.startsWith("video/")?E.jsx("video",{src:a,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0}):E.jsx("img",{src:a,alt:"Uploaded image",className:"w-full h-full object-cover"}))'
content = content.replace(preview_img, preview_video)

# 5. Update footer/label text and titles to be more inclusive
content = content.replace('Images, Video (MP4)', 'Images, Video (MP4, MOV, etc.)')
content = content.replace('AI Image Authenticity Detector', 'AI Media Authenticity Detector')
content = content.replace('TrueLens — AI Image', 'TrueLens — AI Media')
content = content.replace('children:"Image uploaded"', 'children:(l?.type.startsWith("video/")?"Video uploaded":"Image uploaded")')
content = content.replace('this image is authentic.', 'this media is authentic.')
content = content.replace('children:"Change Image"', 'children:"Change Media"')

# 6. Update accept attribute
content = content.replace('accept="image/*,video/mp4"', 'accept="image/*,video/mp4,video/quicktime,video/x-msvideo,video/webm,video/*"')

# Write back
with open(html_path, 'w', encoding='utf-8') as f:
    f.write(content)

print("index.html patched successfully.")