Skip to content

Instantly share code, notes, and snippets.

@jericjan
Last active August 18, 2024 05:35
Show Gist options
  • Save jericjan/ef7ec2bfae652d0c731b0134af85783b to your computer and use it in GitHub Desktop.
Save jericjan/ef7ec2bfae652d0c731b0134af85783b to your computer and use it in GitHub Desktop.
script to check if TLMC (alist) fails on a download
from pathlib import Path
found_folders = set()
def check_flac_files(folder: Path):
# Iterate through all files in the folder
for flac_file in folder.rglob("*.*"):
if flac_file.is_file():
try:
# Open the file and check the beginning of the content
with open(flac_file, "rb") as f:
content = f.read(15) # Read the first 15 bytes
if content.startswith(b"<!DOCTYPE html>"):
found_folders.add(flac_file.parent)
except Exception as e:
print(f"Could not read {flac_file}: {e}")
def main():
selected_folder = input("Paste folder path here: ")
if Path(selected_folder).exists():
check_flac_files(Path(selected_folder))
print(f"{len(found_folders)} folders found")
for file in found_folders:
print(f"Has broken files: {file}")
else:
print("Path does not exist")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment