def make_digital_files(item_list): # Create digital file list digital_file_list = [item for item in item_list if item.digital_ext] if not digital_file_list: logging.info('No digital files to make.') return for item in digital_file_list: if item.image: item.thumb = item.image + '_600x600.jpg' item.thumb_path = os.path.join(thumbs_folder, item.thumb) # Build track filename if item.artist and item.album: item.digital_file_name = '{0} - {1}'.format(item.artist, item.album) elif item.artist or item.album: item.digital_file_name = item.artist or item.album else: item.digital_file_name = 'Untitled - {0}'.format(item.name) item.digital_file_name = item.digital_file_name.translate(None, '<>:|?*') item.digital_file_name = item.digital_file_name.translate(string.maketrans('"/\\', '\'--')) if include_serial_in_digital_filename: item.digital_file_name = '{0} - {1}'.format(item.serial, item.digital_file_name) if just_add_tags: item.digital_rename_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext item.digital_file_path = item.path else: if dropbox_move: item.dropbox_order_folder = os.path.join(dropbox_folder, item.order.lstrip('0')) if not os.path.exists(item.dropbox_order_folder): os.makedirs(item.dropbox_order_folder) item.digital_file_path = os.path.join(item.dropbox_order_folder, item.digital_file_name) + '.' + item.digital_ext else: item.digital_file_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext # Add suffixes for identically-named audio files if not just_add_tags: for i, item in enumerate([item for item in digital_file_list if sum( \ 1 for each_item in digital_file_list if each_item.digital_file_name == item.digital_file_name) > 1]): item.digital_file_name += ' - {0}'.format(str(i + 1)) if dropbox_move: item.digital_file_path = os.path.join(item.dropbox_order_folder, item.digital_file_name) + '.' + item.digital_ext else: item.digital_file_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext logging.info('digital_file_list: ({0}): {1}'.format(len(digital_file_list), [item.name for item in digital_file_list])) if pool_processing: pool = multiprocessing.Pool(multiprocessing.cpu_count() - 1) pool.map(make_thumb, digital_file_list) pool.map(export_digital, digital_file_list) else: for each_file in digital_file_list: make_thumb(each_file) export_digital(each_file) # Send Dropbox emails digital_orders = set([item.order.lstrip('0') for item in digital_file_list]) print 'digital orders:', digital_orders dbox.send_all(digital_orders)
def make_digital_files(item_list): """Create digital file list""" # Filter CD items, copied items, split items digital_file_list = [each_item for each_item in item_list if each_item.digital_ext and not each_item.copy_counter and not each_item.side] if not digital_file_list: logging.info('No digital files to make.') return ''' for item in digital_file_list: # Move original wave to mp3 folder, so we don't see it in the to-burn list if not 'cd' in item.format: try: shutil.move(item.path, os.path.join(digital_folder, item.filename)) try: shutil.move(os.path.splitext(item.path)[0] + '.pkf', os.path.join( digital_folder, os.path.splitext(item.filename)[0] + '.pkf')) except IOError: pass item.path = os.path.join(digital_folder, item.filename) except IOError: logging.warning('IOError while moving digital file {0}. Close all open instances and try again.'.format(item.name)) pass ''' for item in digital_file_list: if item.image: item.thumb = item.image + '_600x600.jpg' item.thumb_path = os.path.join(thumbs_folder, item.thumb) # Build track filename if item.artist and item.album: item.digital_file_name = '{0} - {1}'.format(item.artist, item.album) elif item.artist or item.album: item.digital_file_name = item.artist or item.album else: item.digital_file_name = 'Untitled - {0}'.format(item.name) item.digital_file_name = item.digital_file_name.replace(':', ' -') item.digital_file_name = item.digital_file_name.translate(None, '<>:|?*') # Windows allowed filename chars item.digital_file_name = item.digital_file_name.translate(string.maketrans('"/\\', '\'--')) if include_serial_in_digital_filename: item.digital_file_name = '{0} - {1}'.format(item.serial, item.digital_file_name) if just_add_tags: item.digital_rename_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext item.digital_file_path = item.path else: if dropbox_move: item.dropbox_order_folder = os.path.join(dropbox_folder, item.order.lstrip('0')) if not os.path.exists(item.dropbox_order_folder): os.makedirs(item.dropbox_order_folder) item.digital_file_path = os.path.join(item.dropbox_order_folder, item.digital_file_name) + '.' + item.digital_ext else: item.digital_file_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext # Add suffixes for identically-named audio files if not just_add_tags: for i, item in enumerate([item for item in digital_file_list if sum( \ 1 for each_item in digital_file_list if each_item.digital_file_name == item.digital_file_name) > 1]): item.digital_file_name += ' - {0}'.format(str(i + 1)) if dropbox_move: item.digital_file_path = os.path.join(item.dropbox_order_folder, item.digital_file_name) + '.' + item.digital_ext else: item.digital_file_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext logging.info('digital_file_list: ({0}): {1}'.format(len(digital_file_list), [item.name for item in digital_file_list])) # Loop/multiprocess each file if pool_processing: pool = multiprocessing.Pool(min(multiprocessing.cpu_count() - 1, 5)) pool.map(make_thumb, digital_file_list) pool.map(export_digital, digital_file_list) else: for each_file in digital_file_list: make_thumb(each_file) export_digital(each_file) # Send Dropbox emails digital_orders = set([item.order.lstrip('0') for item in digital_file_list]) logging.info(' - Digital orders:') for each_order in digital_orders: logging.info(' - {0}'.format(each_order)) dbox.send_all(digital_orders)
def make_digital_files(item_list): """Create digital file list""" # Flush stdout buffer for real-time console output sys.stdout.flush() # Filter CD items, copied items, split items digital_file_list = [each_item for each_item in item_list if each_item.digital_ext and not each_item.copy_counter and not each_item.side] if not digital_file_list: logging.info('No digital files to make.') return for item in digital_file_list: if item.image: item.thumb = item.image + '_600x600.jpg' item.thumb_path = os.path.join(config.thumbs_folder, item.thumb) # Build track filename if item.artist and item.album: item.digital_file_name = '{0} - {1}'.format(item.artist, item.album) elif item.artist or item.album: item.digital_file_name = item.artist or item.album else: item.digital_file_name = 'Untitled - {0}'.format(item.name) item.digital_file_name = item.digital_file_name.replace(':', ' -') item.digital_file_name = item.digital_file_name.translate(None, '<>:|?*') # Windows allowed filename chars item.digital_file_name = item.digital_file_name.translate(string.maketrans('"/\\', '\'--')) if config.include_serial_in_digital_filename: item.digital_file_name = '{0} - {1}'.format(item.serial, item.digital_file_name) if config.just_add_tags: item.digital_rename_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext item.digital_file_path = item.path else: if config.dropbox_move: item.dropbox_order_folder = os.path.join(config.dropbox_folder, item.order.lstrip('0')) if not os.path.exists(item.dropbox_order_folder): os.makedirs(item.dropbox_order_folder) item.digital_file_path = os.path.join(item.dropbox_order_folder, item.digital_file_name) + '.' + item.digital_ext else: item.digital_file_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext # Add suffixes for identically-named audio files if not config.just_add_tags: for i, item in enumerate([item for item in digital_file_list if sum( \ 1 for each_item in digital_file_list if each_item.digital_file_name == item.digital_file_name) > 1]): item.digital_file_name += ' - {0}'.format(str(i + 1)) if config.dropbox_move: item.digital_file_path = os.path.join(item.dropbox_order_folder, item.digital_file_name) + '.' + item.digital_ext else: item.digital_file_path = os.path.join(digital_folder, item.digital_file_name) + '.' + item.digital_ext logging.info('digital_file_list: ({0}): {1}'.format(len(digital_file_list), [item.name for item in digital_file_list])) # Loop/multiprocess each file if config.pool_processing: pool = multiprocessing.Pool(min(multiprocessing.cpu_count() - 1, 5)) pool.map(make_thumb, digital_file_list) pool.map(export_digital, digital_file_list) else: for each_file in digital_file_list: make_thumb(each_file) export_digital(each_file) # Send Dropbox emails digital_orders = set([item.order.lstrip('0') for item in digital_file_list]) logging.info(' - Digital orders:') for each_order in digital_orders: logging.info(' - {0}'.format(each_order)) dbox.send_all(digital_orders)