Вы читаете журнал [info]skyer_404

Previous Entry | Next Entry

обещал поделиться скриптом для перевода плейлистов из aimp-а в формат плеера exaile - получите. Написано чисто по-сишному. 

Запуск с параметрами:
$ /usr/bin/python [имя скрипта].py [полныое имя plc файла для обработки] [полное имя m3u файла на выход]
Текст:
import sys
try:
    file_input = open(sys.argv[1], "r")
    text_input = file_input.read()
except:
    print "Unable to read data from file "
    exit()
file_input.close()
i = 0
text_output = "#EXTM3U\n"               
cur_block = 0
sfway = ""
fname = ""
flnth = ""
headr = False
while i < len(text_input) - 1 :
    i += 1
    if text_input[i] == '<' and cur_block == 0 :
        headr = True
        i += 1
        text_output = text_output + "#PLAYLIST: "
    if text_input[i] == ':' :
        if headr == True :
            text_output = text_output + "\n"
        headr = False
    if text_input[i] == '|' :
        cur_block += 1
        i += 1
        if (cur_block - 1) % 12 == 0  and cur_block <> 1 :
            text_output = text_output + "#EXTINF:" + flnth + "," + fname + "\n" + sfway + "\n"
            sfway = ""
            fname = ""
            flnth = ""
    if headr == True :
        text_output += text_input[i]
    if text_input[i] <> '|' and (cur_block - 1) % 12 == 0 :
        sfway += text_input[i]
    if text_input[i] <> '|' and (cur_block - 5) % 12 == 0 :
        fname += text_input[i]   
    if text_input[i] <> '|' and (cur_block - 6) % 12 == 0 :
        flnth += text_input[i]   
try:
    file_output = open(sys.argv[2], "w")
    file_output.write(text_output)
except:
    print "error"
    exit()
file_output.close()

Яндекс.Метрика






Разработано LiveJournal.com
Designed by Lilia Ahner