Test nyaa ok
This commit is contained in:
parent
da7f857095
commit
6fd4708b22
41
poetry.lock
generated
41
poetry.lock
generated
@ -602,22 +602,6 @@ files = [
|
|||||||
{file = "html_void_elements-0.1.0-py3-none-any.whl", hash = "sha256:784cf39db03cdeb017320d9301009f8f3480f9d7b254d0974272e80e0cb5e0d2"},
|
{file = "html_void_elements-0.1.0-py3-none-any.whl", hash = "sha256:784cf39db03cdeb017320d9301009f8f3480f9d7b254d0974272e80e0cb5e0d2"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "humanfriendly"
|
|
||||||
version = "10.0"
|
|
||||||
description = "Human friendly output for text interfaces using Python"
|
|
||||||
category = "main"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
|
||||||
files = [
|
|
||||||
{file = "humanfriendly-10.0-py2.py3-none-any.whl", hash = "sha256:1697e1a8a8f550fd43c2865cd84542fc175a61dcb779b6fee18cf6b6ccba1477"},
|
|
||||||
{file = "humanfriendly-10.0.tar.gz", hash = "sha256:6b0b831ce8f15f7300721aa49829fc4e83921a9a301cc7f606be6686a2288ddc"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[package.dependencies]
|
|
||||||
pyreadline = {version = "*", markers = "sys_platform == \"win32\" and python_version < \"3.8\""}
|
|
||||||
pyreadline3 = {version = "*", markers = "sys_platform == \"win32\" and python_version >= \"3.8\""}
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "3.4"
|
version = "3.4"
|
||||||
@ -1023,29 +1007,6 @@ files = [
|
|||||||
ed25519 = ["PyNaCl (>=1.4.0)"]
|
ed25519 = ["PyNaCl (>=1.4.0)"]
|
||||||
rsa = ["cryptography"]
|
rsa = ["cryptography"]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pyreadline"
|
|
||||||
version = "2.1"
|
|
||||||
description = "A python implmementation of GNU readline."
|
|
||||||
category = "main"
|
|
||||||
optional = false
|
|
||||||
python-versions = "*"
|
|
||||||
files = [
|
|
||||||
{file = "pyreadline-2.1.zip", hash = "sha256:4530592fc2e85b25b1a9f79664433da09237c1a270e4d78ea5aa3a2c7229e2d1"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pyreadline3"
|
|
||||||
version = "3.4.1"
|
|
||||||
description = "A python implementation of GNU readline."
|
|
||||||
category = "main"
|
|
||||||
optional = false
|
|
||||||
python-versions = "*"
|
|
||||||
files = [
|
|
||||||
{file = "pyreadline3-3.4.1-py3-none-any.whl", hash = "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb"},
|
|
||||||
{file = "pyreadline3-3.4.1.tar.gz", hash = "sha256:6f3d1f7b8a31ba32b73917cefc1f28cc660562f39aea8646d30bd6eff21f7bae"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest"
|
name = "pytest"
|
||||||
version = "7.2.0"
|
version = "7.2.0"
|
||||||
@ -1809,4 +1770,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.7"
|
python-versions = "^3.7"
|
||||||
content-hash = "a151e081694d505f2ff9e037e1b45e52ab63b1b824baf8e2253bd059c43bb739"
|
content-hash = "55c532d6efbba349d32200a9c181141efd8242f0f9a20223cac14f433e4d059e"
|
||||||
|
@ -58,6 +58,11 @@ class Nyaa(Bridge):
|
|||||||
urls = tds[1].find_all("a")
|
urls = tds[1].find_all("a")
|
||||||
links = tds[2].find_all("a")
|
links = tds[2].find_all("a")
|
||||||
|
|
||||||
|
nb_pages = html.select("ul.pagination li")[-2]
|
||||||
|
current = nb_pages.select_one("span")
|
||||||
|
if current:
|
||||||
|
current.decompose()
|
||||||
|
|
||||||
torrents.append(
|
torrents.append(
|
||||||
RemoteFile(
|
RemoteFile(
|
||||||
bridge=self.__class__.__name__,
|
bridge=self.__class__.__name__,
|
||||||
@ -75,7 +80,7 @@ class Nyaa(Bridge):
|
|||||||
seeds=tds[5].get_text(),
|
seeds=tds[5].get_text(),
|
||||||
leechs=tds[6].get_text(),
|
leechs=tds[6].get_text(),
|
||||||
downloads=tds[7].get_text(),
|
downloads=tds[7].get_text(),
|
||||||
nb_pages=html.select("ul.pagination li")[-2].get_text(),
|
nb_pages=nb_pages.get_text(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ from typing import List
|
|||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from humanfriendly import parse_size
|
|
||||||
from pydantic import HttpUrl, parse_obj_as
|
from pydantic import HttpUrl, parse_obj_as
|
||||||
|
|
||||||
from pynyaata.cache import cache_data
|
from pynyaata.cache import cache_data
|
||||||
@ -73,7 +72,7 @@ class YggTorrent(Bridge):
|
|||||||
comment=tds[3].get_text(),
|
comment=tds[3].get_text(),
|
||||||
comment_url=f"{tds[1].a['href']}#comm",
|
comment_url=f"{tds[1].a['href']}#comm",
|
||||||
torrent=f"{self.base_url}/engine/download_torrent?id={tds[0].div.get_text()}",
|
torrent=f"{self.base_url}/engine/download_torrent?id={tds[0].div.get_text()}",
|
||||||
size=parse_size(tds[5].get_text()),
|
size=tds[5].get_text(),
|
||||||
date=tds[4].div.get_text(),
|
date=tds[4].div.get_text(),
|
||||||
seeds=tds[7].get_text(),
|
seeds=tds[7].get_text(),
|
||||||
leechs=tds[8].get_text(),
|
leechs=tds[8].get_text(),
|
||||||
|
@ -28,12 +28,15 @@ def inactive(remotes: List[RemoteFile]) -> List[RemoteFile]:
|
|||||||
|
|
||||||
|
|
||||||
def blacklist(remotes: List[RemoteFile]) -> List[RemoteFile]:
|
def blacklist(remotes: List[RemoteFile]) -> List[RemoteFile]:
|
||||||
BLACKLIST_WORDS = getenv("BLACKLIST_WORDS", "").split(",")
|
BLACKLIST_WORDS = getenv("BLACKLIST_WORDS", "")
|
||||||
|
|
||||||
|
if not BLACKLIST_WORDS:
|
||||||
|
return remotes
|
||||||
|
else:
|
||||||
return list(
|
return list(
|
||||||
filter(
|
filter(
|
||||||
lambda remote: not any(
|
lambda remote: not any(
|
||||||
word in remote.name.lower() for word in BLACKLIST_WORDS
|
word in remote.name.lower() for word in BLACKLIST_WORDS.split(",")
|
||||||
),
|
),
|
||||||
remotes,
|
remotes,
|
||||||
)
|
)
|
||||||
|
@ -21,7 +21,6 @@ flask = "2.2.2"
|
|||||||
flask-httpauth = "4.7.0"
|
flask-httpauth = "4.7.0"
|
||||||
flask-sqlalchemy = "3.0.2"
|
flask-sqlalchemy = "3.0.2"
|
||||||
flask-wtf = "1.0.1"
|
flask-wtf = "1.0.1"
|
||||||
humanfriendly = "10.0"
|
|
||||||
pg8000 = "1.29.4"
|
pg8000 = "1.29.4"
|
||||||
pydantic = "1.10.4"
|
pydantic = "1.10.4"
|
||||||
pymysql = "1.0.2"
|
pymysql = "1.0.2"
|
||||||
|
@ -1,13 +1,23 @@
|
|||||||
|
# flake8: noqa: E501
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from pynyaata.bridge.nyaa import Nyaa
|
from pynyaata.bridge.nyaa import Nyaa
|
||||||
from pynyaata.types import RemoteFile
|
from pynyaata.types import Color, RemoteFile
|
||||||
|
|
||||||
from pytest import mark
|
from pytest import mark
|
||||||
import requests
|
import requests
|
||||||
from requests_mock import Mocker
|
from requests_mock import Mocker
|
||||||
|
|
||||||
|
|
||||||
|
def normalize(remotes: List[RemoteFile]):
|
||||||
|
for i in range(len(remotes)):
|
||||||
|
remotes[i].seeds = 1
|
||||||
|
remotes[i].leechs = 10
|
||||||
|
remotes[i].downloads = 100
|
||||||
|
|
||||||
|
return remotes
|
||||||
|
|
||||||
|
|
||||||
def test_search_url():
|
def test_search_url():
|
||||||
assert (
|
assert (
|
||||||
Nyaa().search_url()
|
Nyaa().search_url()
|
||||||
@ -37,6 +47,43 @@ async def test_search(requests_mock: Mocker):
|
|||||||
Nyaa().search_url(), text=requests.get("https://nyaa.si/user/Chaussette33").text
|
Nyaa().search_url(), text=requests.get("https://nyaa.si/user/Chaussette33").text
|
||||||
)
|
)
|
||||||
|
|
||||||
remotes: List[RemoteFile] = []
|
remotes: List[RemoteFile] = [
|
||||||
|
RemoteFile(
|
||||||
|
bridge="Nyaa",
|
||||||
|
id=1080919,
|
||||||
|
category="Anime - Non-English-translated",
|
||||||
|
color=Color.DEFAULT,
|
||||||
|
name="Heroic Age intégrale VOSTFR",
|
||||||
|
link="https://nyaa.si/view/1080919",
|
||||||
|
comment=4,
|
||||||
|
comment_url="https://nyaa.si/view/1080919#comments",
|
||||||
|
magnet="magnet:?xt=urn:btih:f610a3cd6360a36c789d1166e5efc12e3a3bb3ca&dn=Heroic%20Age%20int%C3%A9grale%20VOSTFR&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce",
|
||||||
|
torrent="https://nyaa.si/download/1080919.torrent",
|
||||||
|
size=4509715660,
|
||||||
|
date="2018-10-04 16:26:30",
|
||||||
|
seeds=1,
|
||||||
|
leechs=10,
|
||||||
|
downloads=100,
|
||||||
|
nb_pages=1,
|
||||||
|
),
|
||||||
|
RemoteFile(
|
||||||
|
bridge="Nyaa",
|
||||||
|
id=1080916,
|
||||||
|
category="Anime - Non-English-translated",
|
||||||
|
color=Color.DEFAULT,
|
||||||
|
name="Nisekoi VOSTFR S1 + S2 1080p",
|
||||||
|
link="https://nyaa.si/view/1080916",
|
||||||
|
comment=3,
|
||||||
|
comment_url="https://nyaa.si/view/1080916#comments",
|
||||||
|
magnet="magnet:?xt=urn:btih:11c4b4d513260bf293975f1d24d8752ac5073fb1&dn=Nisekoi%20VOSTFR%20S1%20%2B%20S2%201080p&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce",
|
||||||
|
torrent="https://nyaa.si/download/1080916.torrent",
|
||||||
|
size=9878424780,
|
||||||
|
date="2018-10-04 16:17:56",
|
||||||
|
seeds=1,
|
||||||
|
leechs=10,
|
||||||
|
downloads=100,
|
||||||
|
nb_pages=1,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
assert await Nyaa().search() == remotes
|
assert normalize(await Nyaa().search()) == remotes
|
||||||
|
Reference in New Issue
Block a user