Beispiel #1
0
 def deal_file(self):
     try:
         split_file(self.file, self.mode, self.test_mode)
         with open(TMP_FILE, "r") as f:
             result = f.readlines()
         self.finishSignal.emit("".join(result))
     except:
         print("Error")
Beispiel #2
0
def split_by_video(file,
                   names,
                   videos,
                   offset=1,
                   file_name_format="chapters%n"):
    """ Wrapper for split.py that accepts video files as input and calls split.split_files based on indexes found by video times """

    # expand wildcard for Windows, convert to path
    videos = [os.path.normpath(x) for b in videos for x in glob(b)]

    print("Getting video lengths...")
    video_lengths = []
    for filename in videos:
        video_lengths.append(getLength(filename))

    print("Video lengths: {}".format(video_lengths))
    indexes = parse_file(file, video_lengths)
    # Split!
    print("Splitting files")
    split_file(file, names, False, indexes, offset, file_name_format)
def make_mp3s(audio_serial):
    audio_path_full = audio_path + '_clean.wav'
    mp3_img = os.path.join(images_folder, audio_serial).rsplit('_')[0] + '.jpg'
    print 'mp3:', audio_serial
    # Standard
    if 'std' in row[4].lower():
        mp3_track = AudioSegment.from_wav(audio_path_full)
        mp3_track.export(mp3track, format='mp3', bitrate='192', tags={title:row[2], artist:row[1], album:row[2]})
        # Add cover art
        audio = MP3((os.splitext(audio_path_full)[0] + '.mp3'), ID3=ID3)
        # Add ID3 tag if it doesn't exist
        try:
            audio.add_tags()
        except error:
            pass
        audio.tags.add(
            APIC(
                encoding=3, # 3 is for utf-8
                mime='image/jpg', # image/jpeg or image/png
                type=3, # 3 is for the cover image
                desc=u'Cover',
                data=open(mp3_img).read()
            )
        )
        audio.save()
    # Deluxe/45
    else:        
        # Get track listing
        tracks = []
        for i in range(30):
            if row[11 + i]:
                tracks.append(row[11 + i])
            else:
                break
        split.split_file(audio_path_full, format='mp3', bitrate='192', tracks=tracks, artist=row[1], album=row[2], cover=mp3_img)
    # Embed cover thumbnails
    for each_mp3 in os.listdir(mp3_folder):
        if each_mp3.startswith(audio_serial):
            pass # do the thing
Beispiel #4
0
from quicksort import sort
from split import split_file
from merge import merge_files


if __name__ == '__main__':
	# First, lets handle the arguments"
	parser = argparse.ArgumentParser(description='Sort a huge file.')
	parser.add_argument('--input', help='File to sort')
	parser.add_argument('--output', help='Output file')
	parser.add_argument('--tempfile', help='Temporarily output pattern prefix (default: output)', default='output')
	parser.add_argument('--splitsize', help='Number of bytes in each split (default: 10000)', type=int, default=10000)
	args = parser.parse_args()

	# Let's split up the files in manageable smaller files
	splitted_files = split_file(args.input, '%s_{0:04d}.txt' % args.tempfile, args.splitsize)	

	# Sort each individual file
	for split_file in splitted_files:
		sort(split_file, "%s_sorted" % split_file)	
	
	splitted_files_sorted =  ["%s_sorted" % filename for filename in splitted_files]

	# Merge all the files together again
	merge_files(args.output, splitted_files_sorted)

	# Let's clean up the mess we have temporarily created
	for filename in splitted_files + splitted_files_sorted:
		os.remove(filename)

	# Tada