1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-18 07:15:13 -05:00

Merge pull request #679 from adam111316/nyaa_consolidation

Remove unnecessary code from nyaatorrents provider and PEP8
This commit is contained in:
echel0n 2014-08-03 00:14:11 -07:00
commit 1908c74e96

View File

@ -11,7 +11,7 @@
# SickRage is distributed in the hope that it will be useful, # SickRage is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
@ -28,7 +28,6 @@ from sickbeard.common import Quality
from sickbeard import tvcache from sickbeard import tvcache
from sickbeard import show_name_helpers from sickbeard import show_name_helpers
REMOTE_DBG = False
class NyaaProvider(generic.TorrentProvider): class NyaaProvider(generic.TorrentProvider):
def __init__(self): def __init__(self):
@ -70,9 +69,10 @@ class NyaaProvider(generic.TorrentProvider):
logger.log(u"" + str(self.show.name) + " is not an anime skiping " + str(self.name)) logger.log(u"" + str(self.show.name) + " is not an anime skiping " + str(self.name))
return [] return []
params = {"term": search_string.encode('utf-8'), params = {
"cats": '1_37', #Limit to English-translated Anime (for now) "term": search_string.encode('utf-8'),
"sort": '2', #Sort Descending By Seeders "cats": '1_37', # Limit to English-translated Anime (for now)
"sort": '2', # Sort Descending By Seeders
} }
searchURL = self.url + '?page=rss&' + urllib.urlencode(params) searchURL = self.url + '?page=rss&' + urllib.urlencode(params)
@ -118,6 +118,7 @@ class NyaaProvider(generic.TorrentProvider):
def seedRatio(self): def seedRatio(self):
return self.ratio return self.ratio
class NyaaCache(tvcache.TVCache): class NyaaCache(tvcache.TVCache):
def __init__(self, provider): def __init__(self, provider):
tvcache.TVCache.__init__(self, provider) tvcache.TVCache.__init__(self, provider)
@ -127,8 +128,9 @@ class NyaaCache(tvcache.TVCache):
def _getRSSData(self): def _getRSSData(self):
params = { params = {
"page": 'rss', # Use RSS page "page": 'rss', # Use RSS page
"order": '1' #Sort Descending By Date "order": '1', # Sort Descending By Date
"cats": '1_37', # Limit to English-translated Anime (for now)
} }
url = self.provider.url + '?' + urllib.urlencode(params) url = self.provider.url + '?' + urllib.urlencode(params)
@ -137,17 +139,5 @@ class NyaaCache(tvcache.TVCache):
return self.getRSSFeed(url) return self.getRSSFeed(url)
def _parseItem(self, item):
(title, url) = self.provider._get_title_and_url(item)
if not title or not url:
logger.log(u"The XML returned from the NyaaTorrents RSS feed is incomplete, this result is unusable",
logger.ERROR)
return None
logger.log(u"RSS Feed provider: [" + self.provider.name + "] Attempting to add item to cache: " + title, logger.DEBUG)
return self._addCacheEntry(title, url)
provider = NyaaProvider() provider = NyaaProvider()