Update app.py
Browse files
app.py
CHANGED
|
@@ -50,7 +50,7 @@ def random_string(n=12):
|
|
| 50 |
return ''.join(random.choices(string.ascii_letters + string.digits, k=n))
|
| 51 |
|
| 52 |
def randomize_video_metadata(file_path):
|
| 53 |
-
"""Randomiza metadados de vídeos de forma
|
| 54 |
mime, _ = mimetypes.guess_type(file_path)
|
| 55 |
if not mime or not mime.startswith("video"):
|
| 56 |
return # não é vídeo
|
|
@@ -64,12 +64,18 @@ def randomize_video_metadata(file_path):
|
|
| 64 |
"description": random_string(20),
|
| 65 |
"encoder": random_string(12),
|
| 66 |
"major_brand": random.choice(["isom", "iso2", "mp41", "mp42", "avc1"]),
|
| 67 |
-
"compatible_brands": random.choice(["isom", "iso2", "
|
| 68 |
"album": random_string(12),
|
| 69 |
"artist": random_string(12)
|
| 70 |
}
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
for k, v in metadata.items():
|
| 74 |
cmd.extend(["-metadata", f"{k}={v}"])
|
| 75 |
cmd.append(temp_path)
|
|
@@ -77,7 +83,7 @@ def randomize_video_metadata(file_path):
|
|
| 77 |
try:
|
| 78 |
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 79 |
os.replace(temp_path, file_path)
|
| 80 |
-
print(f"✅ Metadados HARD
|
| 81 |
except Exception as e:
|
| 82 |
print(f"⚠ Erro ao randomizar {file_path}: {e}")
|
| 83 |
|
|
|
|
| 50 |
return ''.join(random.choices(string.ascii_letters + string.digits, k=n))
|
| 51 |
|
| 52 |
def randomize_video_metadata(file_path):
|
| 53 |
+
"""Randomiza metadados de vídeos de forma HARD (força reescrita completa)"""
|
| 54 |
mime, _ = mimetypes.guess_type(file_path)
|
| 55 |
if not mime or not mime.startswith("video"):
|
| 56 |
return # não é vídeo
|
|
|
|
| 64 |
"description": random_string(20),
|
| 65 |
"encoder": random_string(12),
|
| 66 |
"major_brand": random.choice(["isom", "iso2", "mp41", "mp42", "avc1"]),
|
| 67 |
+
"compatible_brands": random.choice(["isom,iso2", "iso2,mp41", "mp42,isom", "avc1,isom"]),
|
| 68 |
"album": random_string(12),
|
| 69 |
"artist": random_string(12)
|
| 70 |
}
|
| 71 |
|
| 72 |
+
# Reescreve completamente (reencode leve com libx264/aac)
|
| 73 |
+
cmd = [
|
| 74 |
+
"ffmpeg", "-y", "-i", file_path,
|
| 75 |
+
"-c:v", "libx264", "-preset", "fast", "-crf", "23",
|
| 76 |
+
"-c:a", "aac", "-b:a", "128k",
|
| 77 |
+
"-movflags", "use_metadata_tags"
|
| 78 |
+
]
|
| 79 |
for k, v in metadata.items():
|
| 80 |
cmd.extend(["-metadata", f"{k}={v}"])
|
| 81 |
cmd.append(temp_path)
|
|
|
|
| 83 |
try:
|
| 84 |
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 85 |
os.replace(temp_path, file_path)
|
| 86 |
+
print(f"✅ Metadados HARD regravados em {file_path}")
|
| 87 |
except Exception as e:
|
| 88 |
print(f"⚠ Erro ao randomizar {file_path}: {e}")
|
| 89 |
|