Handle downloads which are directories

Bug #346893 reported by Michael Still
4
Affects Status Importance Assigned to Milestone
MythNetTV
New
Undecided
Unassigned

Bug Description

From email on the users list.

If a torrent uses a subdirectory to host the video file, then mythnettv downloads the files in the torrent and saves them correctly, but no import is done, as it tries to import the directory as if it where a file. I guess a simple check in program.py "Import" if the file is actualy a directory should be enough. Then if true recursively check the directory to import any files with an extension like "avi", "mov", "mkv" etc.. If more than one file is detected, then just add to the subtitle a "Part 1 of X" tag.

Revision history for this message
Michael Still (mikal) wrote :

Revision 279 now handles a download which creates a directory with a _single file_ in it correctly. The case where more than one video file is in the directory is not yet handled.

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()...

Revision history for this message
managementboy (managementboy) wrote :

to complete my previous comment, here the last few lines of a torrent download that had more than one file, but only one avi:

The Daily: Daily Show [Apr 1, 2009]~Ekolb --> time left: Download Succeeded!
Done!
Bittorrent download finished, kill download processes
Done
Download OK
Importing /var/lib/mythtv/mythnettv/tmpfUK1Zg
Picked /var/lib/mythtv/mythnettv/tmpfUK1Zg/The Daily Show_040109_PDTV_XviD~Ekolb.avi from the directory
Files in format XVID don't need transcoding
Importing video http://www.mininova.org/tor/2444385...
Setting recording group to Internet TV
Rebuilding seek table
Adding commercial flag job to backend queue
Done

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.