Merge pull request #45 from geraldobraz/master

Removing the Utils class.
This commit is contained in:
Juanjo Salvador
2019-10-04 19:00:24 +02:00
committed by GitHub
4 changed files with 200 additions and 209 deletions

View File

@@ -1,10 +1,7 @@
import requests import requests
import urllib.parse import urllib.parse
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from NyaaPy.utils import Utils from NyaaPy.utils import utils
utils = Utils()
class Nyaa: class Nyaa:

View File

@@ -1,8 +1,5 @@
import requests import requests
from NyaaPy.utils import Utils from NyaaPy.utils import utils
utils = Utils()
class Pantsu: class Pantsu:

View File

@@ -1,7 +1,6 @@
import requests import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from NyaaPy.utils import Utils as utils from NyaaPy.utils import utils
class SukebeiNyaa: class SukebeiNyaa:
def search(self, keyword, **kwargs): def search(self, keyword, **kwargs):

View File

@@ -4,9 +4,7 @@
import re import re
def nyaa_categories(self, b):
class Utils:
def nyaa_categories(self, b):
c = b.replace('/?c=', '') c = b.replace('/?c=', '')
cats = c.split('_') cats = c.split('_')
@@ -71,7 +69,7 @@ class Utils:
return category_name return category_name
def parse_nyaa(self, table_rows, limit): def parse_nyaa(self, table_rows, limit):
if limit == 0: if limit == 0:
limit = len(table_rows) limit = len(table_rows)
@@ -94,7 +92,7 @@ class Utils:
try: try:
torrent = { torrent = {
'id': block[1].replace("/view/", ""), 'id': block[1].replace("/view/", ""),
'category': Utils.nyaa_categories(self, block[0]), 'category': nyaa_categories(self, block[0]),
'url': "http://nyaa.si{}".format(block[1]), 'url': "http://nyaa.si{}".format(block[1]),
'name': block[2], 'name': block[2],
'download_url': "http://nyaa.si{}".format(block[4]), 'download_url': "http://nyaa.si{}".format(block[4]),
@@ -112,7 +110,7 @@ class Utils:
return torrents return torrents
def parse_single(self, content): def parse_single(self, content):
torrent = {} torrent = {}
data = [] data = []
torrent_files = [] torrent_files = []
@@ -145,7 +143,7 @@ class Utils:
return torrent return torrent
def parse_sukebei(self, table_rows, limit): def parse_sukebei(self, table_rows, limit):
if limit == 0: if limit == 0:
limit = len(table_rows) limit = len(table_rows)
@@ -166,7 +164,7 @@ class Utils:
try: try:
torrent = { torrent = {
'id': block[1].replace("/view/", ""), 'id': block[1].replace("/view/", ""),
'category': Utils.sukebei_categories(self, block[0]), 'category': sukebei_categories(self, block[0]),
'url': "http://sukebei.nyaa.si{}".format(block[1]), 'url': "http://sukebei.nyaa.si{}".format(block[1]),
'name': block[2], 'name': block[2],
'download_url': "http://sukebei.nyaa.si{}".format( 'download_url': "http://sukebei.nyaa.si{}".format(
@@ -183,7 +181,7 @@ class Utils:
return torrents return torrents
def sukebei_categories(self, b): def sukebei_categories(self, b):
c = b.replace('/?c=', '') c = b.replace('/?c=', '')
cats = c.split('_') cats = c.split('_')
@@ -218,8 +216,8 @@ class Utils:
return category_name return category_name
# Pantsu Utils # Pantsu Utils
def query_builder(self, q, params): def query_builder(self, q, params):
available_params = ["category", "page", "limit", "userID", "fromID", available_params = ["category", "page", "limit", "userID", "fromID",
"status", "maxage", "toDate", "fromDate", "status", "maxage", "toDate", "fromDate",
"dateType", "minSize", "maxSize", "sizeType", "dateType", "minSize", "maxSize", "sizeType",