The news that a publishing division owned by Rupert Murdoch has released a book accusing American TV of liberal bias might sound deeply unsurprising. The belief that NBC, CBS and ABC promote values closer to Democrat beliefs than Republican views is long-established, hard to dispute by objective observation and has already resulted, under the US's free-market TV system, in the rise of Murdoch's Fox News as a deliberately conservative opposition.

But Primetime Propaganda, by Ben Shapiro, merits more attention because it considers not the traditional ideological battleground of news and factual programming but fiction and comedy: M*A*S*H, Friends, Happy Days and so on. And, on this occasion, the allegation of deliberate leftist spin is not merely being asserted by a rightwing commentator but apparently accepted by the makers of the programmes. Shapiro talks to dozens of executives and show-runners who are quoted as cheerfully admitting to having been engaged in social engineering, justifying, for him, the subtitle: The True Hollywood Story of How the Left Took Over Your TV.

Among Shapiro's revelations are that M*A*S*H (1972-1983), the long-running comedy set among US military doctors in Korea, and Happy Days (1974-1984), the sitcom about teenagers in the 1950s, were, by the admission of their producers, pursuing a deliberate pro-pacifist, anti-Vietnam agenda.

In the first case, there will be little surprise that the comedy set during the Korean conflict became so closely associated with Vietnam. Indeed, if it hadn't been for the clear metaphorical connection with a more current war, the spin-off from Robert Altman's movie might well have flopped.

The admission from Happy Days writer Bill Bickley that he inserted a "whole subtext" against Vietnam is slightly more striking, but most viewers will have instinctively understood that Henry Winkler's rocker hero The Fonz was a rebel who was likely to resist the army draft.

And both of these examples show the risk of explaining entertainment retrospectively. In the final years of the Vietnam conflict - during which the first three seasons of M*A*S*H and the first year of Happy Days were screened – to be anti-war was a mainstream position, uniting left and right, President Nixon and folk-protest singers, just as opposition to the Iraq war rapidly became cross-party in Britain three decades later. What has happened is that a modern revisionism in some sections of the right about Vietnam – redefining it as a necessary and even glorious war – is now being applied to TV shows that grew from the majority mood of their times.

Shapiro's thesis, though, should not be immediately dismissed, especially by viewers in Britain, where statutory and regulatory rules of balance make the kind of bias he ascribes theoretically impossible. The work of Aaron Sorkin, for example, is explicitly a liberal manifesto. While The West Wing is one of the supreme achievements of TV drama, its politics are fascinatingly peculiar. From 1999 until 2006, NBC was broadcasting a portrait of a US president who was a perfectly uxorious intellectual genius (winner of the Nobel prize for economics), even though the two fictional administrations of President Jeb Bartlett overlapped with the end of the presidency of the sexually disgraced Bill Clinton and the first five years of the stumblingly inarticulate George W Bush.

But, while The West Wing clearly was a liberal fantasy alternative to the real politics of the period, it was implicitly as anti-Clinton as anti-Bush. Sorkin and his successor as show-runner, John Wells, for example, found a clever and subtle metaphor for the lies and evasions in the Clinton White House over the Monica Lewinsky affair: with Bartlett and his staff concealing from the electorate the fact that he had multiple sclerosis, a detail that is eventually betrayed, from the best of motives, by his wife.

There is never any doubt that the show is written from a liberal perspective – the biggest threat to President Bartlett's safety comes from white supremacist extremists who object to the fact that his daughter is dating an African-American – but such storylines are justified: future historians will surely be impressed by the extent to which the racial politics of the series foreshadowed both the support for and opposition to President Obama.

A more recent hit NBC show, Tina Fey's sitcom 30 Rock, is another example of a series with a liberal agenda that may be more complex than it at first appears. Produced by the entertainment division of NBC, 30 Rock is set within a satirical approximation of that outfit. The ultimate boss of liberal comedy writer Liz Lemon, the character Fey plays, is Jack Donaghy (Alec Baldwin), a senior figure at GE, which owns the network, on- and off-screen. Donaghy is a rabid Republican who has numerous lines referring, for example, to "the recession caused by the Democrats". If, as strongly rumoured, Baldwin plans to run for mayor of New York, Shapiro will have new ammunition for a second edition.

But should 30 Rock be interpreted, through Shapiro's prism, as yet more liberal baiting of the US right or is it an example of a good satirist's ability to find gags in every aspect of a situation? Donaghy is a cartoon conservative but, then, Lemon is a caricature liberal and feminist and, most daringly in a modern American context, Tracy Morgan plays a comic-strip African-American entertainer. Every character in the comedy exists at a sharp angle to reality.

Non-American readers of Shapiro's book will inevitably be tempted to test his thesis against their own drama and sitcom schedules. It is easy to imagine a spoof UK version of Primetime Propaganda, which argues that Dylan the rabbit in The Magic Roundabout was a subversive advert for dope-smoking pacifism, The Liver Birds was an attempt to "normalise" sex before marriage and the hotelier in Fawlty Towers stirred up anti-German sentiment during the period of the creation of the Common Market.

More seriously, though, as the charge of leftist bias has also long been made by the right here against British broadcasting, it is interesting to see if any hidden agenda can be detected in our entertainment programming. Intriguingly, it is immediately apparent that a striking number of the most memorable British comedy characters – Alf Garnett, Terry and June Medford, Captain Mainwaring, Margot Leadbetter, Basil Fawlty, Del Boy Trotter – have been explicitly or implicitly Tory voters: there is even a Terry and June episode in which he is shocked to discover that she plans to vote Liberal in the next election. It also seems likely that David Brent in The Office, after a possible flirtation with Blair's Cool Britannia, would have turned to Conservatism, while Alan Partridge is a natural Thatcherite. It is true that, with the possible exception of the Medfords and Mrs Leadbetter, none of these protagonists would be chosen by Conservative party central office to appear on posters, although, given their ratings success, millions of Tory voters must have watched them with great pleasure. And the most clearly defined lefties in British comedy – Peter Capaldi's Malcolm Tucker in The Thick of It and Robert Lindsay's revolutionary in Citizen Smith – were objects of revulsion and pity respectively.

So does British TV comedy have a hidden conservative agenda equivalent to the insistent liberalism Shapiro detects in US schedules? The problem is that the politics of a comedy are very complicated. Both The West Wing and The Thick of It can be seen as examples of the left criticising the left and can therefore be enjoyed by conservatives. And, although the views of the writers and of the characters can often be objectively defined, they are then filtered through the subjective response of viewers, so that, famously, Alf Garnett, a satire of bigotry, was taken by portions of the audience as an endorsement of it. And Dad's Army, now a national televisual treasure and seemingly the cosiest of franchises, can be regarded – and, when it started, was regarded – as a subversive piece of work.

When the story of the Walmington-on-Sea Home Guard was launched in 1968, voices within the BBC and outside (in newspapers and Westminster) expressed serious concern about the proprieties of seeking jokes in a conflict that had ended only two decades previously and directly touched most families in the land. Indeed, an equally daring project in a US context would be if M*A*S*H had been set during the Vietnam war.

A British Shapiro might also note, with some reason, that it now seems extraordinary that, during one of the chilliest periods of the cold war, one of the country's most popular TV shows was depicting British military defence measures as comically amateurish, although the major victim of this metaphorical connection later turned out to be the left when the then Labour leader Neil Kinnock suggested, during the 1987 election, that a Britain without nuclear weapons would resist Russian invasion through a Captain Mainwaring-like Home Guard.

But the explanation for these intriguing subtexts in both British and US comedy is not that political subversives were operating in comedy departments in Los Angeles and London (although, even if they were, the implicit law-and-order agenda of the dozens of cop shows produced annually in both countries would offer conservative balance).

A central source of comedy is the attempt to impose authority and the efforts to resist it. US networks found these relationships in a Korean army hospital, a Milwaukee coffee bar and the improbably expensive apartments of the Friends characters. British shows chose to stage these stand-offs in a volunteer defence force, a West Country hotel and a Peckham trading company.

But, while good comedy often concerns power struggles, the references to political power are, in most cases, secondary or subliminal from the writers and will certainly transmit to viewers in this way. The only mission of M*A*S*H and Dad's Army and these other comedies is far from secret: to find humour in situations that are historically specific but also, as their success has proved, universally human.