YouTube can’t be sued for restricting access to some of its videos because the company, though a prolific source of information with more than 30 million visitors daily, is not a government agency subject to constitutional guarantees of free speech, a federal appeals court ruled Wednesday.

The suit was filed in 2017 by Prager University, a nonprofit that does not hold classes or award degrees but seeks to communicate conservative views by posting short videos aimed at high school, college and graduate students.

Several dozen Prager videos were classified by YouTube as restricted because of what the company considers “mature” content — such as violence, drugs and alcohol, sex, terrorism, war or political conflicts. Most Prager viewers could still see them, but a small number of viewers, including some libraries, schools and businesses, as well as individual families, automatically filter out restricted content.

The suit also challenged YouTube’s decision to prohibit outside advertising on some Prager videos, a classification called “demonetizing” that is also based on content the company views as inappropriate for certain audiences.

Prager, based in Southern California, sued San Bruno-based YouTube and its parent company, Google, in San Jose federal court. U.S. District Judge Lucy Koh dismissed the suit in 2018 and was upheld Wednesday by the Ninth U.S. Circuit Court of Appeals.

“The First Amendment prohibits the government — not a private party — from abridging speech,” Judge Margaret McKeown said in the 3-0 ruling.

She said a private organization can act for the government on occasion, when it “conducts a public function,” like running an election or operating a “company town.” But “hosting speech on a private platform” is not a traditional government function, McKeown said.

The court also rejected Prager’s claim of false advertising, based on YouTube’s descriptions of its content restriction policies and the company’s public statements about its commitment to free expression — for example, a statement that YouTube believes “people should be able to speak freely, share opinions, foster open dialogue.”

YouTube’s policy descriptions were explanations to its customers, not advertising promotions, McKeown said. She said YouTube’s “braggadocio about its commitment to free speech” amounted to expressions of opinion and “puffery,” not factual assertions that could be challenged as false advertising.

In response to the ruling, Farshad Shadloo, a spokesperson for YouTube, said, “Google’s products are not politically biased. ... Our platforms have always been about sharing information everywhere and giving many different people a voice, including Prager U, who has over 2 million subscribers on their YouTube channel.”

Prager official Craig Strazzeri said in a statement, “We won’t stop fighting and spreading public awareness of Big Tech’s censorship of conservative ideas.”

Meanwhile, lawyers in Prager’s case have filed another federal lawsuit in San Jose that claims YouTube classified certain videos as sexually explicit, and barred advertising, solely because they involved gay or lesbian sexual orientation.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @BobEgelko