Unless the media wanted Trump to win, they handled almost everything in the worst possible way. In the primary debates, they made Trump the center of discussion by attacking him. The result was he got twice his share of speaking time and most of the attention. In the general election debates, they were so pro-Hillary that their actions proved Trump’s point about biased and corrupt insiders.
I think they really wanted Trump to be the nominee because he would be the easiest to defeat, but they didn’t think through human behavior enough to recognize that their strategy would also help him in the general election.
They aren’t as smart as they think they are. Not within a light-year.