Two attorneys general are demanding that Google cleans up YouTube and stops profiting from illegal videos. Reuters

YouTube scored another important legal victory in the ongoing battle against Viacom. U.S. District Judge Louis L. Stanton ruled Thursday that YouTube is not guilty of copyright infringement when users upload clips from Viacom television shows.

In a 24-page opinion, Judge Stanton said YouTube is shielded by a safe-harbor provision in the Digital Millennium Copyright Act, and, due to the sheer volume of content uploaded to YouTube, it is impractical to expect the company to catch every piece of copyrighted material. Instead, media companies like Viacom have the responsibility to report unauthorized content when it appears.

Stanton dismissed the $1 billion lawsuit and ordered Viacom to pay for some of YouTube’s legal expenses.

"This is a win not just for YouTube, but for people everywhere who depend on the Internet to exchange ideas and information,” Google’s general counsel Kent Walker said in a statement.

This is the second time that Stanton has rejected the lawsuit since Viacom originally filed in 2007. Major media companies have followed the case closely, hoping that a victory for Viacom will give greater expanded copyright enforcement against pirated clips of TV shows.

“This ruling ignores the opinions of the higher courts and completely disregards the rights of creative artists," Viacom said in a statement. The company has already vowed to appeal the decision, stating that the “overwhelming evidence” of copyright infringement should be brought to a jury.

For now, YouTube founders are enjoying the taste of victory. Founder Chad Hurley took to Twitter to do a bit of gloating toward Phillipe Duaman, Viacom’s chief executive.