Created
July 10, 2016 00:23
-
-
Save koteq/04bb8504cfd84f545d60efb4dc7b73fc to your computer and use it in GitHub Desktop.
Adapter to pair Taiga with qBittorrent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import argparse | |
# pip install requests | |
import requests | |
def main(): | |
# Sometimes Taiga ends directory argument with slash `\" ` which leads | |
# to total wreck of argumens. Next code is here to solve the issue. | |
raw_args = [] | |
for arg in sys.argv[1:]: | |
if '" ' in arg: | |
raw_args.extend(arg.split('" ')) | |
else: | |
raw_args.append(arg) | |
if len(raw_args) > 3: | |
raw_args[2:] = [' '.join(raw_args[2:])] | |
parser = argparse.ArgumentParser(prefix_chars='-/') | |
parser.add_argument('/directory', action='store') | |
parser.add_argument('torrent_file') | |
args = parser.parse_args(raw_args) | |
if os.path.isfile(args.torrent_file): | |
with open(args.torrent_file, 'rb') as f: | |
r = requests.post( | |
'http://localhost:8080/command/upload', | |
files={'fileselect[]': f}, | |
data={ | |
'category': 'Taiga', | |
'savepath': args.directory, | |
} | |
) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sry to ask, but please can i have a breakdown of what this is how do i use it, in laymans terms. i just really want to use qbittorent with taiga.