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,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()