assign_category
> First commit to this repo. > Adding program used to auto assign a category in qbittorrent.
This commit is contained in:
		
							
								
								
									
										52
									
								
								assign_category.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								assign_category.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| #!/usr/lib/python3 | ||||
| # | ||||
| #   qBittorrent-api: | ||||
| #   https://qbittorrent-api.readthedocs.io/en/v2023.4.47/introduction.html | ||||
| # | ||||
| # | ||||
| # | ||||
| import sys | ||||
| import qbittorrentapi | ||||
|  | ||||
| # User access info | ||||
| qbitt_username = '<username>' | ||||
| qbitt_password = '<password>' | ||||
|  | ||||
| # qbittorrent webui address. | ||||
| #url = 'http://192.168.1.59:8080' | ||||
| url = 'http://<ip_address>:<port>' | ||||
|  | ||||
| # The categories to use for matching torrents | ||||
| category_1080_shows = "1080+ | Shows" | ||||
| category_1080_movies = "1080+ | Movies" | ||||
|  | ||||
| # Connect to the qBittorrent API | ||||
| qb = qbittorrentapi.Client(host=url) | ||||
|  | ||||
| # Log in qbittorrent API | ||||
| qb.auth_log_in(username=qbitt_username, password=qbitt_password) | ||||
|  | ||||
| # Get information about all torrents in the download queue | ||||
| torrents = qb.torrents_info() | ||||
|  | ||||
| # loop through the torrents | ||||
| for torrent in torrents: | ||||
|     #print(torrent['name']) | ||||
|     #print(torrent['hash']) | ||||
|     | ||||
|     # Get the name of the completed torrent from the command line arguments inside qbittorrent | ||||
|     torrent_name = sys.argv[1]  # Name of the added torrent as defined by "%N" in qbittorrent settings. | ||||
|     torrent_hash = sys.argv[2]  # Hash of the added torrent as defined by "%I" in qbittorrent settings. | ||||
|     #print(torrent_name) | ||||
|     #print(torrent_hash) | ||||
|  | ||||
|     # Checking to see if added torrent is by YTS and is 1080p or 4k.  | ||||
|     if "1080p" in torrent_name or "2160p" in torrent_name and "YTS.MX" in torrent_name:      | ||||
|  | ||||
|         # Set the category of the torrent. | ||||
|         qb.torrents_set_category(category=category_1080_movies, hashes=torrent_hash) | ||||
|         # Set torrent to auto management to update the save path. | ||||
|         qb.torrents_set_auto_management(hashes=torrent_hash, enable=True)      | ||||
|  | ||||
| # Disconnect from the qBittorrent API | ||||
| qb.auth_log_out() | ||||
		Reference in New Issue
	
	Block a user