コード例 #1
0
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.get_video_file_path(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
コード例 #2
0
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
コード例 #3
0
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)
        
    url = image.get('poster_image')
    utils.download_file(url, utils.get_file_path(url, image.get('name') + '\\poster_image'))
       
    url = image.get('board_image')
    utils.download_file(url, utils.get_file_path(url, image.get('name') + '\\board_image'))
    
    for keys in ['galleries', 'films','massages']:
        for keys_item in image.get(keys):
            dir_name = utils.dir_path.format(file_path=image.get('name')+'\\'+ keys+'\\'+ keys_item.get('name'))            

            if not os.path.exists(dir_name):
                os.makedirs(dir_name)

            for subkeys in ['large']:
                url = keys_item.get(subkeys)
#
                if url:
                    utils.download_file(url, utils.get_file_path(url, image.get('name')+'\\'+ keys+'\\'+ keys_item.get('name') + '\\board'))
                    break

            for subkeys in ['mid','small']:
                url = keys_item.get(subkeys)
#
                if url:
                    utils.download_file(url, utils.get_file_path(url, image.get('name')+'\\'+ keys+'\\'+ keys_item.get('name') + '\\' + keys_item.get('name')))
                    break 
コード例 #4
0
def process_image(image):
    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:  
    #         utils.download_file(video.get('src'), utils.get_video_file_path(video.get('src'), image.get('name')+
    #                                            '\\video'))     
    #         utils.download_file(video.get('board'), utils.get_file_path(video.get('board'), image.get('name')+
    #                                                '\\video_board'))       
        stills = image.get('detail')  
        if stills :
            for i, val in enumerate(stills):   
                for subkeys_val in ['large','mid','small']:                 
                    image_url = val.get(subkeys_val)
                    if image_url:
                        utils.download_file(image_url, 
                                            utils.get_file_path(image_url, 
                                                                "%s\\%s" %(sub_dir_name,str(i+1))
                                                                ),                                                                     
                                            headers={'Referer':image.get('url')}
                                            )
                        break
    except:
        print('process_image error occured!')
コード例 #5
0
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)

        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('mid'):
        board = image.get('mid')
        utils.download_file(
            board, utils.get_file_path(board,
                                       image.get('name') + '\\board'))
コード例 #6
0
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'))
コード例 #7
0
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)
コード例 #8
0
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!')
コード例 #9
0
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)

    board = image.get('board')
    if board:
        utils.download_file(
            board, utils.get_file_path(board,
                                       image.get('name') + '\\board'))


#     for subkeys in ['small','mid','large']:
#         url = image.get(subkeys)
#   #      print(url)
#         if url:
#              utils.download_file(url, utils.get_file_path(url, image.get('name')+
#                                                '\\'+ subkeys))
#
#     detail = image.get('detail')
#     board = detail.get('board')
#     if board:
#         utils.download_file(board, utils.get_file_path(board, image.get('name')+
#                                                '\\board'))
#
    detail = image.get('detail')
    if detail:
        board_image = detail.get('board_image')
        if board_image:
            utils.download_file(
                board_image,
                utils.get_file_path(board_image,
                                    image.get('name') + '\\board_image'))
        poster_image = detail.get('poster_image')
        if board_image:
            utils.download_file(
                poster_image,
                utils.get_file_path(poster_image,
                                    image.get('name') + '\\poster_image'))

        galleries = detail.get('galleries')
        if galleries:
            for gallery in galleries:
                utils.download_file(
                    gallery.get('img'),
                    utils.get_file_path(
                        gallery.get('img'),
                        image.get('name') + '\\galleries\\' +
                        gallery.get('name') + '\\img'))

                utils.download_file(
                    gallery.get('board'),
                    utils.get_file_path(
                        gallery.get('board'),
                        image.get('name') + '\\galleries\\' +
                        gallery.get('name') + '\\board'))

                detail_s = gallery.get('detail')
                if detail_s:
                    if detail_s.get('board_image'):
                        utils.download_file(
                            detail_s.get('board_image'),
                            utils.get_file_path(
                                detail_s.get('board_image'),
                                image.get('name') + '\\galleries\\' +
                                gallery.get('name') + '\\board_image'))

                    if detail_s.get('images'):
                        for i, val in enumerate(detail_s.get('images')):
                            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') +
                                            '\\galleries\\' +
                                            gallery.get('name') + '\\' +
                                            str(i + 1)))
                                    break

        films = detail.get('films')
        if films:
            for film in films:
                utils.download_file(
                    film.get('img'),
                    utils.get_file_path(
                        film.get('img'),
                        image.get('name') + '\\films\\' + film.get('name') +
                        '\\img'))

                utils.download_file(
                    film.get('board'),
                    utils.get_file_path(
                        film.get('board'),
                        image.get('name') + '\\films\\' + film.get('name') +
                        '\\board'))