Last active
August 18, 2024 05:35
-
-
Save jericjan/ef7ec2bfae652d0c731b0134af85783b to your computer and use it in GitHub Desktop.
script to check if TLMC (alist) fails on a download
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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