A former television producer pressured by debt and riven by jealousy admitted Tuesday he tried to extract vengeance and money by shaking down David Letterman in a case that bared the late-night icon’s affairs with staffers.

Robert “Joe” Halderman pleaded guilty to attempted grand larceny, acknowledging he tried to chisel $2 million from the late-night icon. He threatened to destroy Letterman’s reputation by airing his workplace dalliances — using information authorities have said he mined from a former girlfriend’s diary.