Renamed our config file and change the apikey variable to be upper case. This is reflected in search.py where we import this config file. Other changes in the search.py file is to so that when importing our config file we use the complete path of our file so we can run our script from anywhere, and still this file will find our config file. That is not use a relative path.,

This commit is contained in:
2017-11-18 23:03:24 +01:00
parent 8586521d15
commit ff2f822b5e
3 changed files with 10 additions and 16 deletions

View File

@@ -1,8 +0,0 @@
[DEFAULT]
[JACKETT]
JACKETT_HOST = '10.0.0.41'
JACKETT_PORT = '9117'
JACKETT_MAX_SEARCH_RESULT = 1000
RESULTS_PER_PAGE = 75

View File

@@ -1,18 +1,17 @@
[DEFAULT]
[JACKETT]
HOST = CHANGE_THIS_TO_YOUR_JACKETT_HOST_ADDRESS
HOST = CHANGE_THIS_TO_THE_IP_AND_PORT_OF_JACKETT
PATH = torznab/all
LIMIT = 150
JACKETT_MAX_SEARCH_RESULT = 1000
SSL = false
RESULTS_PER_PAGE = 75
apikey = CHANGE_THIS_TO_YOUR_JACKETT_API_KEY
APIKEY = CHANGE_THIS_TO_YOUR_JACKETT_API_KEY
[PIRATEBAY]
HOST = thepiratebay.org
PATH = search
LIMIT = 150
SSL = true
SSL = true

View File

@@ -1,13 +1,16 @@
#!/usr/bin/env python3.6
import configparser
import sys, argparse, json
import sys, argparse, json, os
from jackett import Jackett
from piratebay import Piratebay
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def getConfig():
config = configparser.ConfigParser()
config.read('config.example.ini')
config_dir = os.path.join(BASE_DIR, 'config.example.ini')
config.read(config_dir)
jackett_host = config['JACKETT']['HOST']
jackett_use_ssl = config['JACKETT']['SSL']
@@ -44,7 +47,7 @@ def searchTorrentSite(config, query, site):
config['PIRATEBAY']['LIMIT'], config['PIRATEBAY']['SSL'])
torrents_found = pirate.search(query)
elif site == 'jackett':
jackett = Jackett(config['JACKETT']['apikey'], config['JACKETT']['HOST'],
jackett = Jackett(config['JACKETT']['APIKEY'], config['JACKETT']['HOST'],
config['JACKETT']['PATH'], config['JACKETT']['LIMIT'], config.getboolean('JACKETT', 'SSL'))
torrents_found = jackett.search(query)
@@ -87,4 +90,4 @@ def main():
searchTorrentSite(config, args.query, args.site)
if __name__ == '__main__':
main()
main()