aprikyan / google-books-downloader

An open-source utility to scrape Google Books
MIT License
65 stars 14 forks source link

Invalid input #8

Open liukliukliuk opened 3 years ago

liukliukliuk commented 3 years ago

image

This keeps happening even though I choose valid locations or just enter.

isra00 commented 3 years ago

Same problem here. I have found out that the problem occurs for books whose title contains characters that are invalid for filenames, e.g. a semicolon (which is pretty common in books with a subtitle). The path (new_directory) in step3() should be filtered taking into account the illegal characters in different filesystems (I guess NTFS is the most restrictive). Additionally, error handling might be improved by distinguishing "Bad input" errors from "filesystem errors".

Eddict commented 3 years ago

i solved it like this;

def clean_path(path):
    invalid = '<>:"/\|?* '

    for char in invalid:
        path = path.replace(char, '')

    return path
      new_directory = os.path.join(main_directory, clean_path(book_data))

also in save_backup()

isra00 commented 3 years ago

@Eddict that's great! Could you make it in a pull request so that code can go to upstream? Thank you