Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6109bd2c56 | |||
| 5bc240ed18 | |||
| be4883d51b | |||
| c3ae7e8349 | |||
| 27f4b67d8b | |||
| a9f51551be | |||
| 406efbc7c7 | |||
| a52f5f9690 | |||
| 82cfbae900 | |||
| cc50e80c3b | |||
| 2f9f30349d | |||
| dfdcaa846a | |||
| 91c8a3b238 | |||
| 1899a9f54d | |||
| 07a0004c4d | |||
| ad7ac7c71b | |||
| 06e00938d5 | |||
| ef4789b246 | |||
| 066f2416d8 | |||
| 254abd7f58 |
11
.drone.yml
11
.drone.yml
@@ -8,18 +8,23 @@ platform:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install python
|
- name: Build package
|
||||||
image: python:3.8
|
image: python:3.8
|
||||||
commands:
|
commands:
|
||||||
- python setup.py install
|
- make build
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
image: python:3.8
|
||||||
|
commands:
|
||||||
|
- make install
|
||||||
- pip install pytest
|
- pip install pytest
|
||||||
- pytest
|
- pytest
|
||||||
|
|
||||||
- name: Upload coverage report
|
- name: Upload coverage report
|
||||||
image: python:3.8
|
image: python:3.8
|
||||||
commands:
|
commands:
|
||||||
- python setup.py install
|
|
||||||
- pip install -r requirements-dev.txt
|
- pip install -r requirements-dev.txt
|
||||||
|
- make install
|
||||||
- coverage run -m pytest
|
- coverage run -m pytest
|
||||||
- codecov -t $CODECOV_TOKEN
|
- codecov -t $CODECOV_TOKEN
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
18
Makefile
Normal file
18
Makefile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
.PHONY: clean
|
||||||
|
binaries=dist build
|
||||||
|
|
||||||
|
install:
|
||||||
|
python3 setup.py install
|
||||||
|
|
||||||
|
dist:
|
||||||
|
python3 setup.py sdist
|
||||||
|
|
||||||
|
build:
|
||||||
|
python3 setup.py build
|
||||||
|
|
||||||
|
upload: clean dist
|
||||||
|
twine upload dist/*
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(binaries)
|
||||||
|
|
||||||
10
README.md
10
README.md
@@ -1,8 +1,12 @@
|
|||||||
# Torrent Search
|
# Torrent Search
|
||||||
|
|
||||||
| Tested version | PyPi package | Drone CI | Travis CI | Code coverage | Known vulnerabilities | License |
|
| Tested version | PyPi package | Drone CI | Travis CI |
|
||||||
|:--------|:------|:------|:------|:------|:------|:------------|
|
|:--------|:------|:------|:------------|
|
||||||
| [](https://www.python.org/downloads/release/python-360/) |  | [](https://drone.schleppe.cloud/KevinMidboe/torrent_search) | [](https://travis-ci.org/KevinMidboe/torrent_search) | [](https://codecov.io/gh/KevinMidboe/torrent_search) | [](https://snyk.io/test/github/kevinmidboe/torrent_search?targetFile=requirements.txt) | [](LICENSE)
|
| [](https://www.python.org/downloads/release/python-360/) | [](https://pypi.org/project/torrentSearch/) | [](https://drone.schleppe.cloud/KevinMidboe/torrent_search) | [](https://travis-ci.org/KevinMidboe/torrent_search)
|
||||||
|
|
||||||
|
| Code coverage | Known vulnerabilities | License |
|
||||||
|
|:--------|:------|:------------|
|
||||||
|
| [](https://codecov.io/gh/KevinMidboe/torrent_search) | [](https://snyk.io/test/github/kevinmidboe/torrent_search?targetFile=requirements.txt) | [](LICENSE)
|
||||||
|
|
||||||
## Idea
|
## Idea
|
||||||
The idea behind this project is to create a modular torrent searcher/indexer in python. Currently we have the option to search for two sites, thepiratebay and with jackett. To add more sites one only needs to create a scraper script for a specific service, and from there create torrent class objects that are returned back to the search script. If the new site needs specific configuration values this can be set in the config.ini file and needs to be imported in the site selector in search.py.
|
The idea behind this project is to create a modular torrent searcher/indexer in python. Currently we have the option to search for two sites, thepiratebay and with jackett. To add more sites one only needs to create a scraper script for a specific service, and from there create torrent class objects that are returned back to the search script. If the new site needs specific configuration values this can be set in the config.ini file and needs to be imported in the site selector in search.py.
|
||||||
|
|||||||
7
pyproject.toml
Normal file
7
pyproject.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = [
|
||||||
|
"setuptools>=42",
|
||||||
|
"wheel"
|
||||||
|
]
|
||||||
|
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
beautifulsoup4>=4.6.0
|
|
||||||
termcolor>=1.1.0
|
|
||||||
docopt==0.6.2
|
docopt==0.6.2
|
||||||
colored==1.3.5
|
colored==1.3.5
|
||||||
|
|||||||
20
setup.py
20
setup.py
@@ -2,21 +2,29 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
from sys import path
|
||||||
|
from os.path import dirname
|
||||||
|
|
||||||
import torrentSearch
|
with open("README.md", "r", encoding="utf-8") as fh:
|
||||||
|
long_description = fh.read()
|
||||||
|
|
||||||
|
exec(open('torrentSearch/__version__.py').read())
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='torrentSearch',
|
name='torrentSearch',
|
||||||
version=torrentSearch.__version__,
|
version=__version__,
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
package_data={
|
||||||
|
'torrentSearch': ['default_config.ini'],
|
||||||
|
},
|
||||||
author='KevinMidboe',
|
author='KevinMidboe',
|
||||||
description='Search For Torrents',
|
description='Search For Torrents',
|
||||||
long_description="README on github : https://github.com/KevinMidboe/torrent_search",
|
long_description=long_description,
|
||||||
|
long_description_content_type='text/markdown',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
'bs4',
|
||||||
'docopt',
|
'docopt',
|
||||||
'beautifulsoup4',
|
'colored'
|
||||||
'termcolor',
|
|
||||||
'colored',
|
|
||||||
],
|
],
|
||||||
url='https://github.com/KevinMidboe/torrent_search',
|
url='https://github.com/KevinMidboe/torrent_search',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
@@ -7,4 +7,13 @@ from sys import path
|
|||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
path.append(dirname(__file__))
|
path.append(dirname(__file__))
|
||||||
|
|
||||||
__version__ = '0.1'
|
import logging
|
||||||
|
from utils import ColorizeFilter
|
||||||
|
ch = logging.StreamHandler()
|
||||||
|
formatter = logging.Formatter('%(asctime)s %(levelname)8s %(name)s | %(message)s')
|
||||||
|
ch.setFormatter(formatter)
|
||||||
|
|
||||||
|
logger = logging.getLogger('torrentSearch')
|
||||||
|
logger.addHandler(ch)
|
||||||
|
logger.setLevel(logging.ERROR) # This toggles all the logging in your app
|
||||||
|
logger.addFilter(ColorizeFilter())
|
||||||
|
|||||||
@@ -25,19 +25,12 @@ import logging.config
|
|||||||
import signal
|
import signal
|
||||||
|
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
from __init__ import __version__
|
from __version__ import __version__
|
||||||
|
|
||||||
from search import searchTorrentSite
|
from search import searchTorrentSite
|
||||||
from utils import ColorizeFilter, getConfig
|
from utils import getConfig
|
||||||
|
|
||||||
ch = logging.StreamHandler()
|
|
||||||
formatter = logging.Formatter('%(asctime)s %(levelname)8s %(name)s | %(message)s')
|
|
||||||
ch.setFormatter(formatter)
|
|
||||||
|
|
||||||
logger = logging.getLogger('torrentSearch')
|
logger = logging.getLogger('torrentSearch')
|
||||||
logger.addHandler(ch)
|
|
||||||
logger.setLevel(logging.ERROR) # This toggles all the logging in your app
|
|
||||||
logger.addFilter(ColorizeFilter())
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
|
|||||||
2
torrentSearch/__version__.py
Normal file
2
torrentSearch/__version__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
__version__ = '0.3.2-5'
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
[DEFAULT]
|
|
||||||
SITE_OPTIONS = piratebay,jackett
|
|
||||||
|
|
||||||
[JACKETT]
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
[PIRATEBAY]
|
|
||||||
HOST = thepiratebay.org
|
|
||||||
PATH = search
|
|
||||||
LIMIT = 150
|
|
||||||
SSL = true
|
|
||||||
18
torrentSearch/default_config.ini
Normal file
18
torrentSearch/default_config.ini
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
SITE_OPTIONS = piratebay,jackett
|
||||||
|
|
||||||
|
[JACKETT]
|
||||||
|
HOST=
|
||||||
|
PATH=torznab/all
|
||||||
|
LIMIT=150
|
||||||
|
JACKETT_MAX_SEARCH_RESULT=1000
|
||||||
|
SSL=false
|
||||||
|
RESULTS_PER_PAGE=75
|
||||||
|
APIKEY=
|
||||||
|
|
||||||
|
|
||||||
|
[PIRATEBAY]
|
||||||
|
HOST=thepiratebay.org
|
||||||
|
PATH=search
|
||||||
|
LIMIT=150
|
||||||
|
SSL=true
|
||||||
@@ -8,6 +8,7 @@ from xml.etree.ElementTree import fromstring
|
|||||||
|
|
||||||
from http_utils import build_url, fetch_url
|
from http_utils import build_url, fetch_url
|
||||||
from torrent import Torrent
|
from torrent import Torrent
|
||||||
|
from utils import humansize, representsInteger
|
||||||
|
|
||||||
logger = logging.getLogger('torrentSearch')
|
logger = logging.getLogger('torrentSearch')
|
||||||
|
|
||||||
@@ -103,6 +104,8 @@ class Jackett(object):
|
|||||||
seeders = elm.get('value')
|
seeders = elm.get('value')
|
||||||
if elm.get('name') == 'peers':
|
if elm.get('name') == 'peers':
|
||||||
peers = elm.get('value')
|
peers = elm.get('value')
|
||||||
|
if size != '' and representsInteger(size):
|
||||||
|
size = humansize(int(size))
|
||||||
|
|
||||||
logger.debug('Found torrent with info: \n\ttitle: {}\n\tmagnet: {}\n\tsize: {}\n\tdate: {}\
|
logger.debug('Found torrent with info: \n\ttitle: {}\n\tmagnet: {}\n\tsize: {}\n\tdate: {}\
|
||||||
\n\tseeders: {}\n\tpeers: {}'.format(title, magnet, size, date, seeders, peers))
|
\n\tseeders: {}\n\tpeers: {}'.format(title, magnet, size, date, seeders, peers))
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
import colored
|
import colored
|
||||||
import configparser
|
import configparser
|
||||||
@@ -25,19 +26,26 @@ SYMBOLS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__all__ = ('ColorizeFilter', )
|
__all__ = ('ColorizeFilter', )
|
||||||
|
logger = logging.getLogger('torrentSearch')
|
||||||
|
|
||||||
def getConfig():
|
def getConfig():
|
||||||
"""
|
"""
|
||||||
Read path and get configuartion file with site settings
|
Read path and get configuartion file with site settings
|
||||||
|
:return: config settings read from 'config.ini'
|
||||||
|
:rtype: configparser.ConfigParser
|
||||||
|
"""
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
user_config_dir = os.path.expanduser("~") + "/.config/torrentSearch"
|
||||||
|
|
||||||
:return: config settings read from 'config.ini'
|
config_dir = os.path.join(user_config_dir, 'config.ini')
|
||||||
:rtype: configparser.ConfigParser
|
if not os.path.isfile(config_dir):
|
||||||
"""
|
defaultConfig = os.path.join(BASE_DIR, 'default_config.ini')
|
||||||
config = configparser.ConfigParser()
|
logger.error('Missing config! Moved default_config.ini to {}.\nOpen this file and set all varaibles!'.format(config_dir))
|
||||||
config_dir = os.path.join(BASE_DIR, 'config.ini')
|
os.makedirs(user_config_dir, exist_ok=True)
|
||||||
config.read(config_dir)
|
shutil.copyfile(defaultConfig, config_dir)
|
||||||
|
|
||||||
return config
|
config.read(config_dir)
|
||||||
|
return config
|
||||||
|
|
||||||
class ColorizeFilter(logging.Filter):
|
class ColorizeFilter(logging.Filter):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user