Esempio n. 1
0
def copy_mp3(music_mp3, usb_mp3):
    for item in music_mp3:
        if item.replace(music_path, usb_path) not in usb_mp3:
            statistics[0] += 1
            ml.print_green('Copying ' + item.strip(music_path))
            if not DEBUG:
                call(['cp', item, item.replace(music_path, usb_path)])
Esempio n. 2
0
def create_missing_folders(music_f, usb_f):

    for item in music_f:
        dest = item.replace(music_path, usb_path)

        if dest not in usb_f:
            statistics[2] += 1

            ml.print_green('Creating ' + dest)
            if not DEBUG:
                call(['mkdir', dest])

        #print("M: " + item)
        #print("D:" + dest)
        subfolders_m = glob(item + '/*')
        subfolders_d = glob(dest + '/*')

        for sub in subfolders_m:
            tras = sub.replace(music_path, usb_path)
            #print("---> " + sub)
            #print(subfolders_m)
            if tras not in subfolders_d:
                ml.print_red("Should be creating " + tras)
                statistics[2] += 1
                if not DEBUG:
                    call(['mkdir', tras])
Esempio n. 3
0
def convert_m4a(music_m4a, usb_mp3):
    try:
        call(['rm', 'temp.mp3'])
    except:
        pass

    for item in music_m4a:
        f_in = item
        temp = check_output(['pwd']).decode().strip('\n')

        l = glob(temp + '/*')
        temp = temp + '/temp.mp3'
        f_out = item.replace(music_path, usb_path)
        f_out = f_out[:len(f_out) - 3] + 'mp3'
        if f_out not in usb_mp3:
            ml.print_green("Converting: " + f_in)
            statistics[4] += 1
            if not DEBUG:
                call([
                    'ffmpeg', '-loglevel', 'quiet', '-i', f_in, '-acodec',
                    'libmp3lame', '-ab', '128k', temp
                ])
                call(['mv', temp, f_out])
Esempio n. 4
0
def print_statistics():
    flag = 1
    for i in statistics:
        if i == 1:
            flag = 0
    if flag == 1:
        ml.print_green('\t\t-------- NO CHANGES MADE --------')
        return

    ml.print_green('\t\tAdded\t\t\t' + str(statistics[0]) + ' songs, ' +
                   str(statistics[2]) + ' folders')
    ml.print_green('\t\tConverted and added\t' + str(statistics[4]) + ' files')
    ml.print_red('\t\tDeleted\t\t\t' + str(statistics[1]) + ' songs, ' +
                 str(statistics[3]) + ' folders')
Esempio n. 5
0
def main():
    ml.print_green('Hola! Starting Program...')
    music_f = glob(music_path + '*')
    usb_f = glob(usb_path + '*')

    music_f = remove_unwanted(music_f, excluded_folders)
    remove_excess_folders(music_f, usb_f)
    create_missing_folders(music_f, usb_f)
    music_mp3 = create_music_mp3()
    music_m4a = create_music_m4a()
    usb_mp3 = glob2(usb_path + '*/**/*.mp3')
    ml.print_green('Source: ' + str(len(music_mp3)) + ' .mp3 and ' +
                   str(len(music_m4a)) + ' .m4a')
    ml.print_green('Destination ' + str(len(usb_mp3)) + ' .mp3')
    remove_old_mp3(music_mp3, music_m4a, usb_mp3)
    copy_mp3(music_mp3, usb_mp3)
    convert_m4a(music_m4a, usb_mp3)

    print_statistics()
    ml.execution_time(start_time)
    return