Donald Trump spent much of his campaign claiming that the election was rigged in favor of Hillary Clinton, but cable news media is now being cited by some as the driving force behind the Republican candidate become president-elect. Attention has focused on the role of the media amid reports of record profits for cable news outlets and studies showing that Trump earned the equivalent of more than $5 billion in free advertising.

As the stunning result of the most intensely covered election in U.S. history became clear in the early hours of Wednesday morning, social media was full of posts from those searching for explanations and in many cases scapegoats for the New York businessman’s extraordinary rise. The media became one of the central targets.

In a tweet that has been liked well over 5,000 times, actor Josh Gad wrote “Dear media, I really hope all the ratings were worth it.”

Gad was far from alone in his sentiment.

Two weeks out from the election, Trump had spent $74 million on advertising, about a third of that spent by Clinton and less than half what Republican Mitt Romney had committed at the same time in the 2012 election cycle when he lost to then-incumbent Barack Obama. But Trump has been anything but absent from television screens in the 17 months since he announced his presidential bid.

According to data-driven analytics firm mediaQuant, Trump received around $5 billion in free media coverage, more than twice that garnered by Clinton. From detailing his constant stream of headline-grabbing comments to regularly accepting phone-in interviews, Trump has been a virtual ever-present on cable news media for the past year and a half.

Donald Trump tv Donald Trump is shown on TV monitors in the media filing room on the campus of University of Nevada, Las Vegas, during the last 2016 U.S. presidential debate in Las Vegas, Oct. 19, 2016. Photo: Reuters/Jim Urquhart

And Trump has also been good for the media. The first presidential debate between Trump and Clinton was the most watched in U.S. history, averaging 84 million viewers. CNN is one of the outlets to benefit most, with the network and its related media businesses expected to post a record gross profit of $1 billion for 2016, a double-digit increase on the previous year.

It was a point former CNN anchor, Soledad O’Brien made in response to Gad’s comment. “CNN posted a reported 1 billion dollar profit, so I'm gonna say yes, it was [worth it],” she tweeted. “And don't expect that strategy to just go away.”

It isn’t just CNN to have benefited from Trump. Fox News is set to have its best news to date, while MSNBC’s projected profits are expected to show a 19 percent growth rate in 2016.

As well as the frequency of Trump’s presence in the media, the way in which the two candidates were covered has also come under scrutiny. A Gallup study released in September showed that while coverage of Clinton’s email scandal had stuck in the minds of voters far more than the myriad of scandals to have hit Trump’s campaign.

“Though Clinton has attacked Trump on several issues related to his character, no specific words representing negative traits have 'stuck' to Trump the way the word 'email' has to Clinton,” read the study’s report.

Yet while Democrats may want to attribute blame to the media, Clinton’s campaign will also have to take a share of the responsibility for the rise of Trump. In an email released by WikiLeaks, Clinton campaign chair John Podesta wrote to the Democratic National Committee in April 2015 outlining a strategy of encouraging the media to promote what he termed “pied piper” candidates in an attempt to undermine the more established Republican hopefuls.

“We need to be elevating the Pied Piper candidates so that they are leaders of the pack and tell the press to them seriously,” he wrote.