This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Feature request: Per RSS Filter download directory

Tags: None
(comma "," separated)
reztho
Registered Member
Posts
1
Karma
0
Hi,

it's really needed ktorrent can associate a RSS filter with a directory which aren't the general download directory. Having all the files downloaded by the RSS filters mixed in the same directory is wrong. It doesn't help for file organization :)

The rss plugin for Azureus can do this.

Another helpful thing would be if it's possible to associate a RSS filter to a tracker specifically so the RSS filter doesn't attack all the trackers i configured. Imagine the same file released in two or more trackers and a bad regexp RSS filter ktorrent will try to download all the files being all of them the same just different filenames or a good regexp RSS filter, ktorrent will try to download the same file, when it detects it's the same file it will seed in all the trackers altogether (i didn't try this, it's an example).

Thanks in advance. Bye.
skyphyr
Registered Member
Posts
36
Karma
0
OS

Sun Feb 11, 2007 5:08 pm
Hi Reztho,

I make take a look at this for a later version - the functionality for downloading to a different directory wasn't added until after the rssfeed plugin was written so I can't comment on how much effort this would be to implement.

Though it would require rewriting the file format the rssfeed plugin stores in - which isn't particularly simple as I've have to support translation from the current version to avoid people losing their settings on upgrade.

As far as limiting the filter to particular feeds this may also be doable, but I'll need to think of a clean approach. Though you shouldn't have any issues for the moment with anything that can be regarded as a TV show and limited issues with others. i.e. any given episode will only download once as it'll check the history to see if it's already been downloaded. So that will prevent issues there - for other types it will add the new torrent in. If it's the same torrent it'll just add a new tracker in without any problem. Otherwise the torrent will be added - so multiple, different releases of the same thing will trigger multiple downloads.

I could add an option whereby it only ever downloads one match for your filter when changing the format. This would allow you to download only the first item which matched your filter (though this kind of this kills some of the purpose of automatic downloading - if you only need it once then you may as well do it by hand).

Cheers,

Alan.
Stormhierta
Registered Member
Posts
11
Karma
0

Mon Jul 16, 2007 9:01 am
I'd like to second the wish for separate download entries for each autodownload, it allows me to keep seeding a file for months since it is already in the place I need it to be.

Thanks in advance!
randomjohn
Registered Member
Posts
9
Karma
0

Thu Aug 02, 2007 6:29 pm
I'd like to "third" this request. This is the #1 feature I'm looking for in a torrent client (and the #1 thing I miss from utorrent). I love the way ktorrent handles shows/seasons/episodes, but I really hate having to move the files every time or change the download directory if I happen to be around and catch it while downloading. As someone said previously, this would also be good for the community as it encourages longer seeding - personally, except with some private trackers, I never bother re-seeding after I have to move a file. If I don't have to move it, I'll seed it longer. Also, I watch the shows from another machine (xbox media center, actually) and don't want to mount the directory in which all my downloads go; I have my shows and movies organized nicely elsewhere for access by most of my network.
koantmob
Registered Member
Posts
2
Karma
0

Python script to sort episodes

Mon Sep 24, 2007 11:46 am
Hi all,
I managed to whip up some python code to sort downloaded episodes into proper directories. I run this script as a cron job every 5 minutes. It checks the files in Ktorrent completed downloads directory and compares the filenames against regular expressions found in a config file. If a match is found, then the file is moved to the directory specified in the config file.

The Python script is like this:

Code: Select all
#!/usr/bin/env python
# Episodemover moves tv show episodes from a general downloads directory
# to predefined directories based on a regexp config file.

import os
import shutil
import sys
import re
import csv

def main(argv=None):
   if argv is None:
      argv = sys.argv

   if argv is None or len(argv) <= 1:
      print "Error: no settings file provided"
      return 2
   else:
      path = argv[1]
      
   if os.path.isfile(path):
       # Parse settings file
       downloadDir,episodeRules = readsettings(path)
       # Act based on settings
       checkMatchesInDownloadDirectory(downloadDir, episodeRules)
   else:
      print "Error:", path, "is not a file"
      return 2

# Reads settings from the specified comma separated file
# Returns the download directory and a dictionary of regexp rules
def readsettings(path):
    fileHandle = open (path, 'r')
    reader = csv.reader(open(path, "r"))
   
    # Dictionary of regexp,directory values
    episodeRules = {}
   
    for row in reader:
        if len(row)<1:
            # Skip blanks
            continue
        elif row[0].startswith("#"):
            # Ignore comments
            continue
        elif row[0]=="DOWNLOAD_DIR":   
            # set download directory
            downloadDir = row[1]
        else:
            # store rule
            episodeRules[row[0]]=row[1]
   
    fileHandle.close()   
   
    return downloadDir,episodeRules

# Iterate over files in downloads_directory and try to match each file
# against the episodeRules   
def checkMatchesInDownloadDirectory(downloadDir, episodeRules):
    for fileName in os.listdir ( downloadDir ):
        targetDir = checkAgainstRules(fileName,episodeRules)
        if len(targetDir)<1:
            print "No target dir or match found for file: ", fileName
        else:
            moveFile(downloadDir,fileName,targetDir)
               
# Check a fileName against the dictionary of regular expressions
# Returns the target directory if a match is found               
def checkAgainstRules(fileName, episodeRules):
    for rule,targetDir in episodeRules.iteritems():
        filePattern = re.compile(rule, re.IGNORECASE)
        if filePattern.match ( fileName ):
            print 'Regexp "', rule, '" matches: ', fileName
            return targetDir

    print 'No match: ', fileName

    # If no rule matches
    return ""

# Moves given file from source directory to target directory
def moveFile(sourceDir,sourceFilename,targetDir):
    # get the absolute path of the source file
    sourceFile = sourceDir + "/" + sourceFilename
   
    # Boolean flags
    sourceIsFile=0
    targetDirExists=0
    targetFileExists=1
   
    # Check that the source file exists and isn't a directory
    if os.path.isfile(sourceFile):
        sourceIsFile=1
    else:
        print "source is not a file: ", sourceFile

    # Check that target directory exists and is a directory       
    if os.path.isdir(targetDir):
        targetDirExists=1
    else:
        print "target is not a directory: ", targetDir

    # get the absolute path of the destination file         
    targetFile = targetDir + "/" + sourceFilename
   
    # Check that the file doesn't already exist
    if os.path.exists(targetFile):
        print "target exists: ", targetFile
    else:
        targetFileExists=0

    # If flags allow moving, then proceed       
    if(targetFileExists==0 and sourceIsFile==1 and targetDirExists==1):
        shutil.move(sourceFile,targetFile)
    else:
        print "Can't move..."
                       
if __name__ == "__main__":
   sys.exit(main())



The config file is like this:
Code: Select all
# Episode Mover Config file
# All lines starting with # are ignored
# this file consists of comma separated values
# Each line has a rule which consists of
#       regexp,targetDirectory[,comment]
# Which is used to match against a filename of a downloaded episode
# and to move it to targetDirectory
#
# The line with DOWNLOAD_DIR as the regexp is a special case
DOWNLOAD_DIR,/var/media/torrents/Ktorrent_completed
greys.anatomy,/var/media/tv/Grey's Anatomy,regexp to matcg Grey's Anatomy
weeds,/var/media/tv/Weeds,regexp to match Weeds
the.daily.show,/var/media/tv/The Daily Show,regexp to match The Daily Show
mythbusters,/var/media/tv/Mythbusters
dexter,/var/media/tv/Dexter
top.gear,/var/media/tv/Top Gear
heroes,/var/media/tv/Heroes


I've placed them both to /etc/episodemover/ and the cron entry to run the script is
Code: Select all
*/5 *   * * *   root    cd /etc/episodemover/ && ./episodemover.py episodemover.conf >> /var/log/episodemover.log


The episodemover.py script is executable (chmod +x).

Hope this is useful to someone.
Regards,
Antti
Stormhierta
Registered Member
Posts
11
Karma
0

Mon Sep 24, 2007 12:41 pm
Does this script transfer the download-connection within kTorrent as well, so that we can continue to share our torrents?
koantmob
Registered Member
Posts
2
Karma
0

Tue Sep 25, 2007 2:37 pm
Stormhierta wrote:Does this script transfer the download-connection within kTorrent as well, so that we can continue to share our torrents?


Sory, but I don't have any idea.
Probably not...

Regards,
Antti


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell