aboutsummaryrefslogtreecommitdiffstats
path: root/tpblite/models
diff options
context:
space:
mode:
authorMatt Lyon <matthewlyon18@gmail.com>2019-12-17 22:50:56 +0000
committerMatt Lyon <matthewlyon18@gmail.com>2019-12-17 22:50:56 +0000
commitc7ec8249b8825a5d9226b16f6aa0c4e39d3d25cc (patch)
tree4e40a9229ff1525c0fc8ee5c7d633fef7ea9579d /tpblite/models
parentaa666a65a3c61fce8b103594cc432aaca2644b8e (diff)
downloadtpb-lite-c7ec8249b8825a5d9226b16f6aa0c4e39d3d25cc.tar.gz
tpb-lite-c7ec8249b8825a5d9226b16f6aa0c4e39d3d25cc.tar.bz2
tpb-lite-c7ec8249b8825a5d9226b16f6aa0c4e39d3d25cc.zip
updated README
Diffstat (limited to 'tpblite/models')
-rw-r--r--tpblite/models/torrents.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/tpblite/models/torrents.py b/tpblite/models/torrents.py
index 87a3b6b..eb007cb 100644
--- a/tpblite/models/torrents.py
+++ b/tpblite/models/torrents.py
@@ -2,7 +2,6 @@ import re
import unicodedata
from bs4 import BeautifulSoup
-#TODO: implement a pretty print for Torrents object
#TODO: write better comments
def fileSizeStrToInt(size_str):
@@ -73,7 +72,7 @@ class Torrents(object):
self.__search_set = None
self.html_source = html_source
- self.list = self._createTorrentListMod()
+ self.list = self._createTorrentList()
def __str__(self):
return 'Torrents object: {} torrents'.format(len(self.list))
@@ -87,21 +86,16 @@ class Torrents(object):
def __len__(self):
return len(self.list)
+ def __getitem__(self,index):
+ return self.list[index]
+
@property
- def search_set(self):
+ def _search_set(self):
if self.__search_set == None:
self.__search_set = set(filter(None, re.split(r'[\s.|\(|\)]',self.search_str.lower())))
return self.__search_set
-
- def _createTorrentList(self):
- soup = BeautifulSoup(self.html_source, features='html.parser')
- rows = self.__getRows(soup)
- torrents = []
- for row in rows:
- torrents.append(Torrent(row))
- return torrents
- def _createTorrentListMod(self):
+ def _createTorrentList(self):
soup = BeautifulSoup(self.html_source, features='html.parser')
rows = soup.body.find_all('tr')
torrents = []
@@ -109,7 +103,7 @@ class Torrents(object):
# Get the lowercase unique set from the row text
text_set = set(filter(None, re.split(r'[\s.|\(|\)]',row.text.lower())))
# Check if search string is subset
- if self.search_set.issubset(text_set):
+ if self._search_set.issubset(text_set):
torrents.append(Torrent(row))
return torrents