corrupted torrent while trying to create it
===

I cant really understand why I get this error... if I open the .torrent created with notepad I have: fod6:lengthi3321856e4:name35:Daft%20Punk%20-%20Aerodynamic.mp3.torrent12:piece lengthi332185e6:pieces220:Èî?î
}÷p6*Y?×çÐwåL_/Ffs†%¢Å#7_qJáia¹]mÍÌÍÒ,ÿAŸC!–¯­ 8êî/YYþ¿;“-ª›/Ï~Ï8Ôø"=9éÅ¥®Ñ­î¿Ùûß€lqÿ´ò‘±¾äödïl +Š:Æ6QÅ#ø¾î`8@ÙÕNÇ3³£ÃNÕËáD.LÅ_Í²sÃ½ÿ)6gH¶ð:;§Æ;Bˆc
A|»¬±hõÖ:%.Nïà¸½¬8ºÅ#YA›E<-²®ãi«ß6ù‘–¶—Â=7:privatei1ee8:url-listl62:http://box6.host1free.com/~multiw3/Daft%20Punk%20-%20Aerodynamic.mp358:http://provawebseed.hostoi.com/Daft%20Punk%20-%20Aerodynamic.mp3ee

I think I did the hash pieces parts wrong... but I dont understand why :(

can you help me plsssssssssss?? 


import bencode, hashlib, time

 def get_pieces(file, dimFile, piece_length):
    numero_pieces = int(dimFile/piece_length)
    if(dimFile%piece_length>=0):
        numero_pieces += 1

    pieces = ""
    i = 0
    while i < numero_pieces:
        pieces += hashlib.sha1(file.read(piece_length)).digest()
        i += 1
    return pieces
    

def create_torrent_from_file(file, dimFile, url_list):
    filename = file.name + ".torrent"
    torrent_file = open(filename, "w")
    

    torrent = {}
    torrent["created by"] = "GARRbox"
    torrent["creation date"] = int(time.time())
    torrent["encoding"] = "UTF-8"

    info = {}
    #file singolo
    info["name"] = torrent_file.name
    info["length"] = dimFile #grandezza file in bytes
    #gestione pieces
    piece_length = 512000
    if(512000 >= dimFile/10):
        piece_length = dimFile/10 #dovrei metterla ad un multiplo di 2
    info["piece length"] = piece_length #grandezza pieces in bytes
    #info["pieces"] = "concatenazione dei hash SHA1 di tutti i pieces(byte string, i.e. not urlencoded)"
    info["pieces"] = get_pieces(file, dimFile, piece_length)
    #privato o pubblico
    info["private"] = 1 #disabilito DHT e PEX(peer exchange)

    torrent["info"] = info
    
    #web-seeding
    lista_web_seed = []
    for el in url_list:
        lista_web_seed.append(el + file.name)
    torrent["url-list"] = lista_web_seed


    torrent = bencode.bencode(torrent)
    print torrent

    torrent_file.write(torrent)

    torrent_file.close()

    
###########################################à

def get_file_size(file):
    file.seek(0,2)
    size = file.tell()
    file.seek(0,0)
    return size

##########################################
url_list = "http://box6.host1free.com/~multiw3/", "http://provawebseed.hostoi.com/"
file = open("Daft Punk - Aerodynamic.mp3", "r")
create_torrent_from_file(file, get_file_size(file), url_list)

file.close()