Skip to content

Commit

Permalink
Merge pull request rachmadaniHaryono#28 from rachmadaniHaryono/dev
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
rachmadaniHaryono authored Nov 19, 2020
2 parents a5db9ac + 4f57389 commit 0991d15
Show file tree
Hide file tree
Showing 24 changed files with 221 additions and 99 deletions.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ or with ``pip``
Dependencies
============

* `prompt_toolkit <https://github.com/jonathanslenders/python-prompt-toolkit>`_, `docopt <https://github.com/docopt/docopt>`_, `colorama <https://github.com/tartley/colorama>`_
* `prompt_toolkit <https://github.com/jonathanslenders/python-prompt-toolkit>`_, `docopt <https://github.com/docopt/docopt>`_, `colorama <https://github.com/tartley/colorama>`_, `beautifulsoup4 <https://github.com/wention/BeautifulSoup4>`_

and `Python <https://www.python.org/>`_ 3.5 or above

Expand All @@ -66,13 +66,15 @@ Options
===================== =====================================================
-s --search=<text> Search for a torrent.
-l --list List top torrents from modules.
-t --target=<target> Select module to use or 'all' [default: all].
-t --target=<target> Select module to use or 'all' [default: all].
-L --links Output results as links.
-J --json Output results in JSON format.
-G --get-list List targets (supported web-sites).
-f --filter=<str> Match text or regular expression in the torrent name.
-n --results=<n> Number of results to retrieve.
-S --sort-type=<type> Sort torrents by name/seeds [default: seeds].
-c --config=<file> Load config file.
-w --sfw Restrict results to safe for work content (the_pirate_bay only)
===================== =====================================================

Video options
Expand All @@ -83,6 +85,7 @@ Video options
-g --genre=<g> Try to select video genre for the torrent (action, comedy, etc..).
================ ==================================================================


See also ``we-get --help``.

Python Module
Expand Down
5 changes: 3 additions & 2 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog<http://keepachangelog.com/en/1.0.0/>`_
and this project adheres to `Semantic Versioning<http://semver.org/spec/v2.0.0.html>`_.

[Unreleased]
------------
1.1.1 - 2020-11-20
------------------

New
~~~

- user status for pirate bay
- argv for arguments
- pby use api

Changes
~~~~~~~
Expand Down
10 changes: 10 additions & 0 deletions config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[item_color]
# default from we-get 1.1.1
# supported color from colorama 0.4.3
# black, red, green, yellow, blue, magenta, cyan, white
# leeches = red
# target = green
# item = white
# seeds = green
# user_status = green
# user_status_vip = magenta
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cogapp==2.5.1
vcrpy==4.1.1
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ flake8-max-line-length = 99

[flake8]
max-line-length = 99

[mypy]
ignore_missing_imports = True
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying permission
"""


from setuptools import setup, find_packages
version = '1.1.0'
version = '1.1.1'

setup(
name='we-get',
Expand All @@ -20,8 +20,9 @@
install_requires=[
'colorama',
'docopt',
'prompt_toolkit>=2.0.3',
'Pygments>=2.2.0',
'beautifulsoup4',
'prompt-toolkit>=3.0.5',
'Pygments>=2.6.1',
],
extras_require={
'test': ["pytest", "pytest-flake8", 'vcrpy'], },
Expand Down
2 changes: 1 addition & 1 deletion tests/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TestsArguments(unittest.TestCase):
def test_number_of_arguments(self):
args = docopt.docopt(__doc__)
self.assertEqual(len(args), 13)
self.assertEqual(len(args), 15)

def test_required_argument_search(self):
sys.argv = ['prog_name', '--search']
Expand Down
4 changes: 3 additions & 1 deletion tests/test_core_we_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[None, {'arguments': None, 'parguments': {}, 'we_get_run': 0}],
[['--search', 'ubuntu'], {
'arguments': {
'--config': [],
'--filter': [],
'--genre': [],
'--get-list': 0,
Expand All @@ -21,6 +22,7 @@
'--quality': [],
'--results': [],
'--search': ['ubuntu'],
'--sfw': 0,
'--sort-type': [],
'--target': ['all'],
'--version': 0
Expand Down Expand Up @@ -52,7 +54,7 @@ def test_parse_arguments(argv, exp_res):
{
'--filter': [], '--genre': [], '--get-list': 0, '--help': 0, '--json': 0,
'--links': 0, '--list': 0, '--quality': [], '--results': [], '--search': [],
'--sort-type': [], '--target': ['all'], '--version': 0}
'--sort-type': [], '--target': ['all'], '--version': 0, '--config': [], '--sfw': 0}
],
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_the_pirate_bay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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'):
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)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from we_get.core import utils


def test_msg_item():
args = [
'Ubuntu.MATE.16.04.2.[MATE][armhf][img.xz][Uzerus]',
{
'leeches': '2',
'link': 'magnet:?xt=urn:btih:D0F23C109D8662A3FE9338F75839AF8D57E5D4A9'
'&dn=Ubuntu+MATE+16.04.2+%5BMATE%5D%5Barmhf%5D%5Bimg.xz%5D%5BUzerus%5D',
'seeds': '260',
'target': '1337x'}
]
utils.msg_item(*args)
62 changes: 57 additions & 5 deletions tools/README.rst.tmpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
we-get: command-line tool for searching torrents.
#################################################

.. image:: https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square :target:
.. image:: https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square
:target: https://github.com/rachmadaniHaryono/we-get/blob/master/LICENSE


.. image:: https://img.shields.io/aur/version/we-get-git.svg?maxAge=600
:target: https://aur.archlinux.org/packages/we-get-git/

.. class:: head

.. image:: https://raw.githubusercontent.com/wiki/0xl3vi/we-get/screenshots/1.png
.. image:: https://raw.githubusercontent.com/rachmadaniHaryono/we-get/master/res/screenshot.png
:alt: Main screenshot.
:width: 100%
:align: center
Expand Down Expand Up @@ -35,7 +40,7 @@ or with ``pip``
Dependencies
============

* `prompt_toolkit <https://github.com/jonathanslenders/python-prompt-toolkit>`_, `docopt <https://github.com/docopt/docopt>`_, `colorama <https://github.com/tartley/colorama>`_
* `prompt_toolkit <https://github.com/jonathanslenders/python-prompt-toolkit>`_, `docopt <https://github.com/docopt/docopt>`_, `colorama <https://github.com/tartley/colorama>`_, `beautifulsoup4 <https://github.com/wention/BeautifulSoup4>`_

and `Python <https://www.python.org/>`_ 3.5 or above

Expand Down Expand Up @@ -117,7 +122,6 @@ Basic Usage

text = subprocess.check_output("we-get --help", shell=True)

section_keyword = ['Options', 'Video options', 'General options']
section_keywords = ('Options', 'Video options', 'General options')
result_dict = get_raw_text(text, section_keywords)
result_dict = process_raw_text(result_dict)
Expand All @@ -128,9 +132,46 @@ Basic Usage
cog_obj.prout(output_text)
]]]
[[[end]]]
See also ``we-get --help``.

Python Module
-------------

.. code-block:: python

>>> from we_get.core.we_get import WG
>>> we_get = WG()
>>> we_get.parse_arguments(['--search', 'ubuntu', '--target', 'all'])
>>> res = we_get.start(api_mode=True)
OrderedDict([
(
'Ubuntu.MATE.16.04.2.[MATE][armhf][img.xz][Uzerus]', {
'seeds': '260',
'leeches': '2',
'link':
'magnet:?xt=urn:btih:D0F23C109D8662A3FE9338F75839AF8D57E5D4A9'
'&dn=Ubuntu+MATE+16.04.2+%5BMATE%5D%5Barmhf%5D%5Bimg.xz%5D%5BUzerus%5D'
'&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce'
'&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce'
'&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce'
'&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce',
'target': '1337x'}
),
...
])

Older version can use `sys.argv` to input the arguments

.. code-block:: python

>>> import sys
>>> from we_get.core.we_get import WG
>>> we_get = WG()
>>> sys.argv[1:] = ['--search', 'ubuntu', '--target', 'all']
>>> we_get.parse_arguments()
>>> we_get.start(api_mode=True)
...

See also ``we-get --help``.

Supported websites
------------------
Expand All @@ -154,3 +195,14 @@ Licence
-------

MIT: `LICENSE <https://github.com/rachmadaniHaryono/we-get/blob/master/LICENSE>`_.

Testing
=======

Dependencies
------------

* pytest
* pytest-flake8

Run tests with ``python -m pytest --flake8``.
2 changes: 1 addition & 1 deletion we_get/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying permission
"""

Expand Down
2 changes: 1 addition & 1 deletion we_get/core/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying.
"""

Expand Down
2 changes: 1 addition & 1 deletion we_get/core/completer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying.
"""

Expand Down
2 changes: 1 addition & 1 deletion we_get/core/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying.
"""

Expand Down
19 changes: 8 additions & 11 deletions we_get/core/shell.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying.
"""
import logging
import re
from json import dumps
from sys import stdout
from we_get.core.utils import printc
from we_get.core.utils import printc_raw
from we_get.core.utils import color
from we_get.core.utils import msg_item
from we_get.core.utils import msg_error
from we_get.core.commands import COMMANDS
from we_get.core.completer import WGCompleter
from we_get.core.style import we_get_prompt_style

import prompt_toolkit
from prompt_toolkit import prompt
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.history import InMemoryHistory

from we_get.core.commands import COMMANDS
from we_get.core.completer import WGCompleter
from we_get.core.style import we_get_prompt_style
from we_get.core.utils import color, msg_error, msg_item, printc, printc_raw

PROMPT_TOOLKIT_V2 = prompt_toolkit.__version__.split('.')[0] == '2'
if PROMPT_TOOLKIT_V2:
Expand All @@ -35,6 +31,7 @@ def __init__(self):
self.pargs = None
self.items = None
self.show_links = False
self.item_color = None

def prompt_usage(self):
printc("white", "Usage: help")
Expand All @@ -57,7 +54,7 @@ def prompt_no_command(self, command):

def prompt_show_items(self):
for item in self.items:
msg_item(item, self.items[item])
msg_item(item, self.items[item], self.item_color)

def prompt_verify_command(self, command, args):
for x in COMMANDS:
Expand Down
2 changes: 1 addition & 1 deletion we_get/core/style.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2016-2019 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying.
This code is from the prompt_toolkit library by `Jonathan Slenders`.
Expand Down
Loading

0 comments on commit 0991d15

Please sign in to comment.