A rapist who attacked a hospital patient and his cell mate was arrested when he began shouting at police while a Hollywood movie was being filmed.

Hamish McIntyre became obsessed with the 33-year-old woman he met at a psychiatric hospital in Edinburgh before raping her at his home.

McIntyre, 46, was arrested and then released on bail before being detained again when he caused a disturbance in the capital's Parliament Square while scenes for Avengers: Infinity War were being shot.

He was taken to Saughton Prison, where he raped a cell mate and sexually assaulted another inmate.

Jailing him for 12 years at the High Court in Edinburgh on Friday, a judge told the rapist: "You have been convicted by the jury of grave sexual offending against three vulnerable individuals."

Lord Arthurson revealed that McIntyre had served 22 previous custodial sentences including for multiple crimes of violence, some involving weapons such as a hammer, brick or knife, and had previously been convicted of sexual assault.

The judge told McIntyre that he would be placed on the sex offenders' register indefinitely.

McIntyre had denied assaulting and raping the woman on March 10 and raping the two men in the jail between March 15 and April 4 last year.

He was found guilty of raping the woman and a 38-year-old man and sexually assaulting the other prisoner.