Bill Cosby departs after a pretrial hearing in his sexual assault case at the Montgomery County Courthouse in Norristown, Pa., Tuesday, Aug. 22, 2017. Cosby's retrial will be delayed as his new legal team gets up to speed on the case. (AP Photo/Matt Rourke)

A publicist for once-beloved actor Bill Cosby complained that the star’s conviction and three- to 10-year prison term for sexual assault stem from a racist and sexist justice system.

Cosby is vowing to appeal his conviction as the first celebrity trial of the #MeToo era. He is serving time at a state prison in Montgomery County after his sentencing there Tuesday.

Judge Steven O’Neill has presided over the case for nearly three years. He says Cosby remains a potential danger to socity even though he is 81 and infirm. The judge says Cosby could still drug people to override their lack of consent to sexual activity.

Defense lawyers had argued that Cosby be sentenced to home confinement over the 2004 assault.