Netflix has struck a deal to buy Warner Bros. Discovery, the Hollywood giant behind “Harry Potter” and HBO Max.