diff --git a/setup.cfg b/setup.cfg index b842253..a9868b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,7 @@ [tool:pytest] flake8-max-line-length = 99 +markers = + non_travis [flake8] max-line-length = 99 diff --git a/tests/test_doc.py b/tests/test_doc.py index aa689ed..3e02ba3 100644 --- a/tests/test_doc.py +++ b/tests/test_doc.py @@ -1,15 +1,18 @@ from datetime import datetime +from pathlib import Path def test_arg_option_doc(): - with open('README.rst') as f: + readme_path = Path(__file__).parent.parent / 'README.rst' + with readme_path.open() as f: content = f.read() option_parts = content.split('Options\n-------')[1].split('Video options\n')[0].strip() option_parts = option_parts.splitlines()[1:-1] option_parts = [x.split(' ', 2) for x in option_parts] for idx, x in enumerate(option_parts): option_parts[idx][2] = x[2].strip() - with open('we_get/core/we_get.py') as f: + we_get_path = Path(__file__).parent.parent / 'we_get' / 'core' / 'we_get.py' + with we_get_path.open() as f: m_content = f.read() m_option_parts = m_content.split('Options:')[1].split('Video options')[0].strip().splitlines() m_option_parts = [x.strip().split(' ', 2) for x in m_option_parts] @@ -20,7 +23,8 @@ def test_arg_option_doc(): def test_year(): current_year = datetime.now().year - with open('we_get/core/we_get.py') as f: + path = Path(__file__).parent.parent / 'we_get' / 'core' / 'we_get.py' + with path.open() as f: m_content = f.read() m_content.splitlines()[1] year = m_content.split('Copyright (c) 2016-')[1].split(' ')[0] diff --git a/tests/test_the_pirate_bay.py b/tests/test_the_pirate_bay.py index 5659b99..1240cf2 100644 --- a/tests/test_the_pirate_bay.py +++ b/tests/test_the_pirate_bay.py @@ -7,7 +7,8 @@ def test_search(): from we_get.modules.the_pirate_bay import the_pirate_bay cl = the_pirate_bay('') cl.search_query = 'ubuntu' - with vcr.use_cassette('fixtures/test_the_pirate_bay_test_search.yaml', record_mode='new_episodes'): + with vcr.use_cassette( + 'fixtures/test_the_pirate_bay_test_search.yaml', record_mode='new_episodes'): res = cl.search() assert res assert any('user_status' in res[k] for k in res) diff --git a/we_get/core/utils.py b/we_get/core/utils.py index 7497590..884529d 100644 --- a/we_get/core/utils.py +++ b/we_get/core/utils.py @@ -38,6 +38,7 @@ 'user_status_vip': 'magenta' } + def format_help(doc, errmsg): """ format_help: fix help message. """ diff --git a/we_get/core/we_get.py b/we_get/core/we_get.py index a02f7f3..89b876a 100644 --- a/we_get/core/we_get.py +++ b/we_get/core/we_get.py @@ -38,7 +38,7 @@ -n --results= Number of results to retrieve. -S --sort-type= Sort torrents by name/seeds [default: seeds]. -c --config= Load config file. - -w --sfw Restrict results to safe for work content (the_pirate_bay only) + -w --sfw Restrict results to safe for work content (the_pirate_bay only) Video options: -q --quality= Try to match quality for the torrent (720p,1080p, ...). diff --git a/we_get/modules/the_pirate_bay.py b/we_get/modules/the_pirate_bay.py index a807a24..553d58f 100644 --- a/we_get/modules/the_pirate_bay.py +++ b/we_get/modules/the_pirate_bay.py @@ -2,10 +2,7 @@ Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/) See the file 'LICENSE' for copying permission """ -from bs4 import BeautifulSoup - from we_get.core.module import Module -import re import urllib import json @@ -14,7 +11,7 @@ API_SEARCH_LOC = "/q.php?q=" ALI_LIST_LOC = "/precompiled/data_top100_all.json" API_SFW_FILTER = "&cat=100,200,300,400,600" -API_TRACKERS = "&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2850%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce" +API_TRACKERS = "&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2850%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce" # NOQA class the_pirate_bay(object): @@ -41,7 +38,7 @@ def parse_pargs(self): self.filter = API_SFW_FILTER def generate_magnet(self, data): - return f"magnet:?xt=urn:btih:{data['info_hash']}&dn={urllib.parse.quote(data['name'])}{API_TRACKERS}" + return f"magnet:?xt=urn:btih:{data['info_hash']}&dn={urllib.parse.quote(data['name'])}{API_TRACKERS}" # NOQA def _parse_data(self, data): for row in json.loads(data):