Hundter / qBittorrent-Ratio-Manager

Per category and private/public control of ratio limits
GNU General Public License v3.0
29 stars 6 forks source link

ModuleNotFoundError: No module named 'resources.CategoryProfile' #3

Closed BinsonBuzz closed 4 years ago

BinsonBuzz commented 4 years ago

Thanks for pulling this together. It's exactly what I need if I can get it running. I get this error when I try to run:

ModuleNotFoundError: No module named 'resources.CategoryProfile'

Am I (probably), doing something stupid? Thanks

root: pip3 install jsonschema requests
Requirement already satisfied: jsonschema in /usr/lib64/python3.8/site-packages (3.2.0)
Requirement already satisfied: requests in /usr/lib64/python3.8/site-packages (2.22.0)
Requirement already satisfied: six>=1.11.0 in /usr/lib64/python3.8/site-packages (from jsonschema) (1.14.0)
Requirement already satisfied: setuptools in /usr/lib64/python3.8/site-packages (from jsonschema) (42.0.2)
Requirement already satisfied: pyrsistent>=0.14.0 in /usr/lib64/python3.8/site-packages (from jsonschema) (0.15.7)
Requirement already satisfied: attrs>=17.4.0 in /usr/lib64/python3.8/site-packages (from jsonschema) (19.3.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib64/python3.8/site-packages (from requests) (2019.11.28)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib64/python3.8/site-packages (from requests) (1.25.8)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib64/python3.8/site-packages (from requests) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib64/python3.8/site-packages (from requests) (3.0.4)

root: pip3 install resources
Requirement already satisfied: resources in /usr/lib64/python3.8/site-packages (0.0.1)

root: python3 qbit_ratio_manager.py --url http://192.168.50.60:8080/api/v2 --verbose
Traceback (most recent call last):
  File "/mnt/user/appdata/other/qbittorrent/scripts/qBittorrent-Ratio-Manager/qbit_ratio_manager.py", line 11, in <module>
    from resources.CategoryProfile import CategoryProfile
ModuleNotFoundError: No module named 'resources.CategoryProfile'
BinsonBuzz commented 4 years ago

Sorry, I had another question - how does the private tag work in the example posted in the readme? Does it assume any trackers not listed i.e not tracker.coppersurfer.tk are private? So, if I want to treat two trackers as public and the others as private I have to do the following?

{
    "category": "test",
    "tracker": "public.tracker.1.com",
    "public": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 10000,
        "min_seed_time": 1,
        "max_seed_time": 960,
        "required_seeders": 1
    },
    "tracker": "public.tracker.2.com",
    "public": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 10000,
        "min_seed_time": 1,
        "max_seed_time": 960,
        "required_seeders": 1
    },
# Anything not matching the two items above will go into private
    "private": { 
        "min_seed_ratio": 2,
        "max_seed_ratio": 10000,
        "min_seed_time": 480,
        "max_seed_time": 960,
        "required_seeders": 1
    },
    "delete_files": true,
}

Is it possible to do it the other way around i.e. if not listed as a private tracker, then treat as public? This is safer IMO and a better way as I have fewer private trackers so easier to identify and list, rather the tonne of public tracker urls that might pop up i..e

{
    "category": "test",
    "tracker": "private.tracker.1.com"
    "private": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 10000,
        "min_seed_time": 1,
        "max_seed_time": 960,
        "required_seeders": 1
    },
    "tracker": "private.tracker.2.com"
    "private": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 10000,
        "min_seed_time": 1,
        "max_seed_time": 960,
        "required_seeders": 1
    },
# Anything not matching the two items above will go into public
    "public": { 
        "min_seed_ratio": 2,
        "max_seed_ratio": 10000,
        "min_seed_time": 480,
        "max_seed_time": 960,
        "required_seeders": 1
    },
    "delete_files": true,
}
Hundter commented 4 years ago

Thanks for the nice words.

Did you keep the resources folder in the same folder as qbit_ratio_manager.py? It contains files that the qbit_ratio_manager.py needs to run

Hundter commented 4 years ago

The script already identifies private and public torrents by itself, since qBittorrent already has this information.

The "tracker" option is only useful to you if you want different rules for each tracker in a category and will apply to both private and public torrents for that tracker. Also you can only have one "tracker" option for each .qman

BinsonBuzz commented 4 years ago

Thanks for getting back so quickly and the answer re private/public torrents. I didn't realise qB did this.

Re the initial error, yep it was me - I didn't copy the whole zip - just the script.

I'm getting a new error now though - any ideas? Thanks

root@Highlander:/mnt/cache/appdata/other/qbittorrent/scripts/qBittorrent-Ratio-Manager-master# python3 qbit_ratio_manager.py --url http://192.168.50.60:8080/api/v2 --username xxxxx --password xxxxxxxx --verbose
Traceback (most recent call last):
  File "qbit_ratio_manager.py", line 120, in <module>
    categoryProfile.process_category()
  File "/mnt/cache/appdata/other/qbittorrent/scripts/qBittorrent-Ratio-Manager-master/resources/CategoryProfile.py", line 52, in process_category
    torrents = QBitController.get_torrents_by_category(self.category)
  File "/mnt/cache/appdata/other/qbittorrent/scripts/qBittorrent-Ratio-Manager-master/resources/QBitController.py", line 57, in get_torrents_by_category
    return QBitController.get("torrents/info?category=" + category).json()
  File "/usr/lib64/python3.8/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib64/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hundter commented 4 years ago

Can you post your entire .qman file(s)?

BinsonBuzz commented 4 years ago

using this for a test - named test.qman

{
    "category": "imported",
    "public": {
        "min_seed_ratio": 1,
        "max_seed_ratio": 2,
        "min_seed_time": 1,
        "max_seed_time": 2,
        "required_seeders": 0
    },
    "private": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 20,
        "min_seed_time": 360,
        "max_seed_time": 361,
        "required_seeders": 1
    },
    "delete_files": true
}
Hundter commented 4 years ago

Looking more closely at the error, it's actually the result from qBittorrent that's not being parsed correctly. Are you running a qBittorrent version over 4.20, i haven't tested with any previous versions.

BinsonBuzz commented 4 years ago

I'm running 4.2.1 in docker (https://hub.docker.com/r/binhex/arch-qbittorrentvpn/)

Hundter commented 4 years ago

Can you try putting a slash at the end of your url, like so --url http://192.168.50.60:8080/api/v2/

BinsonBuzz commented 4 years ago

Can you try putting a slash at the end of your url, like so --url http://192.168.50.60:8080/api/v2/

That worked! I knew it'd be me - thanks.

One last question, if I want to have per tracker settings for 2 private trackers, generic settings for other private and public trackers will this work? I'm just cautious about messing up private trackers for obvious reasons.

I've put my per tracker rules first as I'm assuming it works from top-2-bottom.

{
    "category": "imported",
    "public": {
        "min_seed_ratio": 1,
        "max_seed_ratio": 2,
        "min_seed_time": 1,
        "max_seed_time": 2,
        "required_seeders": 0
    },
    "tracker": "private_tracker1.com",
    "private": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 20,
        "min_seed_time": 360,
        "max_seed_time": 360,
        "required_seeders": 1
    },
    "tracker": "private_tracker2.com",
    "private": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 5,
        "min_seed_time": 180,
        "max_seed_time": 180,
        "required_seeders": 1
    },
# other private other than private_tracker1.com and private_tracker2.com get picked up by next rule
    "private": {
        "min_seed_ratio": 2,
        "max_seed_ratio": 20,
        "min_seed_time": 360,
        "max_seed_time": 361,
        "required_seeders": 1
    },
    "delete_files": true
}
Hundter commented 4 years ago

Great!

First you can only have one "tracker" entry for each .qman file and it will apply to both private and public torrents from that tracker.

Second, if you want tracker specific options you SHOULD NOT have any generic options for the same category, as they will apply to every torrent in that category, even the ones you also have tracker specific options for.

Lastly, the tracker url you should be using in the "tracker" option is not for example "iptorrents.com", but rather one of the actual trackers that they use in their torrents, fx "routing.bgp.technology", you can find these in qBittorrent.

BinsonBuzz commented 4 years ago

got it:

Perfect - works just how I want. Thanks again

Hundter commented 4 years ago

Exactly :) Feel free to ask again if more confusions arise. I admit it's not perfectly simple, but i'm yet to find better ways to structure the configuration options.