Celeb Glow
updates | March 28, 2026

Syntax Error on accessing JSON data in QML data from python youtube_dl

I have a simple youtube_dl function to access the youtube download links here,

@QtCore.Slot(str, result=str)
def getDownloadLinks(self, url): try: with youtube_dl.YoutubeDL({}) as ydl: result = ydl.extract_info(url, download=False) if "entries" in result: videos = result["entries"][0] else: videos = result r_videos = [] for video in videos["formats"]: r_videos.append({"url": video["url"], "format": video["format"], "size": video["filesize"]}) resRet = {"status":"true", "urls": r_videos} return str(resRet) except Exception as e: resRet = {"status":"true", "error": str(e)} return str(resRet)

And I am trying to access it in a QML file which has a function like this which access this python function by calling it like this.

function getLinks(url){ jsonString = downloadeng.getDownloadLinks(url) console.log(jsonString) var jsonObject = JSON.parse(jsonString) var anObject = JSON.parse(jsonObject) if (anObject.status == 'false') { //open Popup console.log("opening popup") } else { console.log(anObject.url) }
}

But every time I get syntax error like thisSyntaxError: JSON.parse: Parse error indicating var anObject = JSON.parse(jsonObject) this line. Another thing is that I am parsing the JSON twice as it errors on one parse but works fine on second parse. Please help me with this two things.

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy