Comment 2 for bug 346893

Revision history for this message
managementboy (managementboy) wrote :

Thanks! Just tested the "single" file version. It works, but if you have any other file, as commonly found in a torrent, it fails. I checked some tutorials an clobbered together a replacement. At line 412 of program.py I changed the logic to this:

    if os.path.isdir(filename):
    for root,dir,files in os.walk(filename):
     filelist = [ os.path.join(root,fi) for fi in files if fi.endswith(".avi")]
        filename = '%s' %(filelist[0])
        out.write('Picked %s from the directory\n' % filename)

in this prove of concept it only detects the first avi file in the torrent, but a few "or"s should make it more flexible.

I tested it with only two torrents that contain an avi and a text file to see if it worked. I am sure it can be done in a nicer way, but for now it works.

As the torrents still get imported with the file size of the .torrent and not the actual video file I suggest using something like getsize()...