0

When I make call to the moviedb API for movie information. I get the following result:-

{
  "id": 155,
  "results": [{
    "id": "58f284f49251413da7003225",
    "iso_639_1": "en",
    "iso_3166_1": "US",
    "key": "kmJLuwP3MbY",
    "name": "The Dark Knight - Official Trailer [HD]",
    "site": "YouTube",
    "size": 1080,
    "type": "Trailer"
  }]
}

How should I store the value of the key in a variable and later use that key in HTML url like this:-

YouTube: https://www.youtube.com/watch?v=(varible) 
Phil
  • 157,677
  • 23
  • 242
  • 245
  • 1
    which one is "the key"? nevermind, found it - it's `x.results[0].key` ... where `x` is the variable you have that object stored in – Jaromanda X Sep 30 '20 at 02:50
  • And how can I add that key to a url? Like https://www.youtube.com/watch?v=key here? Specifically in HTML – ConfusedProgrammer Sep 30 '20 at 03:06
  • `"https://www.youtube.com/watch?v="+x.results[0].key` – Jaromanda X Sep 30 '20 at 03:11
  • Sorry for bugging you again. `` this is what I am trying to do. Can you show me a correct way? – ConfusedProgrammer Sep 30 '20 at 03:22
  • no, since I can't see how you get the data in the first place, nor how you interact with that iframe as you've shown absolutely nothing about your code - there are many ways to do what you want, the one that works depends on what your current *design* is – Jaromanda X Sep 30 '20 at 03:24
  • (https://github.com/Surya6032/Movie-Recommendation-System/blob/master/templates/positive.html) This is the link to the particular code I am trying to change – ConfusedProgrammer Sep 30 '20 at 03:27
  • well, that's the particular code you need to include in the question if you want help with it - you'll want to only include the bare minimum to describe your problem, nobody wants to wade through 600+ lines of irrelevant code – Jaromanda X Sep 30 '20 at 03:30
  • Alright bro. Thanks for the help. I will try to figure it out. And I was trying to get data from The movie db API and I was trying to implement it on my flask application. I just wanted to know how I should particularly connect the key to youtube link, so that the trailer will be visible in a card. – ConfusedProgrammer Sep 30 '20 at 03:36

0 Answers0