A convicted sex offender accused of downloading thousands of indecent images of children has failed in a fresh legal bid to be released from custody.