Commits

Anonymous committed 879a12c

Support for put.io

Comments (0)

Files changed (1)

 
 
 def dlfile(link, targetDir):
+    if not os.path.exists(targetDir):
+        # Assume targetDir is a Put.IO OAuth token (WAT)
+        import putio
+        client = putio.Client(targetDir)
+        client.Transfer.add_url(link)
+        return True
+
     url = urlparse.urlparse(link)
     path = os.path.join(targetDir, os.path.basename(url[2]))
     if os.path.exists(path):
     config = ConfigParser.ConfigParser()
     config.read(CFG_FILE)
 
-    targetDir = config.get('shores', 'targetDir')
+    try:
+        targetDir = config.get('shores', 'targetDir')
+    except ConfigParser.NoOptionError:
+        putioToken = config.get('shores', 'putioToken')
+        # FIXME: This is the worst hack ever...
+        targetDir = putioToken
 
     cache = load_cache()
     listOfShows = list_shows()