def process_image(image): dir_name = utils.dir_path.format(file_path=image.get('name')) if not os.path.exists(dir_name): os.makedirs(dir_name) with open(dir_name+'\\info.json', 'w') as f: json.dump(image, f) for subkeys in ['large','mid','small']: url = image.get(subkeys) # print(url) if url: utils.download_file(url, utils.get_file_path(url, image.get('name')+ '\\'+ image.get('name'))) break video = image.get('video') if video: utils.download_file(video, utils.get_video_file_path(video, image.get('name')+ '\\video')) stills = image.get('detail') if stills : for i, val in enumerate(stills): for subkeys_val in ['large','small']: image_url = val.get(subkeys_val) if image_url: utils.download_file(image_url, utils.get_file_path(image_url, image.get('name')+ '\\'+ str(i+1))) break
def process_image(image): dir_name = utils.dir_path.format(file_path=image.get('name')) if not os.path.exists(dir_name): os.makedirs(dir_name) with open(dir_name + '\\info.json', 'w') as f: json.dump(image, f) for subkeys in ['board']: url = image.get(subkeys) if url: utils.download_file( url, utils.get_file_path(url, image.get('name') + '\\' + subkeys)) detail = image.get('detail') if detail: for subkeys in ['large', 'mid', 'small']: url = detail.get(subkeys) if url: utils.download_file( url, utils.get_file_path( url, image.get('name') + '\\' + image.get('name'))) break video = detail.get('video') if video: utils.download_file( video, utils.get_video_file_path(video, image.get('name') + '\\video'))
def process_image(image): dir_name = utils.dir_path.format(file_path=image.get('name')) if not os.path.exists(dir_name): os.makedirs(dir_name) with open(dir_name + '\\info.json', 'w') as f: json.dump(image, f) for subkeys in ['mid', 'small']: url = image.get(subkeys) # print(url) if url: utils.download_file( url, utils.get_file_path( url, image.get('name') + '\\' + image.get('name'))) break detail = image.get('detail') board = detail.get('board') if board: utils.download_file( board, utils.get_file_path(board, image.get('name') + '\\board')) elif image.get('large'): board = image.get('large') utils.download_file( board, utils.get_file_path(board, image.get('name') + '\\board')) trailer = detail.get('trailer') if trailer: video = trailer[0] utils.download_file( video, utils.get_video_file_path( video, image.get('name') + '\\' + image.get('name'))) stills = detail.get('stills') if stills: for i, val in enumerate(stills): for subkeys_val in ['large', 'small']: image_url = val.get(subkeys_val) if image_url: utils.download_file( image_url, utils.get_file_path( image_url, image.get('name') + '\\' + str(i + 1))) break
def process_image(image): dir_name = utils.dir_path.format(file_path=image.get('brief').get('name')) if not os.path.exists(dir_name): os.makedirs(dir_name) with open(dir_name + '\\info.json', 'w') as f: json.dump(image['brief'], f) board = image.get('brief').get('board') if board: utils.download_file( board, utils.get_file_path( board, "%s\\%s" % (image.get('brief').get('name'), 'board')), headers={'Referer': image.get('brief').get('referer')}) video = image.get('video') if video: for i, val in enumerate(video.get('image_set')): utils.download_file(val, utils.get_file_path( val, "%s\\%s\\%s" % (image.get('brief').get('name'), video.get('name'), str(i + 1))), headers={'Referer': video.get('url')}) utils.download_file( video.get('poster'), utils.get_file_path( video.get('poster'), "%s\\%s\\%s" % (image.get('brief').get('name'), video.get('name'), 'poster')), headers={'Referer': video.get('url')}) for video_item in video.get('src'): utils.download_file(video_item, utils.get_video_file_path( video_item, "%s\\%s\\%s" % (image.get('brief').get('name'), video.get('name'), 'video')), headers={'Referer': video.get('url')}) break with open("%s\\%s\\info.json" % (dir_name, video.get('name')), 'w') as f: json.dump(video, f)
def process_image(image): # print('tid:',threading.currentThread().ident) try: sub_dir_name = "%s\\%s\\%s" % (image.get('site'), image.get('model'), image.get('name')) dir_name = utils.dir_path.format(file_path=sub_dir_name) if not os.path.exists(dir_name): os.makedirs(dir_name) with open(dir_name + '\\info.json', 'w') as f: json.dump(image, f) for subkeys in ['large', 'mid', 'small']: url = image.get(subkeys) # print(url) if url: utils.download_file(url, utils.get_file_path( url, "%s\\%s" % (sub_dir_name, 'board')), headers={'Referer': image.get('url')}) break video = image.get('video') if video: for video_item in video.get('src'): utils.download_file(video_item, utils.get_video_file_path( video_item, "%s\\%s" % (sub_dir_name, 'video')), headers={'Referer': image.get('url')}) break utils.download_file(video.get('poster'), utils.get_file_path( video_item, "%s\\%s" % (sub_dir_name, 'poster')), headers={'Referer': image.get('url')}) except: print('process_image error occured!')