diff --git a/couchpotato/core/downloaders/putio/__init__.py b/couchpotato/core/downloaders/putio/__init__.py index 60ccad58..48794d9d 100644 --- a/couchpotato/core/downloaders/putio/__init__.py +++ b/couchpotato/core/downloaders/putio/__init__.py @@ -30,7 +30,7 @@ config = [{ }, { 'name': 'folder', - 'description': ('The folder on putio where you want the upload to go','Must be a folder in the root directory'), + 'description': ('The folder on putio where you want the upload to go','Will find the first first folder that matches this name'), 'default': 0, }, { diff --git a/couchpotato/core/downloaders/putio/main.py b/couchpotato/core/downloaders/putio/main.py index ce58ff7c..478d15c9 100644 --- a/couchpotato/core/downloaders/putio/main.py +++ b/couchpotato/core/downloaders/putio/main.py @@ -28,6 +28,19 @@ class PutIO(DownloaderBase): return super(PutIO, self).__init__() + # This is a recusive function to check for the folders + def recursionFolder(self, client, folder, tfolder): + files = client.File.list(folder) + for f in files: + if f.name == tfolder and f.content_type == "application/x-directory": + return f.id + elif f.content_type == "application/x-directory": + result = self.recursionFolder(client, f.id, tfolder) + if result != 0: + return result + return 0 + + # This will check the root for the folder, and kick of recusively checking sub folder def convertFolder(self, client, folder): if folder == 0: return 0 @@ -36,6 +49,10 @@ class PutIO(DownloaderBase): for f in files: if f.name == folder and f.content_type == "application/x-directory": return f.id + elif f.content_type == "application/x-directory": + result = self.recursionFolder(client, f.id, folder) + if result != 0: + return result #If we get through the whole list and don't get a match we will use the root return 0