For years, I've said that two books are indispensible for people interested in television writing: Aristotle's POETICS and David Gerrold's THE WORLD OF STAR TREK. The former is extraordinarily helpful for learning to think about the fundamental framework of dramatic writing; the latter is a *magnificent* dissection of TOS as a series, what worked and what didn't, and thoughts on how to improve it. Gerrold used some of those thoughts later, when he and Roddenberry were developing STAR TREK: THE NEXT GENERATION. It's a brilliant book, and if you're at all interested in the mechanisms of drama I highly recommend it. (In terms of sheer usefulness, I'd actually put Aristotle second to Gerrold. That's how highly I think of THE WORLD OF STAR TREK.)
To those, I'd add, at #3,
DOCTOR WHO: THE WRITER'S TALE, by Russell T. Davies and Benjamin Cook. It's an inside look at Davies's and Tennant's last full series of DOCTOR WHO, in the form of emails between Davies and journalist Cook during the preproduction and production of the last Tennant/Davies series. Cook draws Davies out on his process to great effect, and you get a better idea of what it's like to run a TV show out of this than you could ever imagine just sitting around. It's a rough, rough job, and Davies starts out the season blithely saying, yeah, it's wonderful, I'd do this if they weren't paying me, and by the end of it he's about as cheerful as a man on the Bataan Death March. Cook, being a good and helpful friend, quotes Davies's cheerful earlier words back to him on those occasions, causing Davies to hate him with a deep and burning loathing.
The thing has some wonderful insights from Davies about writing.
( Example: )