text stringlengths 1 93.6k |
|---|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# SOFTWARE.
|
import re
|
from html.parser import HTMLParser
|
from helpers import download_file, retrieve_url
|
from novaprinter import prettyPrinter, anySizeToBytes
|
class pediatorrent(object):
|
url = 'https://pediatorrent.com'
|
headers = {
|
'Referer': url
|
}
|
name = 'PediaTorrent'
|
# Al no existir la categoria de busqueda documentales, la asocié a Libros,
|
supported_categories = {
|
'all': 'peliculas',
|
'movies': 'peliculas',
|
'tv': 'series',
|
'books': 'documentales'
|
}
|
no_results_regex = r'<p.*?>No se ha encontrado ning[uú]n resultado.</p>'
|
class SearchResultsParser(HTMLParser):
|
def error(self, message):
|
pass
|
DIV, A = ('div', 'a')
|
supported_categories_class = {
|
'all': 'movie-list',
|
'movies': 'movie-list',
|
'tv': 'serie-list',
|
'books': 'doc-list'
|
}
|
expected_x_data = "{ showDetail: false }"
|
torrent_link_regex = r'\/torrents\/.+?\.torrent'
|
title_regex = r'<h1.*?>.*?</h1>'
|
count = 0
|
def __init__(self, url, cat):
|
HTMLParser.__init__(self)
|
self.url = url
|
self.headers = {
|
'Referer': url
|
}
|
self.insideResultList = False
|
self.insideResultContainer = False
|
self.insideResult = False
|
self.insideLink = False
|
self.insideYear = False
|
self.list_css_class = self.supported_categories_class[cat]
|
def handle_starttag(self, tag, attrs):
|
params = dict(attrs)
|
css_classes = params.get('class', '')
|
x_data = params.get('x-data')
|
if tag == self.DIV and self.list_css_class in css_classes:
|
self.insideResultList = True
|
return
|
if self.insideResultList and tag == self.DIV and x_data == self.expected_x_data:
|
self.insideResultContainer = True
|
return
|
if self.insideResultContainer and tag == self.DIV and 'relative' in css_classes:
|
self.insideResult = True
|
return
|
if self.insideResult and tag == self.A:
|
self.count += 1
|
self.insideLink = True
|
href = params.get('href')
|
retrieved_html = retrieve_url(href, self.headers)
|
link_matches = re.finditer(self.torrent_link_regex, retrieved_html, re.MULTILINE)
|
title_matches = re.finditer(self.title_regex, retrieved_html, re.MULTILINE)
|
torrent_link = [x.group() for x in link_matches]
|
title = [x.group() for x in title_matches]
|
row = {
|
'link': f'{pediatorrent.url}{torrent_link[0]}',
|
'name': re.sub(r'</h1>', '',re.sub(r'<h1.+?>', '', title[0])),
|
'size': 0,
|
'seeds': -1,
|
'leech': -1,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.