Commit e6e02375 authored by echel0n's avatar echel0n
Browse files

Added Anizb Newznab provider

parent f45988ba
# Changelog
- * d79c29c - 2017-10-17: Refactored Newznab provider code Refactored locations of static files and mako templates
- * 7f4c026 - 2017-10-17: Added Anizb Newznab provider
- * f45988b - 2017-10-17: Refactored Newznab provider code Refactored locations of static files and mako templates
- * 7aac26b - 2017-10-17: Refactored Newznab provider code Refactored locations of static files and mako templates
- * 6384aab - 2017-10-17: Release v9.1.39
- * f50a313 - 2017-10-17: Fixed issue with gettext underscore being replaced when using underscore as throwaway variable
......
......@@ -69,6 +69,7 @@ class GenericProvider(object):
self.enable_backlog = False
self.cache = TVCache(self)
self.proper_strings = ['PROPER|REPACK|REAL']
self.search_separator = ' '
# cookies
self.enable_cookies = False
......@@ -245,7 +246,7 @@ class GenericProvider(object):
return [search_string]
def _get_episode_search_strings(self, episode, add_string='', search_separator=' '):
def _get_episode_search_strings(self, episode, add_string=''):
"""
Get episode search strings.
"""
......@@ -257,7 +258,7 @@ class GenericProvider(object):
}
for show_name in allPossibleShowNames(episode.show, episode.scene_season):
episode_string = show_name + search_separator
episode_string = show_name + self.search_separator
episode_string_fallback = None
if episode.show.air_by_date:
......@@ -283,9 +284,9 @@ class GenericProvider(object):
}
if add_string:
episode_string += search_separator + add_string
episode_string += self.search_separator + add_string
if episode_string_fallback:
episode_string_fallback += search_separator + add_string
episode_string_fallback += self.search_separator + add_string
search_string['Episode'].append(episode_string.strip())
if episode_string_fallback:
......
# coding=utf-8
# Author: ellmout <[email protected]>
# Inspired from : adaur <[email protected]> (ABNormal)
#
# URL: https://sickrage.ca
#
# This file is part of SickRage.
#
# SickRage is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SickRage is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import sickrage
from sickrage.core.caches.tv_cache import TVCache
from sickrage.core.helpers import bs4_parser, try_int
from sickrage.providers import NZBProvider
class Anizb(NZBProvider):
"""Nzb Provider using the open api of anizb.org for daily (rss) and backlog/forced searches."""
def __init__(self):
"""Initialize the class."""
super(Anizb, self).__init__('Anizb', 'https://anizb.org', False)
# URLs
self.urls.update({
'api': '{base_url}/api/?q='.format(**self.urls)
})
# Miscellaneous Options
self.supports_absolute_numbering = True
self.anime_only = True
self.search_separator = '*'
# Cache
self.cache = TVCache(self)
def search(self, search_strings, age=0, ep_obj=None):
"""Start searching for anime using the provided search_strings. Used for backlog and daily."""
results = []
for mode in search_strings:
sickrage.srCore.srLogger.debug('Search mode: {0}'.format(mode))
for search_string in search_strings[mode]:
if mode != 'RSS':
sickrage.srCore.srLogger.debug('Search string: {}'.format(search_string))
search_url = (self.urls['rss'], self.urls['api'] + search_string)[mode != 'RSS']
try:
response = sickrage.srCore.srWebSession.get(search_url).text
except Exception:
sickrage.srCore.srLogger.debug('No data returned from provider')
continue
if not response.text.startswith('<?xml'):
sickrage.srCore.srLogger.info('Expected xml but got something else, is your mirror failing?')
continue
with bs4_parser(response) as html:
entries = html('item')
if not entries:
sickrage.srCore.srLogger.info('Returned xml contained no results')
continue
for item in entries:
try:
title = item.title.get_text(strip=True)
download_url = item.enclosure.get('url').strip()
if not (title and download_url):
continue
# description = item.find('description')
size = try_int(item.enclosure.get('length', -1))
item = {
'title': title,
'link': download_url,
'size': size,
}
results.append(item)
except (AttributeError, TypeError, KeyError, ValueError, IndexError):
sickrage.srCore.srLogger.error('Failed parsing provider.')
continue
return results
def _get_size(self, item):
"""Override the default _get_size to prevent it from extracting using the default tags."""
return try_int(item.get('size'))
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment