split some lines and added pointless comments
This commit is contained in:
parent
d26de98ebe
commit
c6ecd1db81
1 changed files with 16 additions and 4 deletions
|
@ -16,29 +16,41 @@ def newgrounds_url(match):
|
||||||
print "Not a valid Newgrounds portal ID. Example: http://www.newgrounds.com/portal/view/593993"
|
print "Not a valid Newgrounds portal ID. Example: http://www.newgrounds.com/portal/view/593993"
|
||||||
return None
|
return None
|
||||||
soup = http.get_soup("http://www.newgrounds.com/portal/view/" + location)
|
soup = http.get_soup("http://www.newgrounds.com/portal/view/" + location)
|
||||||
|
|
||||||
title = "\x02{}\x02".format(soup.find('title').text)
|
title = "\x02{}\x02".format(soup.find('title').text)
|
||||||
|
|
||||||
|
# get author
|
||||||
try:
|
try:
|
||||||
author = " - \x02{}\x02".format(soup.find('ul', {'class': 'authorlinks'}).find('img')['alt'])
|
author_info = soup.find('ul', {'class': 'authorlinks'}).find('img')['alt']
|
||||||
|
author = " - \x02{}\x02".format(author_info)
|
||||||
except:
|
except:
|
||||||
author = ""
|
author = ""
|
||||||
|
|
||||||
|
# get rating
|
||||||
try:
|
try:
|
||||||
rating = u" - rated \x02%s\x02/\x025.0\x02" % soup.find('dd', {'class': 'star-variable'})['title'].split("Stars –")[0].strip()
|
rating_info = soup.find('dd', {'class': 'star-variable'})['title'].split("Stars –")[0].strip()
|
||||||
|
rating = u" - rated \x02{}\x02/\x025.0\x02".format(rating_info)
|
||||||
except:
|
except:
|
||||||
rating = ""
|
rating = ""
|
||||||
|
|
||||||
|
# get amount of ratings
|
||||||
try:
|
try:
|
||||||
numofratings = " ({})".format(soup.find('dd', {'class': 'star-variable'})['title'].split("Stars –")[1].replace("Votes", "").strip())
|
ratings_info = soup.find('dd', {'class': 'star-variable'})['title'].split("Stars –")[1].replace("Votes", "").strip()
|
||||||
|
numofratings = " ({})".format(ratings_info)
|
||||||
except:
|
except:
|
||||||
numofratings = ""
|
numofratings = ""
|
||||||
|
|
||||||
|
# get amount of views
|
||||||
try:
|
try:
|
||||||
views = " - \x02{}\x02 views".format(soup.find('dl', {'class': 'contentdata'}).findAll('dd')[1].find('strong').text)
|
views_info = soup.find('dl', {'class': 'contentdata'}).findAll('dd')[1].find('strong').text
|
||||||
|
views = " - \x02{}\x02 views".format(views_info)
|
||||||
except:
|
except:
|
||||||
views = ""
|
views = ""
|
||||||
|
|
||||||
|
# get upload data
|
||||||
try:
|
try:
|
||||||
date = "on \x02{}\x02".format(soup.find('dl', {'class': 'sidestats'}).find('dd').text)
|
date = "on \x02{}\x02".format(soup.find('dl', {'class': 'sidestats'}).find('dd').text)
|
||||||
except:
|
except:
|
||||||
date = ""
|
date = ""
|
||||||
|
|
||||||
return title + rating + numofratings + views + author + date
|
return title + rating + numofratings + views + author + date
|
||||||
|
|
Reference in a new issue