Skip to content

Commit

Permalink
fix bugs: check stream url nondanee#29
Browse files Browse the repository at this point in the history
  • Loading branch information
nondanee committed Oct 25, 2018
1 parent d9b6648 commit c3a06fa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions weiboPicDownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def uid_to_nickname(uid):
except:
return

def get_urls(uid, video = False):
def get_resources(uid, video = False):
page = 1
count = 25
total = 0
Expand All @@ -183,12 +183,13 @@ def get_urls(uid, video = False):
urls.append(pic["large"]["url"])
elif video and "page_info" in card["mblog"] :
if "media_info" in card["mblog"]["page_info"]:
urls.append(card["mblog"]["page_info"]["media_info"]["stream_url"])
if card["mblog"]["page_info"]["media_info"]["stream_url"]:
urls.append(card["mblog"]["page_info"]["media_info"]["stream_url"])
page += 1
time.sleep(1)

print_fit("finish analysis {}".format(progress(amount, total)), pin = True)
print_fit("\npractically get {} weibos, {} {}".format(amount, len(urls), "medias" if video else "pictures"))
print_fit("\npractically get {} weibos, {} {}".format(amount, len(urls), "resources" if video else "pictures"))
return urls

def download(url, file_path, overwrite):
Expand Down Expand Up @@ -252,7 +253,7 @@ def download(url, file_path, overwrite):
continue
print_fit("{} {}".format(nickname, uid))

urls = get_urls(uid, args.video)
urls = get_resources(uid, args.video)

user_album = os.path.join(saving_path, nickname)
if urls and not os.path.exists(user_album):
Expand Down

0 comments on commit c3a06fa

Please sign in to comment.