The basic principle is that copyright never protects an idea, it only protects the expression of an idea. In the US, that rule is embodied in 17 USC 102(b) which provides that:
(b) In no case does copyright protection for an original work of authorship extend to any idea, procedure, process, system, method of operation, concept, principle, or discovery, regardless of the form in which it is described, explained, illustrated, or embodied in such work.
When significant, detailed, and specific plot elements are copied from a prior work, then that may make the new work a derivative work. Creation or distribution of a derivative work requires permission from the owner of the copyright (if any) on the prior work (source work). But the elements used must be significant and must be detailed. If all that is taken could be expressed in a summery contained in a single sentence or paragraph, this will not make the new work derivative.
For example, such ideas as:
- Napoleon meets the Emperor of China and they form an alliance. [My idea]
- Sherlock Holmes helps to repel the Martian invasion described in The War of the Worlds. Conan Doyle's Professor Challenger is also involved. [Wellman's Sherlock Holmes's War of the Worlds]
- Aliens crash land on Earth in 1905, creating an alternate timeline. They seek to start WWI early, to stimulate technical development. [Benson's ...And Having Writ]
would on their own not be enough to constitute a derivative work and thus infringement. But the more specific detail from the source work is used, the more likely it is that an infringement suit would win.
By the way, the rule is the same whether the source work is a book, or a TV show, or an opera, or any other work subject to copyright protection. If the work is old enough, any copyright will have expired, but the format of the original does not matter, as long as it is "fixed in a tangible form" which includes video tape, DVD, computer file, or a script written on paper. About the only things that do not count as fixed would be an impromptu dance, song, speech, or story whch the creator performed or spoke without its ever having been written down or recorded in any way.