Added logging and stricter import of functions from local scripts.
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
#!/usr/bin/env python3.6
|
#!/usr/bin/env python3.6
|
||||||
|
|
||||||
import re, logging
|
import re
|
||||||
|
import logging
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from http_utils import convert_query_to_percent_encoded_octets, build_url, fetch_url
|
from torrentSearch.http_utils import convert_query_to_percent_encoded_octets, build_url, fetch_url
|
||||||
from utils import return_re_match, deHumansize
|
from torrentSearch.utils import return_re_match, deHumansize
|
||||||
from torrent import Torrent
|
from torrentSearch.torrent import Torrent
|
||||||
|
|
||||||
|
logger = logging.getLogger('torrentSearch')
|
||||||
|
|
||||||
class Piratebay(object):
|
class Piratebay(object):
|
||||||
"""docstring for Jackett"""
|
"""docstring for Piratebay"""
|
||||||
def __init__(self, host, path, limit, ssl):
|
def __init__(self, host, path, limit, ssl):
|
||||||
super(Piratebay, self).__init__()
|
super(Piratebay, self).__init__()
|
||||||
self.host = host
|
self.host = host
|
||||||
@@ -43,8 +46,6 @@ class Piratebay(object):
|
|||||||
return self.parse_raw_page_for_torrents(res.read())
|
return self.parse_raw_page_for_torrents(res.read())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def removeHeader(self, bs4_element):
|
def removeHeader(self, bs4_element):
|
||||||
if ('header' in bs4_element['class']):
|
if ('header' in bs4_element['class']):
|
||||||
return bs4_element.find_next('tr')
|
return bs4_element.find_next('tr')
|
||||||
@@ -89,6 +90,7 @@ class Piratebay(object):
|
|||||||
|
|
||||||
# COULD NOT FIND HREF!
|
# COULD NOT FIND HREF!
|
||||||
if (magnet is None):
|
if (magnet is None):
|
||||||
|
logger.warning('Could not find magnet for {}'.format(name))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
seed_and_leech = torrentElement.find_all_next(attrs={"align": "right"})
|
seed_and_leech = torrentElement.find_all_next(attrs={"align": "right"})
|
||||||
@@ -99,7 +101,7 @@ class Piratebay(object):
|
|||||||
|
|
||||||
torrents_found.append(torrent)
|
torrents_found.append(torrent)
|
||||||
else:
|
else:
|
||||||
# print(torrentElement)
|
logger.warning('Could not find torrent element on thepiratebay webpage.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logging.info('Found %s torrents for given search criteria.' % len(torrents_found))
|
logging.info('Found %s torrents for given search criteria.' % len(torrents_found))
|
||||||
|
|||||||
Reference in New Issue
Block a user