Skip to content

Commit

Permalink
Fix issue #33: fallback to member token if nickname not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandaka committed Jun 5, 2014
1 parent 81f5d13 commit 62d4212
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PixivConstant.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-

PIXIVUTIL_VERSION = '20140325'
PIXIVUTIL_VERSION = '20140605'
PIXIVUTIL_LINK = 'https://nandaka.wordpress.com/tag/pixiv-downloader/'
PIXIV_URL = 'http://www.pixiv.net'
PIXIV_URL_SSL = 'https://ssl.pixiv.net/login.php'
Expand Down
15 changes: 10 additions & 5 deletions PixivModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ def ParseInfo(self, page, fromImage=False):
temp = str(avatarBox.find('a')['href'])
self.artistId = int(re.search('id=(\d+)', temp).group(1))

try:
self.artistName = unicode(page.find('h1', attrs={'class':'user'}).string.extract())
except:
self.artistName = unicode(page.findAll(attrs={"class":"avatar_m"})[0]["title"])
self.artistAvatar = str(page.find('img', attrs={'class':'user-image'})['src'])
self.artistToken = self.ParseToken(page, fromImage)

try:
h1 = page.find('h1', attrs={'class':'user'})
if h1 is not None :
self.artistName = unicode(h1.string.extract())
else :
avatar_m = page.findAll(attrs={"class":"avatar_m"})
if avatar_m is not None and len(avatar_m) > 0 :
self.artistName = unicode(avatar_m[0]["title"])
except:
self.artistName = self.artistToken ## use the token.

def ParseToken(self, page, fromImage=False):
if self.artistAvatar.endswith("no_profile.png"):
Expand Down

0 comments on commit 62d4212

Please sign in to comment.