Extract data from javascript response

I have a php link that returns below response.

var count = 0;
var movies = ["1917","Saving Private Ryan", "Titanic"];
var years = {
    "1997": "Titanic",
    "1998": "Saving Private Ryan",
    "2019": "1917",
};
for (var i in years) {
    if (i == ' ') r_space = years[i];
}

I am using BS4 in Python to get this response but I don’t know how to parse it correctly so I can read content in var movies and var years separately. Loading to JSON obviously gives me an error. How can I get the values of var movies and var years separatley in Python? I am a beginner so would appreciate any help.

I am totally okay to devaite from BS4 as well.