Google must divulge the viewing habits of every user who has ever watched any video on YouTube, a US court has ruled.The ruling comes as part of Google's legal battle with Viacom over allegations of copyright infringement.Digital rights group the Electronic Frontier Foundation (EFF) called the ruling a "set-back to privacy rights".The viewing log, which will be handed to Viacom, contains the log-in ID of users, the computer IP address (online identifier) and video clip details.While the legal battle between the two firms is being contested in the US, it is thought the ruling will apply to YouTube users and their viewing habits everywhere.Viacom, which owns MTV and Paramount Pictures, has alleged that YouTube is guilty of massive copyright infringement.Legal actionWhen it initiated legal action in March 2007 the firm said it had identified about 160,000 unauthorised clips of its programmes on the website, which had been viewed more than 1.5 billion times.Following the launch of its billion-dollar lawsuit, YouTube introduced filtering tools in an effort to prevent copyright materials from appearing on the site.The US court declined Viacom's request that Google be forced to hand over the source code of YouTube, saying it was a "trade secret" that should not be disclosed.But it said privacy concerns expressed by Google about handing over the log were "speculative".The ruling will see the viewing habits of millions of YouTube users given to Viacom, totalling more than 12 terabytes of data.Viacom said it wanted the data to "compare the attractiveness of allegedly infringing video with that of non-infringing videos."'Erroneous ruling'The EFF said: "The Court's erroneous ruling is a set-back to privacy rights, and will allow Viacom to see what you are watching on YouTube."We urge Viacom to back off this overbroad request and Google to take all steps necessary to challenge this order and protect the rights of its users."The body said the ruling was also potentially unlawful because the log data did contain personally identifiable data.The court also ruled that Google disclose to YouTube the details of all videos that have been removed from the site for any reason.