feat: fail task when song did not pass the integrity check

This commit is contained in:
世界观察日志
2025-08-30 23:32:11 +08:00
parent 365fa2f8d3
commit 52ab865100
4 changed files with 18 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
# DO NOT EDIT IT
version = "0.0.2"
version = "0.0.3"
[instance]
url = "127.0.0.1:8080"
@@ -32,6 +32,10 @@ codecAlternative = true
codecPriority = ["alac", "ec3", "ac3", "aac"]
# Encapsulate Atmos(ec-3/ac-3) as M4A and write the song metadata
atmosConventToM4a = true
# If the song integrity check fails, the task will fail and the song will not be saved.
# Due to the possibility of source file corruption, open with caution.
# See more: https://github.com/WorldObservationLog/AppleMusicDecrypt?tab=readme-ov-file#song-did-not-pass-the-integrity-check
failedSongNotPassIntegrityCheck = false
# Follow the Python Format (https://docs.python.org/3/library/string.html#formatstrings)
# Write the audio information to the songNameFormat and playlistSongNameFormat
# Only support alac codec

View File

@@ -5,7 +5,7 @@ from creart import exists_module
from creart.creator import AbstractCreator, CreateTargetInfo
from pydantic import BaseModel
CONFIG_VERSION = "0.0.2"
CONFIG_VERSION = "0.0.3"
class Instance(BaseModel):
@@ -26,6 +26,7 @@ class Download(BaseModel):
codecAlternative: bool = True
codecPriority: list[str] = ["alac", "ec3", "ac3", "aac"]
atmosConventToM4a: bool = True
failedSongNotPassIntegrityCheck: bool = False
audioInfoFormat: str = ""
songNameFormat: str = "{disk}-{tracknum:02d} {title}"
dirPathFormat: str = "downloads/{album_artist}/{album}"

View File

@@ -95,8 +95,11 @@ class RipLogger:
def decrypting(self):
self.logger.info("Decrypting song...")
def failed_integrity(self):
self.logger.warning(f"Song did not pass the integrity check!")
def failed_integrity(self, error_Level: bool):
if error_Level:
self.logger.error(f"Song did not pass the integrity check!")
else:
self.logger.warning(f"Song did not pass the integrity check!")
def saved(self):
self.logger.success("Song saved!")

View File

@@ -72,7 +72,12 @@ async def decrypt_done(adam_id: str):
song = await run_sync(fix_esds_box, task.info.raw, song)
if not await run_sync(check_song_integrity, song):
task.logger.failed_integrity()
if it(Config).download.failedSongNotPassIntegrityCheck:
task.logger.failed_integrity(True)
await task_done(task, Status.FAILED)
return
else:
task.logger.failed_integrity(False)
filename = await run_sync(save, song, codec, task.metadata, task.playlist)
task.logger.saved()