From 07be33635c5aa56279007b238b4ebc08de792896 Mon Sep 17 00:00:00 2001 From: Arthurv89 Date: Tue, 25 Aug 2015 21:51:25 +0200 Subject: [PATCH 1/2] Change icon selector for magnet links and download links. This closes #14 --- KickassAPI.py | 4 ++-- __init__.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 __init__.py diff --git a/KickassAPI.py b/KickassAPI.py index 85ed402..4ab008b 100644 --- a/KickassAPI.py +++ b/KickassAPI.py @@ -234,8 +234,8 @@ def _get_torrent(self, row): torrent_link = "http://" + BASE.domain if td("a.cellMainLink").attr("href") is not None: torrent_link += td("a.cellMainLink").attr("href") - magnet_link = td("a.imagnet.icon16").attr("href") - download_link = td("a.idownload.icon16").eq(1).attr("href") + magnet_link = td("a.icon16[href*='magnet']").attr("href") + download_link = td("a.icon16[href*='.torrent']").attr("href") td_centers = row("td.center") size = td_centers.eq(0).text() diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ + From 6d105e6f18afec6f50e9a4ea6d23fd07418db1c7 Mon Sep 17 00:00:00 2001 From: Arthurv89 Date: Tue, 25 Aug 2015 22:21:14 +0200 Subject: [PATCH 2/2] Searching for ampersands cause the API to throw exception because of bad URL encoding. Closes #16 --- KickassAPI.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/KickassAPI.py b/KickassAPI.py index 4ab008b..e97afb6 100644 --- a/KickassAPI.py +++ b/KickassAPI.py @@ -19,6 +19,8 @@ import requests import re +import urllib + # CONSTANTS class BASE(object): domain='kat.cr' @@ -144,7 +146,6 @@ def build(self, update=True): """ Build and return url. Also update max_page. """ - ret = self.base + self.query page = "".join(("/", str(self.page), "/")) if self.category: @@ -157,7 +158,7 @@ def build(self, update=True): else: order = "" - ret = "".join((self.base, self.query, category, page, order)) + ret = "".join((self.base, urllib.quote_plus(self.query), category, page, order)) if update: self.max_page = self._get_max_page(ret)