I've never heard that non-profits can violate intellectual property laws. Otherwise, that might give advantages to Sci-hub, shadow libraries, etc.
One of them is the purpose or character of the use, including whether the use is of a commercial nature or is for nonprofit educational purposes.