Aside from copyright issues, it’s important to think about what you’re undertaking.
For example, if you were to base a screenplay on a book, you’ll definitely need a different format (e.g. information about what the camera sees and where it’s placed) but at least you’d have the benefit of both mediums being linear. Just like a book, a movie has a start, middle, and end.
IF, on the other hand, is about multiple middles and multiple endings. So where do you get the material for that? If Harry accepts the invitation to go to Hogwarts, you’re fine. But what if he tells the owls to buzz off? What if the sorting hat sends Harry to Slytherin? Etcetera, etcetera.
This can leave you holding the bag as you have one story path (from the original material) well-constructed, but now you have to add more story paths of equal quality to what the original author wrote, who, obviously, isn’t you
Furthermore, IF isn’t just about multiple story paths but about game-ifying a story. The player/reader isn’t just passively consuming your story but actively doing something to try to steer the story path one way or another - and if that isn’t fun for the player/reader, your work will fail as a game even if all your story paths’ textual elements are written well.
Not saying it’s impossible to transform an engaging, linear story (book) into a game that’s fun to play (IF), but it is a rather daunting challenge. This is why you need to ask yourself - why am I doing this in IF? What was exciting about the experience of reading the original book that I want to recreate?
Was it examining the clues? Was it solving the crime before the protagonist did? Was it all the colorful and shady characters that you meet? Was it the shock of discovering the unexpected plot twist?
Whatever your answer is, that’s what you’ve got to transform into an interactive and exciting game.