Compare commits

20 Commits
0.1 ... master

Author SHA1 Message Date
6109bd2c56 Defined clearer steps in drone build 2022-05-30 22:41:13 +02:00
5bc240ed18 Import of __version__ compatible with wheel & added install make target 2022-05-30 22:32:15 +02:00
be4883d51b Simple make file for building and upload dist 2022-05-30 21:08:49 +02:00
c3ae7e8349 Moved version file to source folder 2022-05-30 21:06:46 +02:00
27f4b67d8b Removed print statement 2022-05-30 20:02:31 +02:00
a9f51551be Convert size to human readable size using imported utils funcs 2022-05-30 20:02:21 +02:00
406efbc7c7 Add bs4 to required packages 2022-05-30 20:01:30 +02:00
a52f5f9690 mport version from separate file 2022-05-30 20:01:09 +02:00
82cfbae900 Fix/drone setup missing packages (#4)
* Trying explicitly defining colored package version.

* Try first installing from requirements.

* Tried defining pyproject file.

* Requirements references setup packages.

* Import __version__ from import statement directly.

* Removed unused packages and restored requirements file.

* Install dependencies before running setup.
2021-07-04 16:18:00 +02:00
cc50e80c3b Update PyPI badge to link to package page. 2021-07-04 15:48:18 +02:00
2f9f30349d Defined long description type as markdown. 2021-07-04 15:34:02 +02:00
dfdcaa846a Correct package import 2021-07-04 15:29:00 +02:00
91c8a3b238 Merge branch 'master' of github.com:KevinMidboe/torrent_search 2021-07-04 15:27:18 +02:00
1899a9f54d Updated to version 0.2 2021-07-04 15:27:11 +02:00
07a0004c4d Setup.py's long description is contents of README. 2021-07-04 15:26:34 +02:00
ad7ac7c71b Renamed config with default_ prefix. 2021-07-04 15:25:34 +02:00
06e00938d5 Moved config file to /Users/kemi01/.config/torrentSearch. 2021-07-04 15:23:44 +02:00
ef4789b246 Moved logger setup to __init__ file. 2021-07-04 15:23:03 +02:00
066f2416d8 Update README.md 2021-07-03 19:27:39 +02:00
254abd7f58 Updated version number 2021-07-03 19:25:54 +02:00
13 changed files with 106 additions and 51 deletions

View File

@@ -8,18 +8,23 @@ platform:
arch: amd64
steps:
- name: Install python
- name: Build package
image: python:3.8
commands:
- python setup.py install
- make build
- name: Run tests
image: python:3.8
commands:
- make install
- pip install pytest
- pytest
- name: Upload coverage report
image: python:3.8
commands:
- python setup.py install
- pip install -r requirements-dev.txt
- make install
- coverage run -m pytest
- codecov -t $CODECOV_TOKEN
environment:

18
Makefile Normal file
View 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)

View File

@@ -1,8 +1,12 @@
# Torrent Search
| Tested version | PyPi package | Drone CI | Travis CI | Code coverage | Known vulnerabilities | License |
|:--------|:------|:------|:------|:------|:------|:------------|
| [![PyVersion](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) | ![PyPI](https://img.shields.io/pypi/v/torrentSearch) | [![Build Status](https://drone.schleppe.cloud/api/badges/KevinMidboe/torrent_search/status.svg)](https://drone.schleppe.cloud/KevinMidboe/torrent_search) | [![Build Status](https://travis-ci.org/KevinMidboe/torrent_search.svg?branch=master)](https://travis-ci.org/KevinMidboe/torrent_search) | [![codecov](https://codecov.io/gh/KevinMidboe/torrent_search/branch/master/graph/badge.svg)](https://codecov.io/gh/KevinMidboe/torrent_search) | [![Known Vulnerabilities](https://snyk.io/test/github/kevinmidboe/torrent_search/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/kevinmidboe/torrent_search?targetFile=requirements.txt) | [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)
| Tested version | PyPi package | Drone CI | Travis CI |
|:--------|:------|:------|:------------|
| [![PyVersion](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) | [![PyPI](https://img.shields.io/pypi/v/torrentSearch)](https://pypi.org/project/torrentSearch/) | [![Build Status](https://drone.schleppe.cloud/api/badges/KevinMidboe/torrent_search/status.svg)](https://drone.schleppe.cloud/KevinMidboe/torrent_search) | [![Build Status](https://travis-ci.org/KevinMidboe/torrent_search.svg?branch=master)](https://travis-ci.org/KevinMidboe/torrent_search)
| Code coverage | Known vulnerabilities | License |
|:--------|:------|:------------|
| [![codecov](https://codecov.io/gh/KevinMidboe/torrent_search/branch/master/graph/badge.svg)](https://codecov.io/gh/KevinMidboe/torrent_search) | [![Known Vulnerabilities](https://snyk.io/test/github/kevinmidboe/torrent_search/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/kevinmidboe/torrent_search?targetFile=requirements.txt) | [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)
## 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.

7
pyproject.toml Normal file
View File

@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"

View File

@@ -1,4 +1,2 @@
beautifulsoup4>=4.6.0
termcolor>=1.1.0
docopt==0.6.2
colored==1.3.5

View File

@@ -2,21 +2,29 @@
# -*- encoding: utf-8 -*-
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(
name='torrentSearch',
version=torrentSearch.__version__,
version=__version__,
packages=find_packages(),
package_data={
'torrentSearch': ['default_config.ini'],
},
author='KevinMidboe',
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=[
'bs4',
'docopt',
'beautifulsoup4',
'termcolor',
'colored',
'colored'
],
url='https://github.com/KevinMidboe/torrent_search',
classifiers=[

View File

@@ -7,4 +7,13 @@ from sys import path
from os.path import dirname
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())

View File

@@ -25,19 +25,12 @@ import logging.config
import signal
from docopt import docopt
from __init__ import __version__
from __version__ import __version__
from search import searchTorrentSite
from utils import ColorizeFilter, getConfig
ch = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(levelname)8s %(name)s | %(message)s')
ch.setFormatter(formatter)
from utils import getConfig
logger = logging.getLogger('torrentSearch')
logger.addHandler(ch)
logger.setLevel(logging.ERROR) # This toggles all the logging in your app
logger.addFilter(ColorizeFilter())
def main():
"""

View File

@@ -0,0 +1,2 @@
__version__ = '0.3.2-5'

View File

@@ -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

View 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

View File

@@ -8,6 +8,7 @@ from xml.etree.ElementTree import fromstring
from http_utils import build_url, fetch_url
from torrent import Torrent
from utils import humansize, representsInteger
logger = logging.getLogger('torrentSearch')
@@ -103,6 +104,8 @@ class Jackett(object):
seeders = elm.get('value')
if elm.get('name') == 'peers':
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: {}\
\n\tseeders: {}\n\tpeers: {}'.format(title, magnet, size, date, seeders, peers))

View File

@@ -7,6 +7,7 @@
import re
import os
import shutil
import logging
import colored
import configparser
@@ -25,19 +26,26 @@ SYMBOLS = {
}
__all__ = ('ColorizeFilter', )
logger = logging.getLogger('torrentSearch')
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'
:rtype: configparser.ConfigParser
"""
config = configparser.ConfigParser()
config_dir = os.path.join(BASE_DIR, 'config.ini')
config.read(config_dir)
config_dir = os.path.join(user_config_dir, 'config.ini')
if not os.path.isfile(config_dir):
defaultConfig = os.path.join(BASE_DIR, 'default_config.ini')
logger.error('Missing config! Moved default_config.ini to {}.\nOpen this file and set all varaibles!'.format(config_dir))
os.makedirs(user_config_dir, exist_ok=True)
shutil.copyfile(defaultConfig, config_dir)
return config
config.read(config_dir)
return config
class ColorizeFilter(logging.Filter):
"""