title: Combining BeautifulSoup and json into one output
body: <p>I have probably not explained my question well but as this is new to me... Anyway, I need to combine these two pieces of code.</p>
  
  <p>I can get the BS working, but it uses the wrong image. To get the right fields and the right image, I have to parse the json part of the website and therefore BS won't work.</p>
  
  <h1>The json parsing here</h1>
  
  <pre><code>import json
  import urllib
  import requests
  import re
  
  r    = urllib.urlopen('https://thisiscriminal.com/wp-json/criminal/v1/episodes?posts=10000&amp;page=1')
  data = json.loads(r.read().decode('utf-8'))
  
  for post in data['posts']:
      print post['episodeNumber']
      print post['title']
      print post['audioSource']
      print post['image']['medium']
      print post['content']
  </code></pre>
  
  <h1>And replace the try / BS part here:</h1>
  
  <pre><code>def get_playable_podcast(soup):
  """
  @param: parsed html page            
  """
  subjects = []
  
  for content in soup.find_all('item'):
  
      try:        
          link = content.find('enclosure')
          link = link.get('url')
          print "\n\nLink: ", link
  
          title = content.find('title')
          title = title.get_text()
  
          desc = content.find('itunes:subtitle')
          desc = desc.get_text()
  
          thumbnail = content.find('itunes:image')
          thumbnail = thumbnail.get('href')
  
      except AttributeError:
          continue
  
      item = {
              'url': link,
              'title': title,
              'desc': desc,
              'thumbnail': thumbnail
      }
  
  subjects.append(item)
  
  return subjects
  
  def compile_playable_podcast(playable_podcast):
      """
      @para: list containing dict of key/values pairs for playable podcasts
      """
      items = []
  
      for podcast in playable_podcast:
          items.append({
              'label': podcast['title'],
              'thumbnail': podcast['thumbnail'],
              'path': podcast['url'],
              'info': podcast['desc'],
              'is_playable': True,
      })
  
      return items
  </code></pre>
  
  <p>I have tried all sorts of variations with passing through the output to the items section, but the most common error I get is. I just have no idea how to pass the data from the json through.</p>
  
  <pre><code>Error Type: &lt;type 'exceptions.NameError'&gt;
  Error Contents: name 'title' is not defined
  Traceback (most recent call last):
  File ".../addon.py", line 6, in &lt;module&gt;
  from resources.lib import thisiscriminal    
  File "....resources/lib/thisiscriminal.py", line 132, in &lt;module&gt;
  'title': title,
  NameError: name 'title' is not defined
  </code></pre>