Google will have to turn over every record of every video watched by YouTube users, including users' names and IP addresses, to Viacom, which is suing Google for allowing clips of its copyright videos to appear on YouTube, a judge ruled Wednesday.

Viacom wants the data to prove that infringing material is more popular than user-created videos, which could be used to increase Google's liability if it is found guilty of contributory infringement.

Viacom filed suit against Google in March 2007, seeking more than $1 billion in damages for allowing users to upload clips of Viacom's copyright material. Google argues that the law provides a safe harbor for online services so long as they comply with copyright takedown requests.

Although Google argued that turning over the data would invade its users' privacy, the judge's ruling (.pdf) described that argument as "speculative" and ordered Google to turn over the logs on a set of four tera-byte hard drives.

The judge also turned Google's own defense of its data retention policies – that IP addresses of computers aren't personally revealing in and of themselves, against it to justify the log dump.

The Electronic Frontier Foundation has already reacted, calling the order a violation of the Video Privacy Protection act that "threatens to expose deeply private information."

The order also requires Google to turn over copies of all videos that it has taken down for any reason.

Viacom also requested YouTube's source code, the code for identifying repeat copyright infringement uploads, copies of all videos marked private, and Google's advertising database schema.

Those requests were denied in whole, except that Google will have to turn over data about how often each private video has been watched and by how many persons.