changes content for non-games:
Movie
'''
# get the proper result element we want to pull data from
result = None
if not doc.find_class('query_results'):
return 'no results found'
if plat not in game_platforms:
# for [all] results, or non-game platforms, get the first result
result = doc.find_class('result first_result')[0]
# find the platform, if it exists
result_type = result.find_class('result_type')
if result_type:
# if the result_type div has a platform div, get that one
platform_div = result_type[0].find_class('platform')
if platform_div:
plat = platform_div[0].text_content()
else:
# for games, we want to pull the first result with the correct
# platform
results = doc.find_class('result')
for res in results:
result_plat = res.find_class('platform')[0].text_content()
if result_plat == plat.upper():
result = res
break
if not result:
return 'no results found'
# get the name, release date, and score from the result
name = result.find_class('product_title')[0].text_content()
release = result.find_class('release_date')[0].\
find_class('data')[0].text_content()
try:
score = result.find_class('metascore')[0].text_content()
except IndexError:
score = None
result = '[%s] %s - %s, released: %s' % (plat.upper(), name,
score or 'no score', release)
return result