Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import os
- import time
- from pixivpy3 import *
- from multiprocessing import Pool
- api = PixivAPI()
- username = 'username'
- password = 'password'
- path = u'download path'
- os.chdir(path)
- t = time.strftime('%Y-%m')
- if not os.path.exists(t):
- os.mkdir(t)
- def downloadImg(url):
- print(url)
- dp = os.path.join(path, t)
- api.download(url, path=dp)
- def dirFiles(path):
- files = [i[2] for i in os.walk(path)]
- result = []
- for i in files:
- result.extend(i)
- return result
- def main():
- api.login(username=username, password=password)
- files = dirFiles(path)
- favorite = api.me_favorite_works(page=1, per_page=50)
- fav_res = favorite['response']
- image_urls = [i['work']['image_urls'].large for i in fav_res]
- urls = filter(lambda x: os.path.basename(x) not in files, image_urls)
- p = Pool(10)
- p.map(downloadImg, urls)
- p.close()
- p.join()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement