@@ -35,18 +35,24 @@ async def getProtectedAndPrivateFromQbit(settingsDict):
3535 if settingsDict ['QBITTORRENT_URL' ]:
3636 # Fetch all torrents
3737 qbitItems = await rest_get (settingsDict ['QBITTORRENT_URL' ]+ '/torrents/info' ,params = {}, cookies = settingsDict ['QBIT_COOKIE' ])
38- # Fetch protected torrents (by tag)
38+
3939 for qbitItem in qbitItems :
40+ # Fetch protected torrents (by tag)
4041 if settingsDict ['NO_STALLED_REMOVAL_QBIT_TAG' ] in qbitItem .get ('tags' ):
4142 protectedDownloadIDs .append (str .upper (qbitItem ['hash' ]))
42- # Fetch private torrents
43- if settingsDict ['IGNORE_PRIVATE_TRACKERS' ]:
44- for qbitItem in qbitItems :
45- qbitItemProperties = await rest_get (settingsDict ['QBITTORRENT_URL' ]+ '/torrents/properties' ,params = {'hash' : qbitItem ['hash' ]}, cookies = settingsDict ['QBIT_COOKIE' ])
46- qbitItem ['is_private' ] = qbitItemProperties .get ('is_private' , None ) # Adds the is_private flag to qbitItem info for simplified logging
47- if qbitItemProperties .get ('is_private' , False ):
48- privateDowloadIDs .append (str .upper (qbitItem ['hash' ]))
49- logger .debug ('main/getProtectedAndPrivateFromQbit/qbitItems: %s' , str ([{"hash" : str .upper (item ["hash" ]), "name" : item ["name" ], "category" : item ["category" ], "tags" : item ["tags" ], "is_private" : item .get ("is_private" , None )} for item in qbitItems ]))
43+
44+ # Fetch private torrents
45+ if settingsDict ['IGNORE_PRIVATE_TRACKERS' ]:
46+ if version .parse (settingsDict ['QBIT_VERSION' ]) >= version .parse ('5.1.0' ):
47+ if qbitItem ['private' ]:
48+ privateDowloadIDs .append (str .upper (qbitItem ['hash' ]))
49+ else :
50+ qbitItemProperties = await rest_get (settingsDict ['QBITTORRENT_URL' ]+ '/torrents/properties' ,params = {'hash' : qbitItem ['hash' ]}, cookies = settingsDict ['QBIT_COOKIE' ])
51+ if qbitItemProperties .get ('is_private' , False ):
52+ privateDowloadIDs .append (str .upper (qbitItem ['hash' ]))
53+ qbitItem ['private' ] = qbitItemProperties .get ('is_private' , None ) # Adds the is_private flag to qbitItem info for simplified logging
54+
55+ logger .debug ('main/getProtectedAndPrivateFromQbit/qbitItems: %s' , str ([{"hash" : str .upper (item ["hash" ]), "name" : item ["name" ], "category" : item ["category" ], "tags" : item ["tags" ], "private" : item .get ("private" , None )} for item in qbitItems ]))
5056
5157 logger .debug ('main/getProtectedAndPrivateFromQbit/protectedDownloadIDs: %s' , str (protectedDownloadIDs ))
5258 logger .debug ('main/getProtectedAndPrivateFromQbit/privateDowloadIDs: %s' , str (privateDowloadIDs ))
@@ -197,6 +203,7 @@ async def instanceChecks(settingsDict):
197203 if not error_occured :
198204 qbit_version = await rest_get (settingsDict ['QBITTORRENT_URL' ]+ '/app/version' ,cookies = settingsDict ['QBIT_COOKIE' ])
199205 qbit_version = qbit_version [1 :] # version without _v
206+ settingsDict ['QBIT_VERSION' ] = qbit_version
200207 if version .parse (qbit_version ) < version .parse (settingsDict ['QBITTORRENT_MIN_VERSION' ]):
201208 error_occured = True
202209 logger .error ('-- | %s *** Error: %s ***' , 'qBittorrent' , 'Please update qBittorrent to at least version %s Current version: %s' ,settingsDict ['QBITTORRENT_MIN_VERSION' ], qbit_version )
0 commit comments