old_contents: #!/usr/bin/env python
  
  import requests
  import grequests
  import imgurpython
  
  from itertools import repeat as rep
  
  from . import imgur_key
  
  try:
      from urlparse import urlsplit
  except ImportError:
      from urllib.parse import urlsplit
  
  from bs4 import BeautifulSoup
  
  
  def get_content(url):
      split = urlsplit(url)
      path_elements = [x for x in split.path.split("/") if x]
  
      if len(path_elements) == 1:
          return retrieve_single(url)
      elif 1 < len(path_elements):
          client = imgurpython.ImgurClient(
              imgur_key.cred['client-id'], imgur_key.cred['client-secret']
          )
          particle, content_id = path_elements[:2]
          if particle == 'a' or particle == 'gallery':
              links = [x.link for x in client.get_album_images(content_id)]
              rs = (grequests.get(x) for x in links)
              res = grequests.map(rs)
              info = mk_pasteinfo(*[(x, u) for x, u in zip(res, rep(url))])
              for paste, r in zip(info, res):
                  paste['content'] = r.content
              return info
  
  
  def retrieve_single(url):
      paste_info = {
          'site': 'imgur',
      }
      split = urlsplit(url)
      path_elements = [x for x in split.path.split("/") if x]
  
      element = path_elements[0]
      response = requests.get(url)
  
      if response.status_code != 200:
          return
  
      if "." in element:
          content_url = url
      else:
          soup = BeautifulSoup(response.text)
          content_url = soup.find('link', {'rel': 'image_src'})['href']
  
      response = requests.get(content_url)
      paste_info = mk_pasteinfo((response, url))
      paste_info[0]['content'] = response.content
      return paste_info
  
  
  def mk_pasteinfo(*args):
      info = list()
      paste_info = {
          'site': 'imgur',
      }
      for rs in args:
          response, url = rs
          content_url = response.url
          orig_filename, ext = content_url.split("/")[-1].split(".")
          paste_info['url'] = url
          paste_info['ext'] = ext
          paste_info['orig_filename'] = orig_filename
          info.append(paste_info)
  
      return info
  
new_contents: #!/usr/bin/env python
  
  import requests
  import grequests
  import imgurpython
  
  from itertools import repeat as rep
  
  from . import imgur_key
  
  try:
      from urlparse import urlsplit
  except ImportError:
      from urllib.parse import urlsplit
  
  from bs4 import BeautifulSoup
  
  
  def get_content(url):
      split = urlsplit(url)
      path_elements = [x for x in split.path.split("/") if x]
  
      if len(path_elements) == 1:
          return retrieve_single(url)
      elif 1 < len(path_elements):
          client = imgurpython.ImgurClient(
              imgur_key.cred['client-id'], imgur_key.cred['client-secret']
          )
          particle, content_id = path_elements[:2]
          if particle == 'a' or particle == 'gallery':
              links = [x.link for x in client.get_album_images(content_id)]
              rs = (grequests.get(x) for x in links)
              res = grequests.map(rs)
              info = mk_pasteinfo(*[(x, u) for x, u in zip(res, rep(url))])
  
              for paste, r in zip(info, res):
                  paste['content'] = r.content
              return info
  
  
  def retrieve_single(url):
      paste_info = {
          'site': 'imgur',
      }
      split = urlsplit(url)
      path_elements = [x for x in split.path.split("/") if x]
  
      element = path_elements[0]
      response = requests.get(url)
  
      if response.status_code != 200:
          return
  
      if "." in element:
          content_url = url
      else:
          soup = BeautifulSoup(response.text)
          content_url = soup.find('link', {'rel': 'image_src'})['href']
  
      response = requests.get(content_url)
      paste_info = mk_pasteinfo((response, url))
      paste_info[0]['content'] = response.content
      return paste_info
  
  
  def mk_pasteinfo(*args):
      info = list()
      for rs in args:
          paste_info = {
              'site': 'imgur',
          }
          response, url = rs
          content_url = response.url
          orig_filename, ext = content_url.split("/")[-1].split(".")
          paste_info['url'] = url
          paste_info['ext'] = ext
          paste_info['orig_filename'] = orig_filename
          info.append(paste_info)
  
      return info
  
subject: Fix referencing problem in imgur module