Skip to content Skip to sidebar Skip to footer

Python Ftplib Handbrake Unrecognized File Type

So I am trying to script some video file downloads from my ftp and send them to handbrake for encoding. I was having trouble with keeping the ftp socket open, but due to an amazin

Solution 1:

The solution for me was to send an explicit "TYPE I" Command before performing the transfer

hope this helps someone else new code:

ftp = FTP(myhost,myuser,passw)
    ftp.sendcmd('TYPE I')
    ftp.set_debuglevel(2)
    sock = ftp.transfercmd('RETR ' + filename)
    def background():
        f = open(folder + filename, 'wb')
        while True:
            block = sock.recv(1024*1024)
            ifnot block:
                break
            f.write(block)
        sock.close()
    t = threading.Thread(target=background)
    t.start()
    while t.is_alive():
        t.join(60)
        ftp.voidcmd('NOOP')

Post a Comment for "Python Ftplib Handbrake Unrecognized File Type"