From ff2f822b5e538bf92456c49b8118d5c54778502a Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 18 Nov 2017 23:03:24 +0100 Subject: [PATCH] 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., --- torrentSearch/config.example.py | 8 -------- torrentSearch/{config.example.ini => config.ini} | 7 +++---- torrentSearch/search.py | 11 +++++++---- 3 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 torrentSearch/config.example.py rename torrentSearch/{config.example.ini => config.ini} (63%) diff --git a/torrentSearch/config.example.py b/torrentSearch/config.example.py deleted file mode 100644 index ea0be32..0000000 --- a/torrentSearch/config.example.py +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] - - -[JACKETT] -JACKETT_HOST = '10.0.0.41' -JACKETT_PORT = '9117' -JACKETT_MAX_SEARCH_RESULT = 1000 -RESULTS_PER_PAGE = 75 diff --git a/torrentSearch/config.example.ini b/torrentSearch/config.ini similarity index 63% rename from torrentSearch/config.example.ini rename to torrentSearch/config.ini index fd98b57..31937fc 100644 --- a/torrentSearch/config.example.ini +++ b/torrentSearch/config.ini @@ -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 \ No newline at end of file +SSL = true diff --git a/torrentSearch/search.py b/torrentSearch/search.py index 1a30e0f..8b93fa9 100755 --- a/torrentSearch/search.py +++ b/torrentSearch/search.py @@ -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() \ No newline at end of file + main()