So I’ve read that 部 is used for machines, films and literature. So does that mean I can use 部 for words like 书，词典, etc even though they usually go with 本？
The answer is sometimes.
The reference to literature does not refer to physical books, but to works of literature. E.g.
(The) twelve greatest 21st century novels chosen by the BBC
The case with 字典 and 詞典 is different, as it can refer to the "work" or to the "book".
The first (character) dictionary in China, the Shuowen Jiezi
Note that poetry collection 詩集 can also be used in this way, although individual poems not so.
書 wouldn't go with 部 - it doesn't refer to a work.