Python Forum
tmdbsimple content type? How to work with it?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tmdbsimple content type? How to work with it?
#1
I'm trying to figure out how to access data via the TMDB API using the tmdbsimple wrapper. I've figured out some of the basics but I'm unsure how to reference items in the query results.

First off... Am I looking at python dictionary/list data or JSON data below? The multi-tier braces {[{}]} are what's throwing me off. (I've separated the output based on the search result.

{'page': 1, 'total_results': 4394, 'total_pages': 220, 'results': 
[{'popularity': 39.353, 'vote_count': 6276, 'video': False, 'poster_path': '/Ah3J9OJVc2CNCuH2zMydXy9fmIC.jpg', 'id': 9487, 'adult': False, 'backdrop_path': '/s0eIBHJROgDWO3IoOt8FfQCFPGh.jpg', 'original_language': 'en', 'original_title': "A Bug's Life", 'genre_ids': [12, 16, 35, 10751], 'title': "A Bug's Life", 'vote_average': 6.9, 'overview': 'On behalf of "oppressed bugs everywhere," an inventive ant named Flik hires a troupe of warrior bugs to defend his bustling colony from a horde of freeloading grasshoppers led by the evil-minded Hopper.', 'release_date': '1998-11-25'}, 
{'popularity': 22.055, 'vote_count': 5149, 'video': False, 'poster_path': '/lja0Kh17LLleh6DhtixEh7Z7T6D.jpg', 'id': 395992, 'adult': False, 'backdrop_path': '/nNh7vHHISVAaziJEqAq0P9iL52w.jpg', 'original_language': 'en', 'original_title': 'Life', 'genre_ids': [27, 878, 53], 'title': 'Life', 'vote_average': 6.4, 'overview': 'The six-member crew of the International Space Station is tasked with studying a sample from Mars that may be the first proof of extra-terrestrial life, which proves more intelligent than ever expected.', 'release_date': '2017-03-22'}, 
{'popularity': 74.028, 'vote_count': 4807, 'video': False, 'poster_path': '/y95lQLnuNKdPAzw9F9Ab8kJ80c3.jpg', 'id': 38700, 'adult': False, 'backdrop_path': '/upUy2QhMZEmtypPW3PdieKLAHxh.jpg', 'original_language': 'en', 'original_title': 'Bad Boys for Life', 'genre_ids': [28, 80, 53], 'title': 'Bad Boys for Life', 'vote_average': 7.2, 'overview': 'Marcus and Mike are forced to confront new threats, career changes, and midlife crises as they join the newly created elite team AMMO of the Miami police department to take down the ruthless Armando Armas, the vicious leader of a Miami drug cartel.', 'release_date': '2020-01-15'}, 
{'popularity': 16.719, 'vote_count': 456, 'video': False, 'poster_path': '/mMTrgEhGrHzin07P5G6BPVw9XuW.jpg', 'id': 6522, 'adult': False, 'backdrop_path': '/lpNMmv0clc7Utpvt7mBNfYLlf3h.jpg', 'original_language': 'en', 'original_title': 'Life', 'genre_ids': [35, 80], 'title': 'Life', 'vote_average': 6.6, 'overview': 'Two men in 1930s Mississippi become friends after being sentenced to life in prison together for a crime they did not commit.', 'release_date': '1999-04-16'}, 
{'popularity': 11.941, 'vote_count': 255, 'video': False, 'poster_path': '/3OpgwAQRCt049ytd2Nsd5y6dxv4.jpg', 'id': 300153, 'adult': False, 'backdrop_path': '/fxOyTo0Bnm4pQnt7g5OY1Zz4WOb.jpg', 'original_language': 'en', 'original_title': 'Life', 'genre_ids': [18], 'title': 'Life', 'vote_average': 6.1, 'overview': 'In 1955, young photographer Dennis Stock develops a close bond with actor James Dean while shooting pictures of the rising Hollywood star.', 'release_date': '2015-07-24'}, 
{'popularity': 17.652, 'vote_count': 457, 'video': False, 'poster_path': '/wElOvH7H6sLElsTOLu1MY6oWRUx.jpg', 'id': 376865, 'adult': False, 'backdrop_path': '/bo5VJbds3oeMoj19GFnzBoUgjJS.jpg', 'original_language': 'en', 'original_title': 'High Life', 'genre_ids': [18, 9648, 878, 53], 'title': 'High Life', 'vote_average': 5.8, 'overview': 'A father and his daughter struggle to survive in deep space where they live in isolation.', 'release_date': '2018-11-07'}, 
{'popularity': 17.685, 'vote_count': 548, 'video': False, 'poster_path': '/xX8cM4qhQYpv3vI6hXr9UInq2s.jpg', 'id': 8092, 'adult': False, 'backdrop_path': '/pEgjxsLncICwSn61TaBTKusKVEB.jpg', 'original_language': 'en', 'original_title': "This Boy's Life", 'genre_ids': [18], 'title': "This Boy's Life", 'vote_average': 7.1, 'overview': "In 1957, a son and mother flee the East and an abusive boyfriend to find a new life, and end up in Seattle, where the mother meets a polite garage mechanic. The boy continually gets into trouble by hanging out with the wrong crowd. The mom marries the mechanic, but they soon find out that he's an abusive and unreasoning alcoholic, and they struggle to maintain hope in an impossible situation as the boy grows up with plans to escape the small town by any means possible. Based on a true story by Tobias Wolff.", 'release_date': '1993-04-09'}, 
{'popularity': 14.725, 'vote_count': 78, 'video': False, 'poster_path': '/AdJKmRh3AKX5CVCdwdw1dNTqEJ8.jpg', 'id': 8060, 'adult': False, 'backdrop_path': '/fvIj8fo9j6DifyMWopHevGVhFUQ.jpg', 'original_language': 'en', 'original_title': 'Married Life', 'genre_ids': [80, 18, 10749], 'title': 'Married Life', 'vote_average': 6.1, 'overview': 'A very gentle middle-aged man is married, but when he falls in love with another woman, he decides that to divorce his wife would humiliate her too much – so instead he decides to kill her.', 'release_date': '2007-09-12'}, 
{'popularity': 15.665, 'id': 446696, 'video': False, 'vote_count': 265, 'vote_average': 7.2, 'title': 'Life Itself', 'release_date': '2018-09-21', 'original_language': 'en', 'original_title': 'Life Itself', 'genre_ids': [18, 10749], 'backdrop_path': '/tNAeOH1SGKN4R7cGN9ZPH1LMpHK.jpg', 'adult': False, 'overview': 'As a young New York couple goes from college romance to marriage and the birth of their first child, the unexpected twists of their journey create reverberations that echo over continents and through lifetimes.', 'poster_path': '/aiqvl9GyF4LyGAXeAHkt3SiCFp9.jpg'}, 
{'popularity': 20.968, 'vote_count': 10095, 'video': False, 'poster_path': '/mYDKm9HxImm8PRru3KbkHAe1cmk.jpg', 'id': 87827, 'adult': False, 'backdrop_path': '/7H01zprUY67n7bdcFg6VMvrkNjs.jpg', 'original_language': 'en', 'original_title': 'Life of Pi', 'genre_ids': [28, 12, 18], 'title': 'Life of Pi', 'vote_average': 7.4, 'overview': "The story of an Indian boy named Pi, a zookeeper's son who finds himself in the company of a hyena, zebra, orangutan, and a Bengal tiger after a shipwreck sets them adrift in the Pacific Ocean.", 'release_date': '2012-11-20'}, 
{'popularity': 14.015, 'vote_count': 165, 'video': False, 'poster_path': '/9oAVYDh7RHW3wzQWbGsRB7RFE6J.jpg', 'id': 257440, 'adult': False, 'backdrop_path': '/8yM0mNM5begExtTdmsi5ZnK4Ipm.jpg', 'original_language': 'en', 'original_title': 'Term Life', 'genre_ids': [80, 53], 'title': 'Term Life', 'vote_average': 5.8, 'overview': "If Nick Barrow can stay alive for 21 days, he'll die happy. Everyone Nick knows wants him dead; Mob bosses, contract killers, and dirty cops. Performing the last act of a desperate man, Nick takes out a million dollar insurance policy on himself, payable to his estranged daughter. The problem? The policy doesn't take effect for 21 days. Nick knows they'll be lucky to be alive for twenty-one hours.", 'release_date': '2016-04-29'}, 
{'popularity': 14.104, 'vote_count': 236, 'video': False, 'poster_path': '/52ZLTvJJ3JZu8wmmOMizuNc4r7a.jpg', 'id': 36968, 'adult': False, 'backdrop_path': '/gYlpM0wu3vJFLDyn9VmRNz2tMOK.jpg', 'original_language': 'en', 'original_title': 'Life-Size', 'genre_ids': [35, 14, 10751, 10770], 'title': 'Life-Size', 'vote_average': 5.8, 'overview': "After her mom's death, Casey pulls away from everyone in her life, including her emotionally distant dad. With help from a magic spell, she tries to bring her mother back from the dead; instead, Casey's words accidentally awaken one of her least favorite toys: a statuesque Barbie clone named Eve. Things get worse when Casey's dad develops a crush on his daughter's living doll.", 'release_date': '2000-03-05'}, 
{'popularity': 22.001, 'id': 1585, 'video': False, 'vote_count': 2488, 'vote_average': 8.2, 'title': "It's a Wonderful Life", 'release_date': '1946-12-20', 'original_language': 'en', 'original_title': "It's a Wonderful Life", 'genre_ids': [18, 10751, 14], 'backdrop_path': '/whxy3UQrbHswzXH6jfH7IGAIjLa.jpg', 'adult': False, 'overview': "A holiday favourite for generations...  George Bailey has spent his entire life giving to the people of Bedford Falls.  All that prevents rich skinflint Mr. Potter from taking over the entire town is George's modest building and loan company.  But on Christmas Eve the business's $8,000 is lost and George's troubles begin.", 'poster_path': '/bSqt9rhDZx1Q7UZ86dBPKdNomp2.jpg'}, 
{'popularity': 13.742, 'vote_count': 47, 'video': False, 'poster_path': '/uOVGbT6TR8qiZiruX66yBRXq9Nv.jpg', 'id': 586707, 'adult': False, 'backdrop_path': '/qIKjPZ4EvK8mQh4IUHwgLT2Imtc.jpg', 'original_language': 'en', 'original_title': 'Life Like', 'genre_ids': [878, 53], 'title': 'Life Like', 'vote_average': 6, 'overview': 'An idealistic attractive young couple acquires a stunning, life-like robot for guilt free help, but as the three grow closer, their perception of humanity will be altered forever.', 'release_date': '2019-05-14'}, 
{'popularity': 19.508, 'vote_count': 241, 'video': False, 'poster_path': '/apO5xGmcEHpdIBc3Zreax7MXl2m.jpg', 'id': 209189, 'adult': False, 'backdrop_path': '/qDK6LtjyHmdudJECCpZYoJrdyGi.jpg', 'original_language': 'en', 'original_title': 'Life of Crime', 'genre_ids': [35, 80], 'title': 'Life of Crime', 'vote_average': 5.7, 'overview': 'Two common criminals get more than they bargained for after kidnapping the wife of a corrupt real-estate developer who shows no interest in paying the $1 million dollar ransom for her safe return.', 'release_date': '2013-09-14'}, 
{'popularity': 19.795, 'vote_count': 256, 'video': False, 'poster_path': '/eSpfKXBLMUr8iViLiBFub9OQxfq.jpg', 'id': 403300, 'adult': False, 'backdrop_path': '/zxY1yP9FjJpV7T3hxqBBI5WNydx.jpg', 'original_language': 'en', 'original_title': 'A Hidden Life', 'genre_ids': [18, 36, 10752], 'title': 'A Hidden Life', 'vote_average': 7.2, 'overview': 'Austrian farmer Franz Jägerstätter faces the threat of execution for refusing to fight for the Nazis during World War II.', 'release_date': '2019-12-11'}, 
{'popularity': 18.302, 'id': 583, 'video': False, 'vote_count': 2724, 'vote_average': 7.8, 'title': 'Life of Brian', 'release_date': '1979-08-17', 'original_language': 'en', 'original_title': 'Life of Brian', 'genre_ids': [35], 'backdrop_path': '/aRvoRaR4l7Bxzjch5ioi5dZzrsX.jpg', 'adult': False, 'overview': "Brian Cohen is an average young Jewish man, but through a series of ridiculous events, he gains a reputation as the Messiah. When he's not dodging his followers or being scolded by his shrill mother, the hapless Brian has to contend with the pompous Pontius Pilate and acronym-obsessed members of a separatist movement. Rife with Monty Python's signature absurdity, the tale finds Brian's life paralleling Biblical lore, albeit with many more laughs.", 'poster_path': '/lSSA64WF0M0BXnjwr2quMh6shCl.jpg'}, 
{'popularity': 24.222, 'id': 399796, 'video': False, 'vote_count': 621, 'vote_average': 6.2, 'title': 'Life of the Party', 'release_date': '2018-05-10', 'original_language': 'en', 'original_title': 'Life of the Party', 'genre_ids': [35], 'backdrop_path': '/5uayF96i4JWtdNH3uJy5IpImDBT.jpg', 'adult': False, 'overview': 'Dumped by her husband, longtime housewife Deanna turns regret into reset by going back to college. Winding up at the same school as her daughter, Deanna plunges headlong into the campus experience – embracing fun, freedom and frat boys.', 'poster_path': '/749iUAWQWeutQuTd9excjmigecw.jpg'}, 
{'popularity': 11.605, 'vote_count': 111, 'video': False, 'poster_path': '/bVVIcuFj3n8I6IdyYNHOfBJbPVU.jpg', 'id': 41659, 'adult': False, 'backdrop_path': '/5ccAivPcFEJazxwZZnr5QOGNcz6.jpg', 'original_language': 'en', 'original_title': 'My Life', 'genre_ids': [18, 10749], 'title': 'My Life', 'vote_average': 6.6, 'overview': "It seems that Bob Jones has everything a man could want, namely a fulfilling job and a beautiful, pregnant wife, Gail. But Bob's life is turned upside-down when he is diagnosed with cancer and given four months to live -- not even enough time to see his first child's birth. To cleanse himself of demons in his remaining days, Bob makes a video diary, hoping to pass along some wisdom to his future child. Along the way, he discovers a lot about himself.", 'release_date': '1993-11-12'}, 
{'popularity': 11.728, 'vote_count': 164, 'video': False, 'poster_path': '/Aj92GpVqOFAIXDVD3iKALmo3S4u.jpg', 'id': 36208, 'adult': False, 'backdrop_path': '/nhdKUNC6diqOAMtZdudttvguBb1.jpg', 'original_language': 'en', 'original_title': "A Dog's Life", 'genre_ids': [35, 18], 'title': "A Dog's Life", 'vote_average': 7.4, 'overview': 'The Tramp and his dog companion struggle to survive in the inner city.', 'release_date': '1918-04-14'}]}
Reply
#2
It appears to be a python dict. If nothing, else, JSON requires double-quotes as string designators, single quotes aren't valid for that.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tmdbsimple error pythonnewbie138 4 2,608 Aug-07-2020, 03:52 PM
Last Post: pythonnewbie138
  Type hinting - return type based on parameter micseydel 2 2,492 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Type function does not work sunnyarora 2 2,492 Mar-15-2019, 10:50 AM
Last Post: sunnyarora
  type command does not work appropriately atharva 2 2,549 May-30-2018, 11:20 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020