23 | {% endblock %}
24 |
25 |
26 | :copyright: (c) 2010 by the Jinja Team.
27 | :license: BSD, see LICENSE for more details.
28 | """
29 | __docformat__ = 'restructuredtext en'
30 | __version__ = '2.6'
31 | # high level interface
32 | from jinja2.environment import Environment, Template
33 |
34 | # loaders
35 | from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
36 | DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
37 | ModuleLoader
38 |
39 | # bytecode caches
40 | from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
41 | MemcachedBytecodeCache
42 |
43 | # undefined types
44 | from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined
45 |
46 | # exceptions
47 | from jinja2.exceptions import TemplateError, UndefinedError, \
48 | TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
49 | TemplateAssertionError
50 |
51 | # decorators and public utilities
52 | from jinja2.filters import environmentfilter, contextfilter, \
53 | evalcontextfilter
54 | from jinja2.utils import Markup, escape, clear_caches, \
55 | environmentfunction, evalcontextfunction, contextfunction, \
56 | is_undefined
57 |
58 | __all__ = [
59 | 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
60 | 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
61 | 'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
62 | 'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
63 | 'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
64 | 'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
65 | 'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
66 | 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
67 | 'evalcontextfilter', 'evalcontextfunction'
68 | ]
69 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/_debugsupport.c:
--------------------------------------------------------------------------------
1 | /**
2 | * jinja2._debugsupport
3 | * ~~~~~~~~~~~~~~~~~~~~
4 | *
5 | * C implementation of `tb_set_next`.
6 | *
7 | * :copyright: (c) 2010 by the Jinja Team.
8 | * :license: BSD.
9 | */
10 |
11 | #include
12 |
13 |
14 | static PyObject*
15 | tb_set_next(PyObject *self, PyObject *args)
16 | {
17 | PyTracebackObject *tb, *old;
18 | PyObject *next;
19 |
20 | if (!PyArg_ParseTuple(args, "O!O:tb_set_next", &PyTraceBack_Type, &tb, &next))
21 | return NULL;
22 | if (next == Py_None)
23 | next = NULL;
24 | else if (!PyTraceBack_Check(next)) {
25 | PyErr_SetString(PyExc_TypeError,
26 | "tb_set_next arg 2 must be traceback or None");
27 | return NULL;
28 | }
29 | else
30 | Py_INCREF(next);
31 |
32 | old = tb->tb_next;
33 | tb->tb_next = (PyTracebackObject*)next;
34 | Py_XDECREF(old);
35 |
36 | Py_INCREF(Py_None);
37 | return Py_None;
38 | }
39 |
40 | static PyMethodDef module_methods[] = {
41 | {"tb_set_next", (PyCFunction)tb_set_next, METH_VARARGS,
42 | "Set the tb_next member of a traceback object."},
43 | {NULL, NULL, 0, NULL} /* Sentinel */
44 | };
45 |
46 |
47 | #if PY_MAJOR_VERSION < 3
48 |
49 | #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
50 | #define PyMODINIT_FUNC void
51 | #endif
52 | PyMODINIT_FUNC
53 | init_debugsupport(void)
54 | {
55 | Py_InitModule3("jinja2._debugsupport", module_methods, "");
56 | }
57 |
58 | #else /* Python 3.x module initialization */
59 |
60 | static struct PyModuleDef module_definition = {
61 | PyModuleDef_HEAD_INIT,
62 | "jinja2._debugsupport",
63 | NULL,
64 | -1,
65 | module_methods,
66 | NULL,
67 | NULL,
68 | NULL,
69 | NULL
70 | };
71 |
72 | PyMODINIT_FUNC
73 | PyInit__debugsupport(void)
74 | {
75 | return PyModule_Create(&module_definition);
76 | }
77 |
78 | #endif
79 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/_markupsafe/_bundle.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2._markupsafe._bundle
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | This script pulls in markupsafe from a source folder and
7 | bundles it with Jinja2. It does not pull in the speedups
8 | module though.
9 |
10 | :copyright: Copyright 2010 by the Jinja team, see AUTHORS.
11 | :license: BSD, see LICENSE for details.
12 | """
13 | import sys
14 | import os
15 | import re
16 |
17 |
18 | def rewrite_imports(lines):
19 | for idx, line in enumerate(lines):
20 | new_line = re.sub(r'(import|from)\s+markupsafe\b',
21 | r'\1 jinja2._markupsafe', line)
22 | if new_line != line:
23 | lines[idx] = new_line
24 |
25 |
26 | def main():
27 | if len(sys.argv) != 2:
28 | print 'error: only argument is path to markupsafe'
29 | sys.exit(1)
30 | basedir = os.path.dirname(__file__)
31 | markupdir = sys.argv[1]
32 | for filename in os.listdir(markupdir):
33 | if filename.endswith('.py'):
34 | f = open(os.path.join(markupdir, filename))
35 | try:
36 | lines = list(f)
37 | finally:
38 | f.close()
39 | rewrite_imports(lines)
40 | f = open(os.path.join(basedir, filename), 'w')
41 | try:
42 | for line in lines:
43 | f.write(line)
44 | finally:
45 | f.close()
46 |
47 |
48 | if __name__ == '__main__':
49 | main()
50 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/_markupsafe/_native.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | markupsafe._native
4 | ~~~~~~~~~~~~~~~~~~
5 |
6 | Native Python implementation the C module is not compiled.
7 |
8 | :copyright: (c) 2010 by Armin Ronacher.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 | from jinja2._markupsafe import Markup
12 |
13 |
14 | def escape(s):
15 | """Convert the characters &, <, >, ' and " in string s to HTML-safe
16 | sequences. Use this if you need to display text that might contain
17 | such characters in HTML. Marks return value as markup string.
18 | """
19 | if hasattr(s, '__html__'):
20 | return s.__html__()
21 | return Markup(unicode(s)
22 | .replace('&', '&')
23 | .replace('>', '>')
24 | .replace('<', '<')
25 | .replace("'", ''')
26 | .replace('"', '"')
27 | )
28 |
29 |
30 | def escape_silent(s):
31 | """Like :func:`escape` but converts `None` into an empty
32 | markup string.
33 | """
34 | if s is None:
35 | return Markup()
36 | return escape(s)
37 |
38 |
39 | def soft_unicode(s):
40 | """Make a string unicode if it isn't already. That way a markup
41 | string is not converted back to unicode.
42 | """
43 | if not isinstance(s, unicode):
44 | s = unicode(s)
45 | return s
46 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/_markupsafe/tests.py:
--------------------------------------------------------------------------------
1 | import gc
2 | import unittest
3 | from jinja2._markupsafe import Markup, escape, escape_silent
4 |
5 |
6 | class MarkupTestCase(unittest.TestCase):
7 | def test_markup_operations(self):
8 | # adding two strings should escape the unsafe one
9 | unsafe = ''
10 | safe = Markup('username')
11 | assert unsafe + safe == unicode(escape(unsafe)) + unicode(safe)
12 |
13 | # string interpolations are safe to use too
14 | assert Markup('%s') % '' == \
15 | '<bad user>'
16 | assert Markup('%(username)s') % {
17 | 'username': ''
18 | } == '<bad user>'
19 |
20 | # an escaped object is markup too
21 | assert type(Markup('foo') + 'bar') is Markup
22 |
23 | # and it implements __html__ by returning itself
24 | x = Markup("foo")
25 | assert x.__html__() is x
26 |
27 | # it also knows how to treat __html__ objects
28 | class Foo(object):
29 | def __html__(self):
30 | return 'awesome'
31 |
32 | def __unicode__(self):
33 | return 'awesome'
34 |
35 | assert Markup(Foo()) == 'awesome'
36 | assert Markup('%s') % Foo() == \
37 | 'awesome'
38 |
39 | # escaping and unescaping
40 | assert escape('"<>&\'') == '"<>&''
41 | assert Markup("Foo & Bar").striptags() == "Foo & Bar"
42 | assert Markup("<test>").unescape() == ""
43 |
44 | def test_all_set(self):
45 | import jinja2._markupsafe as markup
46 |
47 | for item in markup.__all__:
48 | getattr(markup, item)
49 |
50 | def test_escape_silent(self):
51 | assert escape_silent(None) == Markup()
52 | assert escape(None) == Markup(None)
53 | assert escape_silent('') == Markup(u'<foo>')
54 |
55 |
56 | class MarkupLeakTestCase(unittest.TestCase):
57 | def test_markup_leaks(self):
58 | counts = set()
59 | for count in xrange(20):
60 | for item in xrange(1000):
61 | escape("foo")
62 | escape("")
63 | escape(u"foo")
64 | escape(u"")
65 | counts.add(len(gc.get_objects()))
66 | assert len(counts) == 1, 'ouch, c extension seems to leak objects'
67 |
68 |
69 | def suite():
70 | suite = unittest.TestSuite()
71 | suite.addTest(unittest.makeSuite(MarkupTestCase))
72 |
73 | # this test only tests the c extension
74 | if not hasattr(escape, 'func_code'):
75 | suite.addTest(unittest.makeSuite(MarkupLeakTestCase))
76 |
77 | return suite
78 |
79 |
80 | if __name__ == '__main__':
81 | unittest.main(defaultTest='suite')
82 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/constants.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja.constants
4 | ~~~~~~~~~~~~~~~
5 |
6 | Various constants.
7 |
8 | :copyright: (c) 2010 by the Jinja Team.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 |
13 | #: list of lorem ipsum words used by the lipsum() helper function
14 | LOREM_IPSUM_WORDS = u'''\
15 | a ac accumsan ad adipiscing aenean aliquam aliquet amet ante aptent arcu at
16 | auctor augue bibendum blandit class commodo condimentum congue consectetuer
17 | consequat conubia convallis cras cubilia cum curabitur curae cursus dapibus
18 | diam dictum dictumst dignissim dis dolor donec dui duis egestas eget eleifend
19 | elementum elit enim erat eros est et etiam eu euismod facilisi facilisis fames
20 | faucibus felis fermentum feugiat fringilla fusce gravida habitant habitasse hac
21 | hendrerit hymenaeos iaculis id imperdiet in inceptos integer interdum ipsum
22 | justo lacinia lacus laoreet lectus leo libero ligula litora lobortis lorem
23 | luctus maecenas magna magnis malesuada massa mattis mauris metus mi molestie
24 | mollis montes morbi mus nam nascetur natoque nec neque netus nibh nisi nisl non
25 | nonummy nostra nulla nullam nunc odio orci ornare parturient pede pellentesque
26 | penatibus per pharetra phasellus placerat platea porta porttitor posuere
27 | potenti praesent pretium primis proin pulvinar purus quam quis quisque rhoncus
28 | ridiculus risus rutrum sagittis sapien scelerisque sed sem semper senectus sit
29 | sociis sociosqu sodales sollicitudin suscipit suspendisse taciti tellus tempor
30 | tempus tincidunt torquent tortor tristique turpis ullamcorper ultrices
31 | ultricies urna ut varius vehicula vel velit venenatis vestibulum vitae vivamus
32 | viverra volutpat vulputate'''
33 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/defaults.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.defaults
4 | ~~~~~~~~~~~~~~~
5 |
6 | Jinja default filters and tags.
7 |
8 | :copyright: (c) 2010 by the Jinja Team.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 | from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner
12 |
13 |
14 | # defaults for the parser / lexer
15 | BLOCK_START_STRING = '{%'
16 | BLOCK_END_STRING = '%}'
17 | VARIABLE_START_STRING = '{{'
18 | VARIABLE_END_STRING = '}}'
19 | COMMENT_START_STRING = '{#'
20 | COMMENT_END_STRING = '#}'
21 | LINE_STATEMENT_PREFIX = None
22 | LINE_COMMENT_PREFIX = None
23 | TRIM_BLOCKS = False
24 | NEWLINE_SEQUENCE = '\n'
25 |
26 |
27 | # default filters, tests and namespace
28 | from jinja2.filters import FILTERS as DEFAULT_FILTERS
29 | from jinja2.tests import TESTS as DEFAULT_TESTS
30 |
31 | DEFAULT_NAMESPACE = {
32 | 'range': xrange,
33 | 'dict': lambda **kw: kw,
34 | 'lipsum': generate_lorem_ipsum,
35 | 'cycler': Cycler,
36 | 'joiner': Joiner
37 | }
38 |
39 |
40 | # export all constants
41 | __all__ = tuple(x for x in locals().keys() if x.isupper())
42 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/optimizer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.optimizer
4 | ~~~~~~~~~~~~~~~~
5 |
6 | The jinja optimizer is currently trying to constant fold a few expressions
7 | and modify the AST in place so that it should be easier to evaluate it.
8 |
9 | Because the AST does not contain all the scoping information and the
10 | compiler has to find that out, we cannot do all the optimizations we
11 | want. For example loop unrolling doesn't work because unrolled loops would
12 | have a different scoping.
13 |
14 | The solution would be a second syntax tree that has the scoping rules stored.
15 |
16 | :copyright: (c) 2010 by the Jinja Team.
17 | :license: BSD.
18 | """
19 | from jinja2 import nodes
20 | from jinja2.visitor import NodeTransformer
21 |
22 |
23 | def optimize(node, environment):
24 | """The context hint can be used to perform an static optimization
25 | based on the context given."""
26 | optimizer = Optimizer(environment)
27 | return optimizer.visit(node)
28 |
29 |
30 | class Optimizer(NodeTransformer):
31 | def __init__(self, environment):
32 | self.environment = environment
33 |
34 | def visit_If(self, node):
35 | """Eliminate dead code."""
36 | # do not optimize ifs that have a block inside so that it doesn't
37 | # break super().
38 | if node.find(nodes.Block) is not None:
39 | return self.generic_visit(node)
40 | try:
41 | val = self.visit(node.test).as_const()
42 | except nodes.Impossible:
43 | return self.generic_visit(node)
44 | if val:
45 | body = node.body
46 | else:
47 | body = node.else_
48 | result = []
49 | for node in body:
50 | result.extend(self.visit_list(node))
51 | return result
52 |
53 | def fold(self, node):
54 | """Do constant folding."""
55 | node = self.generic_visit(node)
56 | try:
57 | return nodes.Const.from_untrusted(node.as_const(),
58 | lineno=node.lineno,
59 | environment=self.environment)
60 | except nodes.Impossible:
61 | return node
62 |
63 | visit_Add = visit_Sub = visit_Mul = visit_Div = visit_FloorDiv = \
64 | visit_Pow = visit_Mod = visit_And = visit_Or = visit_Pos = visit_Neg = \
65 | visit_Not = visit_Compare = visit_Getitem = visit_Getattr = visit_Call = \
66 | visit_Filter = visit_Test = visit_CondExpr = fold
67 | del fold
68 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.testsuite
4 | ~~~~~~~~~~~~~~~~
5 |
6 | All the unittests of Jinja2. These tests can be executed by
7 | either running run-tests.py using multiple Python versions at
8 | the same time.
9 |
10 | :copyright: (c) 2010 by the Jinja Team.
11 | :license: BSD, see LICENSE for more details.
12 | """
13 | import os
14 | import re
15 | import sys
16 | import unittest
17 | from traceback import format_exception
18 | from jinja2 import loaders
19 |
20 | here = os.path.dirname(os.path.abspath(__file__))
21 |
22 | dict_loader = loaders.DictLoader({
23 | 'justdict.html': 'FOO'
24 | })
25 | package_loader = loaders.PackageLoader('jinja2.testsuite.res', 'templates')
26 | filesystem_loader = loaders.FileSystemLoader(here + '/res/templates')
27 | function_loader = loaders.FunctionLoader({'justfunction.html': 'FOO'}.get)
28 | choice_loader = loaders.ChoiceLoader([dict_loader, package_loader])
29 | prefix_loader = loaders.PrefixLoader({
30 | 'a': filesystem_loader,
31 | 'b': dict_loader
32 | })
33 |
34 |
35 | class JinjaTestCase(unittest.TestCase):
36 | ### use only these methods for testing. If you need standard
37 | ### unittest method, wrap them!
38 |
39 | def setup(self):
40 | pass
41 |
42 | def teardown(self):
43 | pass
44 |
45 | def setUp(self):
46 | self.setup()
47 |
48 | def tearDown(self):
49 | self.teardown()
50 |
51 | def assert_equal(self, a, b):
52 | return self.assertEqual(a, b)
53 |
54 | def assert_raises(self, *args, **kwargs):
55 | return self.assertRaises(*args, **kwargs)
56 |
57 | def assert_traceback_matches(self, callback, expected_tb):
58 | try:
59 | callback()
60 | except Exception, e:
61 | tb = format_exception(*sys.exc_info())
62 | if re.search(expected_tb.strip(), ''.join(tb)) is None:
63 | raise self.fail('Traceback did not match:\n\n%s\nexpected:\n%s'
64 | % (''.join(tb), expected_tb))
65 | else:
66 | self.fail('Expected exception')
67 |
68 |
69 | def suite():
70 | from jinja2.testsuite import ext, filters, tests, core_tags, \
71 | loader, inheritance, imports, lexnparse, security, api, \
72 | regression, debug, utils, doctests
73 |
74 | suite = unittest.TestSuite()
75 | suite.addTest(ext.suite())
76 | suite.addTest(filters.suite())
77 | suite.addTest(tests.suite())
78 | suite.addTest(core_tags.suite())
79 | suite.addTest(loader.suite())
80 | suite.addTest(inheritance.suite())
81 | suite.addTest(imports.suite())
82 | suite.addTest(lexnparse.suite())
83 | suite.addTest(security.suite())
84 | suite.addTest(api.suite())
85 | suite.addTest(regression.suite())
86 | suite.addTest(debug.suite())
87 | suite.addTest(utils.suite())
88 |
89 | # doctests will not run on python 3 currently. Too many issues
90 | # with that, do not test that on that platform.
91 | if sys.version_info < (3, 0):
92 | suite.addTest(doctests.suite())
93 |
94 | return suite
95 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/debug.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.testsuite.debug
4 | ~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | Tests the debug system.
7 |
8 | :copyright: (c) 2010 by the Jinja Team.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 | import sys
12 | import unittest
13 |
14 | from jinja2.testsuite import JinjaTestCase, filesystem_loader
15 |
16 | from jinja2 import Environment, TemplateSyntaxError
17 |
18 | env = Environment(loader=filesystem_loader)
19 |
20 |
21 | class DebugTestCase(JinjaTestCase):
22 | if sys.version_info[:2] != (2, 4):
23 | def test_runtime_error(self):
24 | def test():
25 | tmpl.render(fail=lambda: 1 / 0)
26 |
27 | tmpl = env.get_template('broken.html')
28 | self.assert_traceback_matches(test, r'''
29 | File ".*?broken.html", line 2, in (top-level template code|)
30 | \{\{ fail\(\) \}\}
31 | File ".*?debug.pyc?", line \d+, in
32 | tmpl\.render\(fail=lambda: 1 / 0\)
33 | ZeroDivisionError: (int(eger)? )?division (or modulo )?by zero
34 | ''')
35 |
36 | def test_syntax_error(self):
37 | # XXX: the .*? is necessary for python3 which does not hide
38 | # some of the stack frames we don't want to show. Not sure
39 | # what's up with that, but that is not that critical. Should
40 | # be fixed though.
41 | self.assert_traceback_matches(lambda: env.get_template('syntaxerror.html'), r'''(?sm)
42 | File ".*?syntaxerror.html", line 4, in (template|)
43 | \{% endif %\}.*?
44 | (jinja2\.exceptions\.)?TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.
45 | ''')
46 |
47 | def test_regular_syntax_error(self):
48 | def test():
49 | raise TemplateSyntaxError('wtf', 42)
50 |
51 | self.assert_traceback_matches(test, r'''
52 | File ".*debug.pyc?", line \d+, in test
53 | raise TemplateSyntaxError\('wtf', 42\)
54 | (jinja2\.exceptions\.)?TemplateSyntaxError: wtf
55 | line 42''')
56 |
57 |
58 | def suite():
59 | suite = unittest.TestSuite()
60 | suite.addTest(unittest.makeSuite(DebugTestCase))
61 | return suite
62 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/doctests.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.testsuite.doctests
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | The doctests. Collects all tests we want to test from
7 | the Jinja modules.
8 |
9 | :copyright: (c) 2010 by the Jinja Team.
10 | :license: BSD, see LICENSE for more details.
11 | """
12 | import unittest
13 | import doctest
14 |
15 |
16 | def suite():
17 | from jinja2 import utils, sandbox, runtime, meta, loaders, \
18 | ext, environment, bccache, nodes
19 |
20 | suite = unittest.TestSuite()
21 | suite.addTest(doctest.DocTestSuite(utils))
22 | suite.addTest(doctest.DocTestSuite(sandbox))
23 | suite.addTest(doctest.DocTestSuite(runtime))
24 | suite.addTest(doctest.DocTestSuite(meta))
25 | suite.addTest(doctest.DocTestSuite(loaders))
26 | suite.addTest(doctest.DocTestSuite(ext))
27 | suite.addTest(doctest.DocTestSuite(environment))
28 | suite.addTest(doctest.DocTestSuite(bccache))
29 | suite.addTest(doctest.DocTestSuite(nodes))
30 | return suite
31 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/res/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/jinja2/testsuite/res/__init__.py
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/res/templates/broken.html:
--------------------------------------------------------------------------------
1 | Before
2 | {{ fail() }}
3 | After
4 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/res/templates/foo/test.html:
--------------------------------------------------------------------------------
1 | FOO
2 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/res/templates/syntaxerror.html:
--------------------------------------------------------------------------------
1 | Foo
2 | {% for item in broken %}
3 | ...
4 | {% endif %}
5 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/res/templates/test.html:
--------------------------------------------------------------------------------
1 | BAR
2 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/tests.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.testsuite.tests
4 | ~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | Who tests the tests?
7 |
8 | :copyright: (c) 2010 by the Jinja Team.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 | import unittest
12 | from jinja2.testsuite import JinjaTestCase
13 |
14 | from jinja2 import Markup, Environment
15 |
16 | env = Environment()
17 |
18 |
19 | class TestsTestCase(JinjaTestCase):
20 | def test_defined(self):
21 | tmpl = env.from_string('{{ missing is defined }}|{{ true is defined }}')
22 | assert tmpl.render() == 'False|True'
23 |
24 | def test_even(self):
25 | tmpl = env.from_string('''{{ 1 is even }}|{{ 2 is even }}''')
26 | assert tmpl.render() == 'False|True'
27 |
28 | def test_odd(self):
29 | tmpl = env.from_string('''{{ 1 is odd }}|{{ 2 is odd }}''')
30 | assert tmpl.render() == 'True|False'
31 |
32 | def test_lower(self):
33 | tmpl = env.from_string('''{{ "foo" is lower }}|{{ "FOO" is lower }}''')
34 | assert tmpl.render() == 'True|False'
35 |
36 | def test_typechecks(self):
37 | tmpl = env.from_string('''
38 | {{ 42 is undefined }}
39 | {{ 42 is defined }}
40 | {{ 42 is none }}
41 | {{ none is none }}
42 | {{ 42 is number }}
43 | {{ 42 is string }}
44 | {{ "foo" is string }}
45 | {{ "foo" is sequence }}
46 | {{ [1] is sequence }}
47 | {{ range is callable }}
48 | {{ 42 is callable }}
49 | {{ range(5) is iterable }}
50 | {{ {} is mapping }}
51 | {{ mydict is mapping }}
52 | {{ [] is mapping }}
53 | ''')
54 |
55 | class MyDict(dict):
56 | pass
57 |
58 | assert tmpl.render(mydict=MyDict()).split() == [
59 | 'False', 'True', 'False', 'True', 'True', 'False',
60 | 'True', 'True', 'True', 'True', 'False', 'True',
61 | 'True', 'True', 'False'
62 | ]
63 |
64 | def test_sequence(self):
65 | tmpl = env.from_string(
66 | '{{ [1, 2, 3] is sequence }}|'
67 | '{{ "foo" is sequence }}|'
68 | '{{ 42 is sequence }}'
69 | )
70 | assert tmpl.render() == 'True|True|False'
71 |
72 | def test_upper(self):
73 | tmpl = env.from_string('{{ "FOO" is upper }}|{{ "foo" is upper }}')
74 | assert tmpl.render() == 'True|False'
75 |
76 | def test_sameas(self):
77 | tmpl = env.from_string('{{ foo is sameas false }}|'
78 | '{{ 0 is sameas false }}')
79 | assert tmpl.render(foo=False) == 'True|False'
80 |
81 | def test_no_paren_for_arg1(self):
82 | tmpl = env.from_string('{{ foo is sameas none }}')
83 | assert tmpl.render(foo=None) == 'True'
84 |
85 | def test_escaped(self):
86 | env = Environment(autoescape=True)
87 | tmpl = env.from_string('{{ x is escaped }}|{{ y is escaped }}')
88 | assert tmpl.render(x='foo', y=Markup('foo')) == 'False|True'
89 |
90 |
91 | def suite():
92 | suite = unittest.TestSuite()
93 | suite.addTest(unittest.makeSuite(TestsTestCase))
94 | return suite
95 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/testsuite/utils.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.testsuite.utils
4 | ~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | Tests utilities jinja uses.
7 |
8 | :copyright: (c) 2010 by the Jinja Team.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 | import gc
12 | import unittest
13 |
14 | import pickle
15 |
16 | from jinja2.testsuite import JinjaTestCase
17 |
18 | from jinja2.utils import LRUCache, escape, object_type_repr
19 |
20 |
21 | class LRUCacheTestCase(JinjaTestCase):
22 | def test_simple(self):
23 | d = LRUCache(3)
24 | d["a"] = 1
25 | d["b"] = 2
26 | d["c"] = 3
27 | d["a"]
28 | d["d"] = 4
29 | assert len(d) == 3
30 | assert 'a' in d and 'c' in d and 'd' in d and 'b' not in d
31 |
32 | def test_pickleable(self):
33 | cache = LRUCache(2)
34 | cache["foo"] = 42
35 | cache["bar"] = 23
36 | cache["foo"]
37 |
38 | for protocol in range(3):
39 | copy = pickle.loads(pickle.dumps(cache, protocol))
40 | assert copy.capacity == cache.capacity
41 | assert copy._mapping == cache._mapping
42 | assert copy._queue == cache._queue
43 |
44 |
45 | class HelpersTestCase(JinjaTestCase):
46 | def test_object_type_repr(self):
47 | class X(object):
48 | pass
49 |
50 | self.assert_equal(object_type_repr(42), 'int object')
51 | self.assert_equal(object_type_repr([]), 'list object')
52 | self.assert_equal(object_type_repr(X()),
53 | 'jinja2.testsuite.utils.X object')
54 | self.assert_equal(object_type_repr(None), 'None')
55 | self.assert_equal(object_type_repr(Ellipsis), 'Ellipsis')
56 |
57 |
58 | class MarkupLeakTestCase(JinjaTestCase):
59 | def test_markup_leaks(self):
60 | counts = set()
61 | for count in xrange(20):
62 | for item in xrange(1000):
63 | escape("foo")
64 | escape("")
65 | escape(u"foo")
66 | escape(u"")
67 | counts.add(len(gc.get_objects()))
68 | assert len(counts) == 1, 'ouch, c extension seems to leak objects'
69 |
70 |
71 | def suite():
72 | suite = unittest.TestSuite()
73 | suite.addTest(unittest.makeSuite(LRUCacheTestCase))
74 | suite.addTest(unittest.makeSuite(HelpersTestCase))
75 |
76 | # this test only tests the c extension
77 | if not hasattr(escape, 'func_code'):
78 | suite.addTest(unittest.makeSuite(MarkupLeakTestCase))
79 |
80 | return suite
81 |
--------------------------------------------------------------------------------
/NZBmegasearch/jinja2/visitor.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | jinja2.visitor
4 | ~~~~~~~~~~~~~~
5 |
6 | This module implements a visitor for the nodes.
7 |
8 | :copyright: (c) 2010 by the Jinja Team.
9 | :license: BSD.
10 | """
11 | from jinja2.nodes import Node
12 |
13 |
14 | class NodeVisitor(object):
15 | """Walks the abstract syntax tree and call visitor functions for every
16 | node found. The visitor functions may return values which will be
17 | forwarded by the `visit` method.
18 |
19 | Per default the visitor functions for the nodes are ``'visit_'`` +
20 | class name of the node. So a `TryFinally` node visit function would
21 | be `visit_TryFinally`. This behavior can be changed by overriding
22 | the `get_visitor` function. If no visitor function exists for a node
23 | (return value `None`) the `generic_visit` visitor is used instead.
24 | """
25 |
26 | def get_visitor(self, node):
27 | """Return the visitor function for this node or `None` if no visitor
28 | exists for this node. In that case the generic visit function is
29 | used instead.
30 | """
31 | method = 'visit_' + node.__class__.__name__
32 | return getattr(self, method, None)
33 |
34 | def visit(self, node, *args, **kwargs):
35 | """Visit a node."""
36 | f = self.get_visitor(node)
37 | if f is not None:
38 | return f(node, *args, **kwargs)
39 | return self.generic_visit(node, *args, **kwargs)
40 |
41 | def generic_visit(self, node, *args, **kwargs):
42 | """Called if no explicit visitor function exists for a node."""
43 | for node in node.iter_child_nodes():
44 | self.visit(node, *args, **kwargs)
45 |
46 |
47 | class NodeTransformer(NodeVisitor):
48 | """Walks the abstract syntax tree and allows modifications of nodes.
49 |
50 | The `NodeTransformer` will walk the AST and use the return value of the
51 | visitor functions to replace or remove the old node. If the return
52 | value of the visitor function is `None` the node will be removed
53 | from the previous location otherwise it's replaced with the return
54 | value. The return value may be the original node in which case no
55 | replacement takes place.
56 | """
57 |
58 | def generic_visit(self, node, *args, **kwargs):
59 | for field, old_value in node.iter_fields():
60 | if isinstance(old_value, list):
61 | new_values = []
62 | for value in old_value:
63 | if isinstance(value, Node):
64 | value = self.visit(value, *args, **kwargs)
65 | if value is None:
66 | continue
67 | elif not isinstance(value, Node):
68 | new_values.extend(value)
69 | continue
70 | new_values.append(value)
71 | old_value[:] = new_values
72 | elif isinstance(old_value, Node):
73 | new_node = self.visit(old_value, *args, **kwargs)
74 | if new_node is None:
75 | delattr(node, field)
76 | else:
77 | setattr(node, field, new_node)
78 | return node
79 |
80 | def visit_list(self, node, *args, **kwargs):
81 | """As transformers may return lists in some places this method
82 | can be used to enforce a list as return value.
83 | """
84 | rv = self.visit(node, *args, **kwargs)
85 | if not isinstance(rv, list):
86 | rv = [rv]
87 | return rv
88 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/nginx.conf:
--------------------------------------------------------------------------------
1 | daemon off; # run in the foreground so supervisord can look after it
2 | worker_processes 2;
3 |
4 | user nobody nogroup;
5 | pid /tmp/nginx.pid;
6 | error_log /tmp/nginx.error.log;
7 |
8 | events {
9 | worker_connections 1024;
10 | accept_mutex off;
11 | }
12 |
13 | http {
14 | include mime.types;
15 | default_type application/octet-stream;
16 | access_log /tmp/nginx.access.log combined;
17 | sendfile on;
18 |
19 | upstream app_server {
20 | server unix:/tmp/gunicorn.sock fail_timeout=0;
21 | # For a TCP configuration:
22 | # server 192.168.0.7:8000 fail_timeout=0;
23 | }
24 |
25 | server {
26 | listen 443 ssl;
27 | listen 80 default_server;
28 |
29 | ssl_certificate /opt/usntssearch/NZBmegasearch/certificates/server.crt;
30 | ssl_certificate_key /opt/usntssearch/NZBmegasearch/certificates/server.key;
31 |
32 |
33 | client_max_body_size 4G;
34 | server_name _;
35 |
36 | keepalive_timeout 5;
37 |
38 | # path for static files
39 | root /opt/usntssearch/NZBmegasearch/static/;
40 |
41 | location / {
42 | # checks for static file, if not found proxy to app
43 | try_files $uri @proxy_to_app;
44 | }
45 |
46 | # Proxy download
47 | location ~* ^/warpme/http(s?)://(.*?)/(.*) {
48 | resolver 8.8.8.8;
49 |
50 | # Do not allow people to mess with this location directly
51 | # Only internal redirects are allowed
52 | internal;
53 |
54 | # Location-specific logging
55 | access_log /tmp/internal_redirect.access.log combined;
56 | error_log /tmp/internal_redirect.error.log warn;
57 |
58 | # Extract download url from the request
59 | set $download_uri $3;
60 | set $download_host $2;
61 | set $download_protocol $1;
62 |
63 | # Compose download url
64 | set $download_url http$download_protocol://$download_host/$download_uri?$args;
65 |
66 | # Set download request headers
67 | proxy_set_header Host $download_host;
68 | proxy_set_header Authorization '';
69 |
70 | #~ debug purposes
71 | #~ add_header DBG_prot '$download_protocol';
72 | #~ add_header DBG_host '$download_host';
73 | #~ add_header DBG_uri '$download_uri';
74 | #~ add_header DBG_fullurl '$download_url';
75 | #~ add_header DBG_args '$args';
76 |
77 | # Do not touch local disks when proxying
78 | # content to clients
79 | proxy_max_temp_file_size 0;
80 |
81 | # Download the file and send it to client
82 | proxy_pass $download_url;
83 |
84 |
85 | }
86 |
87 |
88 | location @proxy_to_app {
89 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
90 | proxy_set_header Host $http_host;
91 | proxy_redirect off;
92 |
93 | proxy_pass http://app_server;
94 | }
95 |
96 | error_page 500 502 503 504 /500.html;
97 | location = /500.html {
98 | root /opt/usntssearch/NZBmegasearch/static/;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/nginx_install.md:
--------------------------------------------------------------------------------
1 | ## How to install NZBMegasearch + NGINX + GUNICORN
2 |
3 | This document explains how to install NZBMegasearch for handling heavy traffic by combining with nginx and Gunicorn.
4 |
5 |
6 | It has been heavily tested by large quantity of users in the last months.
7 |
8 | Who need this?
9 |
10 | * moderate to high traffic websites
11 | * who wants an exact replica of mega.nzbx.co ;)
12 |
13 | ---
14 |
15 | ### Content
16 |
17 | * STEP 0: Tools needed
18 | * STEP 1: Installation and configuration
19 | * STEP 2: All systems ready
20 |
21 | ---
22 |
23 | ### STEP 0: Tools needed
24 |
25 | A linux system. You also need:
26 |
27 | * nginx and supervisord: `$ sudo apt-get install nginx supervisor`
28 | * gunicorn: `$ sudo easy_install gunicorn`
29 |
30 | ---
31 |
32 | ### STEP 1: Installation and configuration
33 |
34 | * Install NZBMegasearch (**not as root**) in `/opt/` (or wherever else) by:
35 | ```
36 | $ cd /opt/
37 | $ git clone https://github.com/pillone
38 | ```
39 | > This will produce `/opt/usntssearch/`
40 |
41 | * All the example configuration files are with respect to that directory.
42 |
43 | * Edit, if needed, and copy the nginx conf file: `$ sudo cp /opt/usntssearch/large_server/nginx.conf /etc/nginx/`
44 |
45 | * Edit the 'user' field in the files contained in: `/opt/usntssearch/large_server/supervisor/conf.d/*.conf`
46 |
47 |
48 | * Depending on the expected traffic, change the parameter `-w 15` (number of concurrent workers) in `/opt/usntssearch/large_server/supervisor/conf.d/mega2.py`
49 |
50 | * Copy the supervisor configuration: `$ sudo cp -r /opt/usntssearch/large_server/supervisor /etc`
51 |
52 | * Remove the init.d file `$ sudo rm /etc/init.d/nginx`. Supervisor will take care of running and restarting all the services
53 |
54 | ---
55 |
56 | ### STEP 2: All systems ready!
57 |
58 | * Generate a valid configuration for NZBMegasearch:
59 | ```
60 | $ cd /opt/usntssearch/NZBmegasearch
61 | $ python mega2.py
62 | ```
63 | > then visit `http://serveripaddress:5000` and configure it. Alternatively, you can use a `custom_params.ini` that you have already saved from a home install.
64 |
65 | * This will start all the services:
66 | ```
67 | $ sudo supervisorctl reread
68 | $ sudo supervisorctl update
69 | $ sudo supervisorctl restart all
70 | ```
71 |
72 | * **THAT'S IT! You have successfully installed NZBMegasearch!**
73 |
74 | `
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/supervisor/conf.d/README:
--------------------------------------------------------------------------------
1 | Place custom configuration files for supervisor here. They
2 | will be read after the main configuration file in
3 | /etc/supervisor/supervisord.conf
4 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/supervisor/conf.d/detachedtrend.conf:
--------------------------------------------------------------------------------
1 | [program:detached]
2 | command = /usr/bin/python detachedtrend.py
3 | directory = /opt/usntssearch/NZBmegasearch/
4 | user = zerobyte
5 | autostart = true
6 | autorestart = true
7 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/supervisor/conf.d/mega.conf:
--------------------------------------------------------------------------------
1 | [program:mega]
2 | command = /usr/local/bin/gunicorn mega2:app --bind unix:/tmp/gunicorn.sock -w 15
3 | directory = /opt/usntssearch/NZBmegasearch/
4 | user = zerobyte
5 | autostart = true
6 | autorestart = true
7 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/supervisor/conf.d/nginx.conf:
--------------------------------------------------------------------------------
1 | [program:nginx]
2 | command=/usr/sbin/nginx
3 | user = root
4 | autostart = true
5 | autorestart = true
6 |
--------------------------------------------------------------------------------
/NZBmegasearch/large_server/supervisor/supervisord.conf:
--------------------------------------------------------------------------------
1 | ; supervisor config file
2 |
3 | [unix_http_server]
4 | file=/var/run//supervisor.sock ; (the path to the socket file)
5 | chmod=0700 ; sockef file mode (default 0700)
6 |
7 | [supervisord]
8 | logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
9 | pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
10 | childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
11 |
12 | ; the below section must remain in the config file for RPC
13 | ; (supervisorctl/web interface) to work, additional interfaces may be
14 | ; added by defining them in separate rpcinterface: sections
15 | [rpcinterface:supervisor]
16 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
17 |
18 | [supervisorctl]
19 | serverurl=unix:///var/run//supervisor.sock ; use a unix:// URL for a unix socket
20 |
21 | ; The [include] section can just contain the "files" setting. This
22 | ; setting can list multiple files (separated by whitespace or
23 | ; newlines). It can also contain wildcards. The filenames are
24 | ; interpreted as relative to this file. Included files *cannot*
25 | ; include files themselves.
26 |
27 | [include]
28 | files = /etc/supervisor/conf.d/*.conf
29 |
--------------------------------------------------------------------------------
/NZBmegasearch/logs/placeholder:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/logs/placeholder
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_auth.py:
--------------------------------------------------------------------------------
1 | """HTTP Authentication and Proxy support.
2 |
3 |
4 | Copyright 2006 John J. Lee
5 |
6 | This code is free software; you can redistribute it and/or modify it under
7 | the terms of the BSD or ZPL 2.1 licenses (see the file COPYING.txt
8 | included with the distribution).
9 |
10 | """
11 |
12 | from _urllib2_fork import HTTPPasswordMgr
13 |
14 |
15 | # TODO: stop deriving from HTTPPasswordMgr
16 | class HTTPProxyPasswordMgr(HTTPPasswordMgr):
17 | # has default realm and host/port
18 | def add_password(self, realm, uri, user, passwd):
19 | # uri could be a single URI or a sequence
20 | if uri is None or isinstance(uri, basestring):
21 | uris = [uri]
22 | else:
23 | uris = uri
24 | passwd_by_domain = self.passwd.setdefault(realm, {})
25 | for uri in uris:
26 | for default_port in True, False:
27 | reduced_uri = self.reduce_uri(uri, default_port)
28 | passwd_by_domain[reduced_uri] = (user, passwd)
29 |
30 | def find_user_password(self, realm, authuri):
31 | attempts = [(realm, authuri), (None, authuri)]
32 | # bleh, want default realm to take precedence over default
33 | # URI/authority, hence this outer loop
34 | for default_uri in False, True:
35 | for realm, authuri in attempts:
36 | authinfo_by_domain = self.passwd.get(realm, {})
37 | for default_port in True, False:
38 | reduced_authuri = self.reduce_uri(authuri, default_port)
39 | for uri, authinfo in authinfo_by_domain.iteritems():
40 | if uri is None and not default_uri:
41 | continue
42 | if self.is_suburi(uri, reduced_authuri):
43 | return authinfo
44 | user, password = None, None
45 |
46 | if user is not None:
47 | break
48 | return user, password
49 |
50 | def reduce_uri(self, uri, default_port=True):
51 | if uri is None:
52 | return None
53 | return HTTPPasswordMgr.reduce_uri(self, uri, default_port)
54 |
55 | def is_suburi(self, base, test):
56 | if base is None:
57 | # default to the proxy's host/port
58 | hostport, path = test
59 | base = (hostport, "/")
60 | return HTTPPasswordMgr.is_suburi(self, base, test)
61 |
62 |
63 | class HTTPSClientCertMgr(HTTPPasswordMgr):
64 | # implementation inheritance: this is not a proper subclass
65 | def add_key_cert(self, uri, key_file, cert_file):
66 | self.add_password(None, uri, key_file, cert_file)
67 |
68 | def find_key_cert(self, authuri):
69 | return HTTPPasswordMgr.find_user_password(self, None, authuri)
70 |
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_debug.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | from _response import response_seek_wrapper
4 | from _urllib2_fork import BaseHandler
5 |
6 |
7 | class HTTPResponseDebugProcessor(BaseHandler):
8 | handler_order = 900 # before redirections, after everything else
9 |
10 | def http_response(self, request, response):
11 | if not hasattr(response, "seek"):
12 | response = response_seek_wrapper(response)
13 | info = logging.getLogger("mechanize.http_responses").info
14 | try:
15 | info(response.read())
16 | finally:
17 | response.seek(0)
18 | info("*****************************************************")
19 | return response
20 |
21 | https_response = http_response
22 |
23 |
24 | class HTTPRedirectDebugProcessor(BaseHandler):
25 | def http_request(self, request):
26 | if hasattr(request, "redirect_dict"):
27 | info = logging.getLogger("mechanize.http_redirects").info
28 | info("redirecting to %s", request.get_full_url())
29 | return request
30 |
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_gzip.py:
--------------------------------------------------------------------------------
1 | from cStringIO import StringIO
2 |
3 | import _response
4 | import _urllib2_fork
5 |
6 |
7 | # GzipConsumer was taken from Fredrik Lundh's effbot.org-0.1-20041009 library
8 | class GzipConsumer:
9 | def __init__(self, consumer):
10 | self.__consumer = consumer
11 | self.__decoder = None
12 | self.__data = ""
13 |
14 | def __getattr__(self, key):
15 | return getattr(self.__consumer, key)
16 |
17 | def feed(self, data):
18 | if self.__decoder is None:
19 | # check if we have a full gzip header
20 | data = self.__data + data
21 | try:
22 | i = 10
23 | flag = ord(data[3])
24 | if flag & 4: # extra
25 | x = ord(data[i]) + 256 * ord(data[i + 1])
26 | i = i + 2 + x
27 | if flag & 8: # filename
28 | while ord(data[i]):
29 | i = i + 1
30 | i = i + 1
31 | if flag & 16: # comment
32 | while ord(data[i]):
33 | i = i + 1
34 | i = i + 1
35 | if flag & 2: # crc
36 | i = i + 2
37 | if len(data) < i:
38 | raise IndexError("not enough data")
39 | if data[:3] != "\x1f\x8b\x08":
40 | raise IOError("invalid gzip data")
41 | data = data[i:]
42 | except IndexError:
43 | self.__data = data
44 | return # need more data
45 | import zlib
46 |
47 | self.__data = ""
48 | self.__decoder = zlib.decompressobj(-zlib.MAX_WBITS)
49 | data = self.__decoder.decompress(data)
50 | if data:
51 | self.__consumer.feed(data)
52 |
53 | def close(self):
54 | if self.__decoder:
55 | data = self.__decoder.flush()
56 | if data:
57 | self.__consumer.feed(data)
58 | self.__consumer.close()
59 |
60 |
61 | # --------------------------------------------------------------------
62 |
63 | # the rest of this module is John Lee's stupid code, not
64 | # Fredrik's nice code :-)
65 |
66 | class stupid_gzip_consumer:
67 | def __init__(self): self.data = []
68 |
69 | def feed(self, data): self.data.append(data)
70 |
71 |
72 | class stupid_gzip_wrapper(_response.closeable_response):
73 | def __init__(self, response):
74 | self._response = response
75 |
76 | c = stupid_gzip_consumer()
77 | gzc = GzipConsumer(c)
78 | gzc.feed(response.read())
79 | self.__data = StringIO("".join(c.data))
80 |
81 | def read(self, size=-1):
82 | return self.__data.read(size)
83 |
84 | def readline(self, size=-1):
85 | return self.__data.readline(size)
86 |
87 | def readlines(self, sizehint=-1):
88 | return self.__data.readlines(sizehint)
89 |
90 | def __getattr__(self, name):
91 | # delegate unknown methods/attributes
92 | return getattr(self._response, name)
93 |
94 |
95 | class HTTPGzipProcessor(_urllib2_fork.BaseHandler):
96 | handler_order = 200 # response processing before HTTPEquivProcessor
97 |
98 | def http_request(self, request):
99 | request.add_header("Accept-Encoding", "gzip")
100 | return request
101 |
102 | def http_response(self, request, response):
103 | # post-process response
104 | enc_hdrs = response.info().getheaders("Content-encoding")
105 | for enc_hdr in enc_hdrs:
106 | if ("gzip" in enc_hdr) or ("compress" in enc_hdr):
107 | return stupid_gzip_wrapper(response)
108 | return response
109 |
110 | https_response = http_response
111 |
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_request.py:
--------------------------------------------------------------------------------
1 | """Integration with Python standard library module urllib2: Request class.
2 |
3 | Copyright 2004-2006 John J Lee
4 |
5 | This code is free software; you can redistribute it and/or modify it
6 | under the terms of the BSD or ZPL 2.1 licenses (see the file
7 | COPYING.txt included with the distribution).
8 |
9 | """
10 |
11 | import logging
12 |
13 | import _rfc3986
14 | import _sockettimeout
15 | import _urllib2_fork
16 |
17 | warn = logging.getLogger("mechanize").warning
18 |
19 |
20 | class Request(_urllib2_fork.Request):
21 | def __init__(self, url, data=None, headers={},
22 | origin_req_host=None, unverifiable=False, visit=None,
23 | timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
24 | # In mechanize 0.2, the interpretation of a unicode url argument will
25 | # change: A unicode url argument will be interpreted as an IRI, and a
26 | # bytestring as a URI. For now, we accept unicode or bytestring. We
27 | # don't insist that the value is always a URI (specifically, must only
28 | # contain characters which are legal), because that might break working
29 | # code (who knows what bytes some servers want to see, especially with
30 | # browser plugins for internationalised URIs).
31 | if not _rfc3986.is_clean_uri(url):
32 | warn("url argument is not a URI "
33 | "(contains illegal characters) %r" % url)
34 | _urllib2_fork.Request.__init__(self, url, data, headers)
35 | self.selector = None
36 | self.visit = visit
37 | self.timeout = timeout
38 |
39 | def __str__(self):
40 | return "" % self.get_full_url()
41 |
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_sockettimeout.py:
--------------------------------------------------------------------------------
1 | import socket
2 |
3 | try:
4 | _GLOBAL_DEFAULT_TIMEOUT = socket._GLOBAL_DEFAULT_TIMEOUT
5 | except AttributeError:
6 | _GLOBAL_DEFAULT_TIMEOUT = object()
7 |
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_urllib2.py:
--------------------------------------------------------------------------------
1 | # urllib2 work-alike interface
2 | # ...from urllib2...
3 | from urllib2 import \
4 | URLError, \
5 | HTTPError
6 | # ...and from mechanize
7 | from _auth import \
8 | HTTPProxyPasswordMgr, \
9 | HTTPSClientCertMgr
10 | from _debug import \
11 | HTTPResponseDebugProcessor, \
12 | HTTPRedirectDebugProcessor
13 | # crap ATM
14 | ## from _gzip import \
15 | ## HTTPGzipProcessor
16 | from _urllib2_fork import \
17 | AbstractBasicAuthHandler, \
18 | AbstractDigestAuthHandler, \
19 | BaseHandler, \
20 | CacheFTPHandler, \
21 | FileHandler, \
22 | FTPHandler, \
23 | HTTPBasicAuthHandler, \
24 | HTTPCookieProcessor, \
25 | HTTPDefaultErrorHandler, \
26 | HTTPDigestAuthHandler, \
27 | HTTPErrorProcessor, \
28 | HTTPHandler, \
29 | HTTPPasswordMgr, \
30 | HTTPPasswordMgrWithDefaultRealm, \
31 | HTTPRedirectHandler, \
32 | ProxyBasicAuthHandler, \
33 | ProxyDigestAuthHandler, \
34 | ProxyHandler, \
35 | UnknownHandler
36 | from _http import \
37 | HTTPEquivProcessor, \
38 | HTTPRefererProcessor, \
39 | HTTPRefreshProcessor, \
40 | HTTPRobotRulesProcessor, \
41 | RobotExclusionError
42 | import httplib
43 |
44 | if hasattr(httplib, 'HTTPS'):
45 | from _urllib2_fork import HTTPSHandler
46 | del httplib
47 | from _opener import OpenerDirector, \
48 | SeekableResponseOpener, \
49 | build_opener, install_opener, urlopen
50 | from _request import \
51 | Request
52 |
--------------------------------------------------------------------------------
/NZBmegasearch/mechanize/_version.py:
--------------------------------------------------------------------------------
1 | "0.2.5"
2 | __version__ = (0, 2, 5, None, None)
3 |
--------------------------------------------------------------------------------
/NZBmegasearch/openshift/app.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import imp
3 | import os
4 | import sys
5 |
6 | PYCART_DIR = ''.join(['python-', '.'.join(map(str, sys.version_info[:2]))])
7 |
8 | try:
9 | zvirtenv = os.path.join(os.environ['OPENSHIFT_HOMEDIR'], PYCART_DIR,
10 | 'virtenv', 'bin', 'activate_this.py')
11 | execfile(zvirtenv, dict(__file__=zvirtenv))
12 | except IOError:
13 | pass
14 |
15 |
16 | def run_gevent_server(app, ip, port=8080):
17 | from gevent.pywsgi import WSGIServer
18 |
19 | WSGIServer((ip, port), app).serve_forever()
20 |
21 |
22 | def run_simple_httpd_server(app, ip, port=8080):
23 | from wsgiref.simple_server import make_server
24 |
25 | make_server(ip, port, app).serve_forever()
26 |
27 | #
28 | # IMPORTANT: Put any additional includes below this line. If placed above this
29 | # line, it's possible required libraries won't be in your searchable path
30 | #
31 |
32 |
33 | #
34 | # main():
35 | #
36 | if __name__ == '__main__':
37 | ip = os.environ['OPENSHIFT_PYTHON_IP']
38 | port = int(os.environ['OPENSHIFT_PYTHON_PORT'])
39 |
40 | zapp = imp.load_source('application', 'wsgi/usntssearch/NZBmegasearch/application')
41 |
42 | # Use gevent if we have it, otherwise run a simple httpd server.
43 | print 'Starting WSGIServer on %s:%d ... ' % (ip, port)
44 | try:
45 | run_gevent_server(zapp.application, ip, port)
46 | except:
47 | print 'gevent probably not installed - using default simple server ...'
48 | run_simple_httpd_server(zapp.application, ip, port)
49 |
--------------------------------------------------------------------------------
/NZBmegasearch/openshift/application:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | import os
3 | import sys
4 |
5 | sys.path.insert(0, os.path.dirname(__file__) or '.')
6 | PY_VERSION = 'python-' + ('.'.join(map(str, sys.version_info[:2])))
7 | PY_DIR = os.environ['HOME'] + '/' + PY_VERSION
8 |
9 | virtenv = PY_DIR + '/virtenv/'
10 |
11 | PY_CACHE = virtenv + 'lib/' + PY_VERSION + '/site-packages'
12 |
13 | os.environ['PYTHON_EGG_CACHE'] = os.path.join(PY_CACHE)
14 | virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
15 |
16 | try:
17 | execfile(virtualenv, dict(__file__=virtualenv))
18 | except IOError:
19 | pass
20 |
21 | # ~ this is for exclusive usage of Openshift
22 | from mega2 import app as application
23 |
--------------------------------------------------------------------------------
/NZBmegasearch/openshift/install_openshift.sh:
--------------------------------------------------------------------------------
1 | #~ OPENSHIFT_DATA_DIR
2 | echo '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*'
3 | echo ' NZBMEGASEARCH install for Openshift'
4 | echo '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*'
5 |
6 | echo 'Running update -- 01/02'
7 | git fetch
8 |
9 | echo 'Running update -- 02/02'
10 | git reset --hard origin/master
11 |
12 | echo 'Preparing...'
13 | cp ../builtin_params.ini .
14 |
15 | #~ SETS DEFAULT PWD
16 | grep -v '^general_user' ../builtin_params.ini | grep -v '^general_pwd' > tmpfl.tmp
17 | printf 'general_user = NZBMadmin\ngeneral_pwd = NZBMadmin\n' >> ../builtin_params.ini
18 |
19 | cp ../builtin_params.ini $OPENSHIFT_DATA_DIR
20 | cp ../vernum.num $OPENSHIFT_DATA_DIR
21 | cp application $OPENSHIFT_REPO_DIR/wsgi/usntssearch/NZBmegasearch/
22 | cp app.py $OPENSHIFT_REPO_DIR/
23 |
24 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # __
4 | # /__) _ _ _ _ _/ _
5 | # / ( (- (/ (/ (- _) / _)
6 | # /
7 |
8 | """
9 | requests HTTP library
10 | ~~~~~~~~~~~~~~~~~~~~~
11 |
12 | Requests is an HTTP library, written in Python, for human beings. Basic GET
13 | usage:
14 |
15 | >>> import requests
16 | >>> r = requests.get('http://python.org')
17 | >>> r.status_code
18 | 200
19 | >>> 'Python is a programming language' in r.content
20 | True
21 |
22 | ... or POST:
23 |
24 | >>> payload = dict(key1='value1', key2='value2')
25 | >>> r = requests.post("http://httpbin.org/post", data=payload)
26 | >>> print r.text
27 | {
28 | ...
29 | "form": {
30 | "key2": "value2",
31 | "key1": "value1"
32 | },
33 | ...
34 | }
35 |
36 | The other HTTP methods are supported - see `requests.api`. Full documentation
37 | is at .
38 |
39 | :copyright: (c) 2013 by Kenneth Reitz.
40 | :license: Apache 2.0, see LICENSE for more details.
41 |
42 | """
43 |
44 | __title__ = 'requests'
45 | __version__ = '1.1.0'
46 | __build__ = 0x010100
47 | __author__ = 'Kenneth Reitz'
48 | __license__ = 'Apache 2.0'
49 | __copyright__ = 'Copyright 2013 Kenneth Reitz'
50 |
51 | from . import utils
52 | from .models import Request, Response, PreparedRequest
53 | from .api import request, get, head, post, patch, put, delete, options
54 | from .sessions import session, Session
55 | from .status_codes import codes
56 | from .exceptions import (
57 | RequestException, Timeout, URLRequired,
58 | TooManyRedirects, HTTPError, ConnectionError
59 | )
60 |
61 | # Set default logging handler to avoid "No handler found" warnings.
62 | import logging
63 |
64 | try: # Python 2.7+
65 | from logging import NullHandler
66 | except ImportError:
67 | class NullHandler(logging.Handler):
68 | def emit(self, record):
69 | pass
70 |
71 | logging.getLogger(__name__).addHandler(NullHandler())
72 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/certs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | """
5 | certs.py
6 | ~~~~~~~~
7 |
8 | This module returns the preferred default CA certificate bundle.
9 |
10 | If you are packaging Requests, e.g., for a Linux distribution or a managed
11 | environment, you can change the definition of where() to return a separately
12 | packaged CA bundle.
13 | """
14 |
15 | import os.path
16 |
17 |
18 | def where():
19 | """Return the preferred certificate bundle."""
20 | # vendored bundle inside Requests
21 | return os.path.join(os.path.dirname(__file__), 'cacert.pem')
22 |
23 |
24 | if __name__ == '__main__':
25 | print(where())
26 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/compat.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | pythoncompat
5 | """
6 |
7 | from .packages import charade as chardet
8 |
9 | import sys
10 |
11 | # -------
12 | # Pythons
13 | # -------
14 |
15 | # Syntax sugar.
16 | _ver = sys.version_info
17 |
18 | #: Python 2.x?
19 | is_py2 = (_ver[0] == 2)
20 |
21 | #: Python 3.x?
22 | is_py3 = (_ver[0] == 3)
23 |
24 | #: Python 3.0.x
25 | is_py30 = (is_py3 and _ver[1] == 0)
26 |
27 | #: Python 3.1.x
28 | is_py31 = (is_py3 and _ver[1] == 1)
29 |
30 | #: Python 3.2.x
31 | is_py32 = (is_py3 and _ver[1] == 2)
32 |
33 | #: Python 3.3.x
34 | is_py33 = (is_py3 and _ver[1] == 3)
35 |
36 | #: Python 3.4.x
37 | is_py34 = (is_py3 and _ver[1] == 4)
38 |
39 | #: Python 2.7.x
40 | is_py27 = (is_py2 and _ver[1] == 7)
41 |
42 | #: Python 2.6.x
43 | is_py26 = (is_py2 and _ver[1] == 6)
44 |
45 | #: Python 2.5.x
46 | is_py25 = (is_py2 and _ver[1] == 5)
47 |
48 | #: Python 2.4.x
49 | is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.
50 |
51 |
52 | # ---------
53 | # Platforms
54 | # ---------
55 |
56 |
57 | # Syntax sugar.
58 | _ver = sys.version.lower()
59 |
60 | is_pypy = ('pypy' in _ver)
61 | is_jython = ('jython' in _ver)
62 | is_ironpython = ('iron' in _ver)
63 |
64 | # Assume CPython, if nothing else.
65 | is_cpython = not any((is_pypy, is_jython, is_ironpython))
66 |
67 | # Windows-based system.
68 | is_windows = 'win32' in str(sys.platform).lower()
69 |
70 | # Standard Linux 2+ system.
71 | is_linux = ('linux' in str(sys.platform).lower())
72 | is_osx = ('darwin' in str(sys.platform).lower())
73 | is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.
74 | is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.
75 |
76 | try:
77 | import simplejson as json
78 | except ImportError:
79 | import json
80 |
81 | # ---------
82 | # Specifics
83 | # ---------
84 |
85 | if is_py2:
86 | from urllib import quote, unquote, quote_plus, unquote_plus, urlencode
87 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
88 | from urllib2 import parse_http_list
89 | import cookielib
90 | from Cookie import Morsel
91 | from StringIO import StringIO
92 | from .packages.urllib3.packages.ordered_dict import OrderedDict
93 |
94 | builtin_str = str
95 | bytes = str
96 | str = unicode
97 | basestring = basestring
98 | numeric_types = (int, long, float)
99 |
100 |
101 | elif is_py3:
102 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, \
103 | unquote_plus, urldefrag
104 | from urllib.request import parse_http_list
105 | from http import cookiejar as cookielib
106 | from http.cookies import Morsel
107 | from io import StringIO
108 | from collections import OrderedDict
109 |
110 | builtin_str = str
111 | str = str
112 | bytes = bytes
113 | basestring = (str, bytes)
114 | numeric_types = (int, float)
115 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/exceptions.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.exceptions
5 | ~~~~~~~~~~~~~~~~~~~
6 |
7 | This module contains the set of Requests' exceptions.
8 |
9 | """
10 |
11 |
12 | class RequestException(RuntimeError):
13 | """There was an ambiguous exception that occurred while handling your
14 | request."""
15 |
16 |
17 | class HTTPError(RequestException):
18 | """An HTTP error occurred."""
19 | response = None
20 |
21 |
22 | class ConnectionError(RequestException):
23 | """A Connection error occurred."""
24 |
25 |
26 | class SSLError(ConnectionError):
27 | """An SSL error occurred."""
28 |
29 |
30 | class Timeout(RequestException):
31 | """The request timed out."""
32 |
33 |
34 | class URLRequired(RequestException):
35 | """A valid URL is required to make a request."""
36 |
37 |
38 | class TooManyRedirects(RequestException):
39 | """Too many redirects."""
40 |
41 |
42 | class MissingSchema(RequestException, ValueError):
43 | """The URL schema (e.g. http or https) is missing."""
44 |
45 |
46 | class InvalidSchema(RequestException, ValueError):
47 | """See defaults.py for valid schemas."""
48 |
49 |
50 | class InvalidURL(RequestException, ValueError):
51 | """ The URL provided was somehow invalid. """
52 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/hooks.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.hooks
5 | ~~~~~~~~~~~~~~
6 |
7 | This module provides the capabilities for the Requests hooks system.
8 |
9 | Available hooks:
10 |
11 | ``response``:
12 | The response generated from a Request.
13 |
14 | """
15 |
16 | HOOKS = ['response']
17 |
18 |
19 | def default_hooks():
20 | hooks = {}
21 | for event in HOOKS:
22 | hooks[event] = []
23 | return hooks
24 |
25 |
26 | # TODO: response is the only one
27 |
28 |
29 | def dispatch_hook(key, hooks, hook_data):
30 | """Dispatches a hook dictionary on a given piece of data."""
31 |
32 | hooks = hooks or dict()
33 |
34 | if key in hooks:
35 | hooks = hooks.get(key)
36 |
37 | if hasattr(hooks, '__call__'):
38 | hooks = [hooks]
39 |
40 | for hook in hooks:
41 | _hook_data = hook(hook_data)
42 | if _hook_data is not None:
43 | hook_data = _hook_data
44 |
45 | return hook_data
46 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 |
3 | from . import urllib3
4 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/__init__.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # This library is free software; you can redistribute it and/or
3 | # modify it under the terms of the GNU Lesser General Public
4 | # License as published by the Free Software Foundation; either
5 | # version 2.1 of the License, or (at your option) any later version.
6 | #
7 | # This library is distributed in the hope that it will be useful,
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 | # Lesser General Public License for more details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public
13 | # License along with this library; if not, write to the Free Software
14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
15 | # 02110-1301 USA
16 | ######################### END LICENSE BLOCK #########################
17 |
18 | __version__ = "1.0.1"
19 |
20 |
21 | def detect(aBuf):
22 | from . import universaldetector
23 |
24 | u = universaldetector.UniversalDetector()
25 | u.reset()
26 | u.feed(aBuf)
27 | u.close()
28 | return u.result
29 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/big5prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Communicator client code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import Big5DistributionAnalysis
31 | from .mbcssm import Big5SMModel
32 |
33 |
34 | class Big5Prober(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(Big5SMModel)
38 | self._mDistributionAnalyzer = Big5DistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "Big5"
43 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/charsetprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | from . import constants
30 | import re
31 |
32 |
33 | class CharSetProber:
34 | def __init__(self):
35 | pass
36 |
37 | def reset(self):
38 | self._mState = constants.eDetecting
39 |
40 | def get_charset_name(self):
41 | return None
42 |
43 | def feed(self, aBuf):
44 | pass
45 |
46 | def get_state(self):
47 | return self._mState
48 |
49 | def get_confidence(self):
50 | return 0.0
51 |
52 | def filter_high_bit_only(self, aBuf):
53 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf)
54 | return aBuf
55 |
56 | def filter_without_english_letters(self, aBuf):
57 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf)
58 | return aBuf
59 |
60 | def filter_with_english_letters(self, aBuf):
61 | # TODO
62 | return aBuf
63 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/codingstatemachine.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .constants import eStart
29 | from .compat import wrap_ord
30 |
31 |
32 | class CodingStateMachine:
33 | def __init__(self, sm):
34 | self._mModel = sm
35 | self._mCurrentBytePos = 0
36 | self._mCurrentCharLen = 0
37 | self.reset()
38 |
39 | def reset(self):
40 | self._mCurrentState = eStart
41 |
42 | def next_state(self, c):
43 | # for each byte we get its class
44 | # if it is first byte, we also get byte length
45 | # PY3K: aBuf is a byte stream, so c is an int, not a byte
46 | byteCls = self._mModel['classTable'][wrap_ord(c)]
47 | if self._mCurrentState == eStart:
48 | self._mCurrentBytePos = 0
49 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]
50 | # from byte's class and stateTable, we get its next state
51 | curr_state = (self._mCurrentState * self._mModel['classFactor']
52 | + byteCls)
53 | self._mCurrentState = self._mModel['stateTable'][curr_state]
54 | self._mCurrentBytePos += 1
55 | return self._mCurrentState
56 |
57 | def get_current_charlen(self):
58 | return self._mCurrentCharLen
59 |
60 | def get_coding_state_machine(self):
61 | return self._mModel['name']
62 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/compat.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # Contributor(s):
3 | # Ian Cordasco - port to Python
4 | #
5 | # This library is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU Lesser General Public
7 | # License as published by the Free Software Foundation; either
8 | # version 2.1 of the License, or (at your option) any later version.
9 | #
10 | # This library is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # Lesser General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU Lesser General Public
16 | # License along with this library; if not, write to the Free Software
17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 | # 02110-1301 USA
19 | ######################### END LICENSE BLOCK #########################
20 |
21 |
22 | def wrap_ord(a):
23 | if isinstance(a, str):
24 | return ord(a)
25 | elif isinstance(a, int):
26 | return a
27 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/constants.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | _debug = 0
30 |
31 | eDetecting = 0
32 | eFoundIt = 1
33 | eNotMe = 2
34 |
35 | eStart = 0
36 | eError = 1
37 | eItsMe = 2
38 |
39 | SHORTCUT_THRESHOLD = 0.95
40 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/escprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from . import constants
29 | from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,
30 | ISO2022KRSMModel)
31 | from .charsetprober import CharSetProber
32 | from .codingstatemachine import CodingStateMachine
33 | from .compat import wrap_ord
34 |
35 |
36 | class EscCharSetProber(CharSetProber):
37 | def __init__(self):
38 | CharSetProber.__init__(self)
39 | self._mCodingSM = [
40 | CodingStateMachine(HZSMModel),
41 | CodingStateMachine(ISO2022CNSMModel),
42 | CodingStateMachine(ISO2022JPSMModel),
43 | CodingStateMachine(ISO2022KRSMModel)
44 | ]
45 | self.reset()
46 |
47 | def reset(self):
48 | CharSetProber.reset(self)
49 | for codingSM in self._mCodingSM:
50 | if not codingSM:
51 | continue
52 | codingSM.active = True
53 | codingSM.reset()
54 | self._mActiveSM = len(self._mCodingSM)
55 | self._mDetectedCharset = None
56 |
57 | def get_charset_name(self):
58 | return self._mDetectedCharset
59 |
60 | def get_confidence(self):
61 | if self._mDetectedCharset:
62 | return 0.99
63 | else:
64 | return 0.00
65 |
66 | def feed(self, aBuf):
67 | for c in aBuf:
68 | # PY3K: aBuf is a byte array, so c is an int, not a byte
69 | for codingSM in self._mCodingSM:
70 | if not codingSM:
71 | continue
72 | if not codingSM.active:
73 | continue
74 | codingState = codingSM.next_state(wrap_ord(c))
75 | if codingState == constants.eError:
76 | codingSM.active = False
77 | self._mActiveSM -= 1
78 | if self._mActiveSM <= 0:
79 | self._mState = constants.eNotMe
80 | return self.get_state()
81 | elif codingState == constants.eItsMe:
82 | self._mState = constants.eFoundIt
83 | self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8
84 | return self.get_state()
85 |
86 | return self.get_state()
87 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/eucjpprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | import sys
29 | from . import constants
30 | from .mbcharsetprober import MultiByteCharSetProber
31 | from .codingstatemachine import CodingStateMachine
32 | from .chardistribution import EUCJPDistributionAnalysis
33 | from .jpcntx import EUCJPContextAnalysis
34 | from .mbcssm import EUCJPSMModel
35 |
36 |
37 | class EUCJPProber(MultiByteCharSetProber):
38 | def __init__(self):
39 | MultiByteCharSetProber.__init__(self)
40 | self._mCodingSM = CodingStateMachine(EUCJPSMModel)
41 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis()
42 | self._mContextAnalyzer = EUCJPContextAnalysis()
43 | self.reset()
44 |
45 | def reset(self):
46 | MultiByteCharSetProber.reset(self)
47 | self._mContextAnalyzer.reset()
48 |
49 | def get_charset_name(self):
50 | return "EUC-JP"
51 |
52 | def feed(self, aBuf):
53 | aLen = len(aBuf)
54 | for i in range(0, aLen):
55 | # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte
56 | codingState = self._mCodingSM.next_state(aBuf[i])
57 | if codingState == constants.eError:
58 | if constants._debug:
59 | sys.stderr.write(self.get_charset_name()
60 | + ' prober hit error at byte ' + str(i)
61 | + '\n')
62 | self._mState = constants.eNotMe
63 | break
64 | elif codingState == constants.eItsMe:
65 | self._mState = constants.eFoundIt
66 | break
67 | elif codingState == constants.eStart:
68 | charLen = self._mCodingSM.get_current_charlen()
69 | if i == 0:
70 | self._mLastChar[1] = aBuf[0]
71 | self._mContextAnalyzer.feed(self._mLastChar, charLen)
72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
73 | else:
74 | self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)
75 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
76 | charLen)
77 |
78 | self._mLastChar[0] = aBuf[aLen - 1]
79 |
80 | if self.get_state() == constants.eDetecting:
81 | if (self._mContextAnalyzer.got_enough_data() and
82 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
83 | self._mState = constants.eFoundIt
84 |
85 | return self.get_state()
86 |
87 | def get_confidence(self):
88 | contxtCf = self._mContextAnalyzer.get_confidence()
89 | distribCf = self._mDistributionAnalyzer.get_confidence()
90 | return max(contxtCf, distribCf)
91 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/euckrprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCKRDistributionAnalysis
31 | from .mbcssm import EUCKRSMModel
32 |
33 |
34 | class EUCKRProber(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(EUCKRSMModel)
38 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "EUC-KR"
43 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/euctwprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCTWDistributionAnalysis
31 | from .mbcssm import EUCTWSMModel
32 |
33 |
34 | class EUCTWProber(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(EUCTWSMModel)
38 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "EUC-TW"
43 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/gb2312prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import GB2312DistributionAnalysis
31 | from .mbcssm import GB2312SMModel
32 |
33 |
34 | class GB2312Prober(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(GB2312SMModel)
38 | self._mDistributionAnalyzer = GB2312DistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "GB2312"
43 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/mbcharsetprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | # Proofpoint, Inc.
13 | #
14 | # This library is free software; you can redistribute it and/or
15 | # modify it under the terms of the GNU Lesser General Public
16 | # License as published by the Free Software Foundation; either
17 | # version 2.1 of the License, or (at your option) any later version.
18 | #
19 | # This library is distributed in the hope that it will be useful,
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 | # Lesser General Public License for more details.
23 | #
24 | # You should have received a copy of the GNU Lesser General Public
25 | # License along with this library; if not, write to the Free Software
26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 | # 02110-1301 USA
28 | ######################### END LICENSE BLOCK #########################
29 |
30 | import sys
31 | from . import constants
32 | from .charsetprober import CharSetProber
33 |
34 |
35 | class MultiByteCharSetProber(CharSetProber):
36 | def __init__(self):
37 | CharSetProber.__init__(self)
38 | self._mDistributionAnalyzer = None
39 | self._mCodingSM = None
40 | self._mLastChar = [0, 0]
41 |
42 | def reset(self):
43 | CharSetProber.reset(self)
44 | if self._mCodingSM:
45 | self._mCodingSM.reset()
46 | if self._mDistributionAnalyzer:
47 | self._mDistributionAnalyzer.reset()
48 | self._mLastChar = [0, 0]
49 |
50 | def get_charset_name(self):
51 | pass
52 |
53 | def feed(self, aBuf):
54 | aLen = len(aBuf)
55 | for i in range(0, aLen):
56 | codingState = self._mCodingSM.next_state(aBuf[i])
57 | if codingState == constants.eError:
58 | if constants._debug:
59 | sys.stderr.write(self.get_charset_name()
60 | + ' prober hit error at byte ' + str(i)
61 | + '\n')
62 | self._mState = constants.eNotMe
63 | break
64 | elif codingState == constants.eItsMe:
65 | self._mState = constants.eFoundIt
66 | break
67 | elif codingState == constants.eStart:
68 | charLen = self._mCodingSM.get_current_charlen()
69 | if i == 0:
70 | self._mLastChar[1] = aBuf[0]
71 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
72 | else:
73 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
74 | charLen)
75 |
76 | self._mLastChar[0] = aBuf[aLen - 1]
77 |
78 | if self.get_state() == constants.eDetecting:
79 | if (self._mDistributionAnalyzer.got_enough_data() and
80 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
81 | self._mState = constants.eFoundIt
82 |
83 | return self.get_state()
84 |
85 | def get_confidence(self):
86 | return self._mDistributionAnalyzer.get_confidence()
87 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/mbcsgroupprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | # Proofpoint, Inc.
13 | #
14 | # This library is free software; you can redistribute it and/or
15 | # modify it under the terms of the GNU Lesser General Public
16 | # License as published by the Free Software Foundation; either
17 | # version 2.1 of the License, or (at your option) any later version.
18 | #
19 | # This library is distributed in the hope that it will be useful,
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 | # Lesser General Public License for more details.
23 | #
24 | # You should have received a copy of the GNU Lesser General Public
25 | # License along with this library; if not, write to the Free Software
26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 | # 02110-1301 USA
28 | ######################### END LICENSE BLOCK #########################
29 |
30 | from .charsetgroupprober import CharSetGroupProber
31 | from .utf8prober import UTF8Prober
32 | from .sjisprober import SJISProber
33 | from .eucjpprober import EUCJPProber
34 | from .gb2312prober import GB2312Prober
35 | from .euckrprober import EUCKRProber
36 | from .big5prober import Big5Prober
37 | from .euctwprober import EUCTWProber
38 |
39 |
40 | class MBCSGroupProber(CharSetGroupProber):
41 | def __init__(self):
42 | CharSetGroupProber.__init__(self)
43 | self._mProbers = [
44 | UTF8Prober(),
45 | SJISProber(),
46 | EUCJPProber(),
47 | GB2312Prober(),
48 | EUCKRProber(),
49 | Big5Prober(),
50 | EUCTWProber()
51 | ]
52 | self.reset()
53 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/sbcsgroupprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | from .charsetgroupprober import CharSetGroupProber
30 | from .sbcharsetprober import SingleByteCharSetProber
31 | from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,
32 | Latin5CyrillicModel, MacCyrillicModel,
33 | Ibm866Model, Ibm855Model)
34 | from .langgreekmodel import Latin7GreekModel, Win1253GreekModel
35 | from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel
36 | from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel
37 | from .langthaimodel import TIS620ThaiModel
38 | from .langhebrewmodel import Win1255HebrewModel
39 | from .hebrewprober import HebrewProber
40 |
41 |
42 | class SBCSGroupProber(CharSetGroupProber):
43 | def __init__(self):
44 | CharSetGroupProber.__init__(self)
45 | self._mProbers = [
46 | SingleByteCharSetProber(Win1251CyrillicModel),
47 | SingleByteCharSetProber(Koi8rModel),
48 | SingleByteCharSetProber(Latin5CyrillicModel),
49 | SingleByteCharSetProber(MacCyrillicModel),
50 | SingleByteCharSetProber(Ibm866Model),
51 | SingleByteCharSetProber(Ibm855Model),
52 | SingleByteCharSetProber(Latin7GreekModel),
53 | SingleByteCharSetProber(Win1253GreekModel),
54 | SingleByteCharSetProber(Latin5BulgarianModel),
55 | SingleByteCharSetProber(Win1251BulgarianModel),
56 | SingleByteCharSetProber(Latin2HungarianModel),
57 | SingleByteCharSetProber(Win1250HungarianModel),
58 | SingleByteCharSetProber(TIS620ThaiModel),
59 | ]
60 | hebrewProber = HebrewProber()
61 | logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,
62 | False, hebrewProber)
63 | visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,
64 | hebrewProber)
65 | hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)
66 | self._mProbers.extend([hebrewProber, logicalHebrewProber,
67 | visualHebrewProber])
68 |
69 | self.reset()
70 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/sjisprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | import sys
29 | from .mbcharsetprober import MultiByteCharSetProber
30 | from .codingstatemachine import CodingStateMachine
31 | from .chardistribution import SJISDistributionAnalysis
32 | from .jpcntx import SJISContextAnalysis
33 | from .mbcssm import SJISSMModel
34 | from . import constants
35 |
36 |
37 | class SJISProber(MultiByteCharSetProber):
38 | def __init__(self):
39 | MultiByteCharSetProber.__init__(self)
40 | self._mCodingSM = CodingStateMachine(SJISSMModel)
41 | self._mDistributionAnalyzer = SJISDistributionAnalysis()
42 | self._mContextAnalyzer = SJISContextAnalysis()
43 | self.reset()
44 |
45 | def reset(self):
46 | MultiByteCharSetProber.reset(self)
47 | self._mContextAnalyzer.reset()
48 |
49 | def get_charset_name(self):
50 | return "SHIFT_JIS"
51 |
52 | def feed(self, aBuf):
53 | aLen = len(aBuf)
54 | for i in range(0, aLen):
55 | codingState = self._mCodingSM.next_state(aBuf[i])
56 | if codingState == constants.eError:
57 | if constants._debug:
58 | sys.stderr.write(self.get_charset_name()
59 | + ' prober hit error at byte ' + str(i)
60 | + '\n')
61 | self._mState = constants.eNotMe
62 | break
63 | elif codingState == constants.eItsMe:
64 | self._mState = constants.eFoundIt
65 | break
66 | elif codingState == constants.eStart:
67 | charLen = self._mCodingSM.get_current_charlen()
68 | if i == 0:
69 | self._mLastChar[1] = aBuf[0]
70 | self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],
71 | charLen)
72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
73 | else:
74 | self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3
75 | - charLen], charLen)
76 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
77 | charLen)
78 |
79 | self._mLastChar[0] = aBuf[aLen - 1]
80 |
81 | if self.get_state() == constants.eDetecting:
82 | if (self._mContextAnalyzer.got_enough_data() and
83 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
84 | self._mState = constants.eFoundIt
85 |
86 | return self.get_state()
87 |
88 | def get_confidence(self):
89 | contxtCf = self._mContextAnalyzer.get_confidence()
90 | distribCf = self._mDistributionAnalyzer.get_confidence()
91 | return max(contxtCf, distribCf)
92 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/charade/utf8prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from . import constants
29 | from .charsetprober import CharSetProber
30 | from .codingstatemachine import CodingStateMachine
31 | from .mbcssm import UTF8SMModel
32 |
33 | ONE_CHAR_PROB = 0.5
34 |
35 |
36 | class UTF8Prober(CharSetProber):
37 | def __init__(self):
38 | CharSetProber.__init__(self)
39 | self._mCodingSM = CodingStateMachine(UTF8SMModel)
40 | self.reset()
41 |
42 | def reset(self):
43 | CharSetProber.reset(self)
44 | self._mCodingSM.reset()
45 | self._mNumOfMBChar = 0
46 |
47 | def get_charset_name(self):
48 | return "utf-8"
49 |
50 | def feed(self, aBuf):
51 | for c in aBuf:
52 | codingState = self._mCodingSM.next_state(c)
53 | if codingState == constants.eError:
54 | self._mState = constants.eNotMe
55 | break
56 | elif codingState == constants.eItsMe:
57 | self._mState = constants.eFoundIt
58 | break
59 | elif codingState == constants.eStart:
60 | if self._mCodingSM.get_current_charlen() >= 2:
61 | self._mNumOfMBChar += 1
62 |
63 | if self.get_state() == constants.eDetecting:
64 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD:
65 | self._mState = constants.eFoundIt
66 |
67 | return self.get_state()
68 |
69 | def get_confidence(self):
70 | unlike = 0.99
71 | if self._mNumOfMBChar < 6:
72 | for i in range(0, self._mNumOfMBChar):
73 | unlike = unlike * ONE_CHAR_PROB
74 | return 1.0 - unlike
75 | else:
76 | return unlike
77 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/__init__.py:
--------------------------------------------------------------------------------
1 | # urllib3/__init__.py
2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | """
8 | urllib3 - Thread-safe connection pooling and re-using.
9 | """
10 |
11 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)'
12 | __license__ = 'MIT'
13 | __version__ = 'dev'
14 |
15 | from .connectionpool import (
16 | HTTPConnectionPool,
17 | HTTPSConnectionPool,
18 | connection_from_url
19 | )
20 |
21 | from . import exceptions
22 | from .filepost import encode_multipart_formdata
23 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url
24 | from .response import HTTPResponse
25 | from .util import make_headers, get_host
26 |
27 |
28 | # Set default logging handler to avoid "No handler found" warnings.
29 | import logging
30 |
31 | try: # Python 2.7+
32 | from logging import NullHandler
33 | except ImportError:
34 | class NullHandler(logging.Handler):
35 | def emit(self, record):
36 | pass
37 |
38 | logging.getLogger(__name__).addHandler(NullHandler())
39 |
40 |
41 | def add_stderr_logger(level=logging.DEBUG):
42 | """
43 | Helper for quickly adding a StreamHandler to the logger. Useful for
44 | debugging.
45 |
46 | Returns the handler after adding it.
47 | """
48 | # This method needs to be in this __init__.py to get the __name__ correct
49 | # even if urllib3 is vendored within another package.
50 | logger = logging.getLogger(__name__)
51 | handler = logging.StreamHandler()
52 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
53 | logger.addHandler(handler)
54 | logger.setLevel(level)
55 | logger.debug('Added an stderr logging handler to logger: %s' % __name__)
56 | return handler
57 |
58 | # ... Clean up.
59 | del NullHandler
60 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/_collections.py:
--------------------------------------------------------------------------------
1 | # urllib3/_collections.py
2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | from collections import MutableMapping
8 | from threading import Lock
9 |
10 | try: # Python 2.7+
11 | from collections import OrderedDict
12 | except ImportError:
13 | from .packages.ordered_dict import OrderedDict
14 |
15 | __all__ = ['RecentlyUsedContainer']
16 |
17 | _Null = object()
18 |
19 |
20 | class RecentlyUsedContainer(MutableMapping):
21 | """
22 | Provides a thread-safe dict-like container which maintains up to
23 | ``maxsize`` keys while throwing away the least-recently-used keys beyond
24 | ``maxsize``.
25 |
26 | :param maxsize:
27 | Maximum number of recent elements to retain.
28 |
29 | :param dispose_func:
30 | Every time an item is evicted from the container,
31 | ``dispose_func(value)`` is called. Callback which will get called
32 | """
33 |
34 | ContainerCls = OrderedDict
35 |
36 | def __init__(self, maxsize=10, dispose_func=None):
37 | self._maxsize = maxsize
38 | self.dispose_func = dispose_func
39 |
40 | self._container = self.ContainerCls()
41 | self._lock = Lock()
42 |
43 | def __getitem__(self, key):
44 | # Re-insert the item, moving it to the end of the eviction line.
45 | with self._lock:
46 | item = self._container.pop(key)
47 | self._container[key] = item
48 | return item
49 |
50 | def __setitem__(self, key, value):
51 | evicted_value = _Null
52 | with self._lock:
53 | # Possibly evict the existing value of 'key'
54 | evicted_value = self._container.get(key, _Null)
55 | self._container[key] = value
56 |
57 | # If we didn't evict an existing value, we might have to evict the
58 | # least recently used item from the beginning of the container.
59 | if len(self._container) > self._maxsize:
60 | _key, evicted_value = self._container.popitem(last=False)
61 |
62 | if self.dispose_func and evicted_value is not _Null:
63 | self.dispose_func(evicted_value)
64 |
65 | def __delitem__(self, key):
66 | with self._lock:
67 | value = self._container.pop(key)
68 |
69 | if self.dispose_func:
70 | self.dispose_func(value)
71 |
72 | def __len__(self):
73 | with self._lock:
74 | return len(self._container)
75 |
76 | def __iter__(self):
77 | raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.')
78 |
79 | def clear(self):
80 | with self._lock:
81 | # Copy pointers to all values, then wipe the mapping
82 | # under Python 2, this copies the list of values twice :-|
83 | values = list(self._container.values())
84 | self._container.clear()
85 |
86 | if self.dispose_func:
87 | for value in values:
88 | self.dispose_func(value)
89 |
90 | def keys(self):
91 | with self._lock:
92 | return self._container.keys()
93 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/contrib/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/requests/packages/urllib3/contrib/__init__.py
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/exceptions.py:
--------------------------------------------------------------------------------
1 | # urllib3/exceptions.py
2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 |
8 | ## Base Exceptions
9 |
10 | class HTTPError(Exception):
11 | "Base exception used by this module."
12 | pass
13 |
14 |
15 | class PoolError(HTTPError):
16 | "Base exception for errors caused within a pool."
17 |
18 | def __init__(self, pool, message):
19 | self.pool = pool
20 | HTTPError.__init__(self, "%s: %s" % (pool, message))
21 |
22 | def __reduce__(self):
23 | # For pickling purposes.
24 | return self.__class__, (None, self.url)
25 |
26 |
27 | class SSLError(HTTPError):
28 | "Raised when SSL certificate fails in an HTTPS connection."
29 | pass
30 |
31 |
32 | class DecodeError(HTTPError):
33 | "Raised when automatic decoding based on Content-Type fails."
34 | pass
35 |
36 |
37 | ## Leaf Exceptions
38 |
39 | class MaxRetryError(PoolError):
40 | "Raised when the maximum number of retries is exceeded."
41 |
42 | def __init__(self, pool, url, reason=None):
43 | self.reason = reason
44 |
45 | message = "Max retries exceeded with url: %s" % url
46 | if reason:
47 | message += " (Caused by %s: %s)" % (type(reason), reason)
48 | else:
49 | message += " (Caused by redirect)"
50 |
51 | PoolError.__init__(self, pool, message)
52 | self.url = url
53 |
54 |
55 | class HostChangedError(PoolError):
56 | "Raised when an existing pool gets a request for a foreign host."
57 |
58 | def __init__(self, pool, url, retries=3):
59 | message = "Tried to open a foreign host with url: %s" % url
60 | PoolError.__init__(self, pool, message)
61 |
62 | self.url = url
63 | self.retries = retries
64 |
65 |
66 | class TimeoutError(PoolError):
67 | "Raised when a socket timeout occurs."
68 | pass
69 |
70 |
71 | class EmptyPoolError(PoolError):
72 | "Raised when a pool runs out of connections and no more are allowed."
73 | pass
74 |
75 |
76 | class ClosedPoolError(PoolError):
77 | "Raised when a request enters a pool after the pool has been closed."
78 | pass
79 |
80 |
81 | class LocationParseError(ValueError, HTTPError):
82 | "Raised when get_host or similar fails to parse the URL input."
83 |
84 | def __init__(self, location):
85 | message = "Failed to parse: %s" % location
86 | HTTPError.__init__(self, message)
87 |
88 | self.location = location
89 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/filepost.py:
--------------------------------------------------------------------------------
1 | # urllib3/filepost.py
2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | import codecs
8 | import mimetypes
9 |
10 | from uuid import uuid4
11 | from io import BytesIO
12 |
13 | from .packages import six
14 | from .packages.six import b
15 |
16 | writer = codecs.lookup('utf-8')[3]
17 |
18 |
19 | def choose_boundary():
20 | """
21 | Our embarassingly-simple replacement for mimetools.choose_boundary.
22 | """
23 | return uuid4().hex
24 |
25 |
26 | def get_content_type(filename):
27 | return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
28 |
29 |
30 | def iter_fields(fields):
31 | """
32 | Iterate over fields.
33 |
34 | Supports list of (k, v) tuples and dicts.
35 | """
36 | if isinstance(fields, dict):
37 | return ((k, v) for k, v in six.iteritems(fields))
38 |
39 | return ((k, v) for k, v in fields)
40 |
41 |
42 | def encode_multipart_formdata(fields, boundary=None):
43 | """
44 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
45 |
46 | :param fields:
47 | Dictionary of fields or list of (key, value) or (key, value, MIME type)
48 | field tuples. The key is treated as the field name, and the value as
49 | the body of the form-data bytes. If the value is a tuple of two
50 | elements, then the first element is treated as the filename of the
51 | form-data section and a suitable MIME type is guessed based on the
52 | filename. If the value is a tuple of three elements, then the third
53 | element is treated as an explicit MIME type of the form-data section.
54 |
55 | Field names and filenames must be unicode.
56 |
57 | :param boundary:
58 | If not specified, then a random boundary will be generated using
59 | :func:`mimetools.choose_boundary`.
60 | """
61 | body = BytesIO()
62 | if boundary is None:
63 | boundary = choose_boundary()
64 |
65 | for fieldname, value in iter_fields(fields):
66 | body.write(b('--%s\r\n' % (boundary)))
67 |
68 | if isinstance(value, tuple):
69 | if len(value) == 3:
70 | filename, data, content_type = value
71 | else:
72 | filename, data = value
73 | content_type = get_content_type(filename)
74 | writer(body).write('Content-Disposition: form-data; name="%s"; '
75 | 'filename="%s"\r\n' % (fieldname, filename))
76 | body.write(b('Content-Type: %s\r\n\r\n' %
77 | (content_type,)))
78 | else:
79 | data = value
80 | writer(body).write('Content-Disposition: form-data; name="%s"\r\n'
81 | % (fieldname))
82 | body.write(b'\r\n')
83 |
84 | if isinstance(data, int):
85 | data = str(data) # Backwards compatibility
86 |
87 | if isinstance(data, six.text_type):
88 | writer(body).write(data)
89 | else:
90 | body.write(data)
91 |
92 | body.write(b'\r\n')
93 |
94 | body.write(b('--%s--\r\n' % (boundary)))
95 |
96 | content_type = b('multipart/form-data; boundary=%s' % boundary)
97 |
98 | return body.getvalue(), content_type
99 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/packages/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 |
3 | from . import ssl_match_hostname
4 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py:
--------------------------------------------------------------------------------
1 | """The match_hostname() function from Python 3.2, essential when using SSL."""
2 |
3 | import re
4 |
5 | __version__ = '3.2.2'
6 |
7 |
8 | class CertificateError(ValueError):
9 | pass
10 |
11 |
12 | def _dnsname_to_pat(dn):
13 | pats = []
14 | for frag in dn.split(r'.'):
15 | if frag == '*':
16 | # When '*' is a fragment by itself, it matches a non-empty dotless
17 | # fragment.
18 | pats.append('[^.]+')
19 | else:
20 | # Otherwise, '*' matches any dotless fragment.
21 | frag = re.escape(frag)
22 | pats.append(frag.replace(r'\*', '[^.]*'))
23 | return re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE)
24 |
25 |
26 | def match_hostname(cert, hostname):
27 | """Verify that *cert* (in decoded format as returned by
28 | SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules
29 | are mostly followed, but IP addresses are not accepted for *hostname*.
30 |
31 | CertificateError is raised on failure. On success, the function
32 | returns nothing.
33 | """
34 | if not cert:
35 | raise ValueError("empty or no certificate")
36 | dnsnames = []
37 | san = cert.get('subjectAltName', ())
38 | for key, value in san:
39 | if key == 'DNS':
40 | if _dnsname_to_pat(value).match(hostname):
41 | return
42 | dnsnames.append(value)
43 | if not dnsnames:
44 | # The subject is only checked when there is no dNSName entry
45 | # in subjectAltName
46 | for sub in cert.get('subject', ()):
47 | for key, value in sub:
48 | # XXX according to RFC 2818, the most specific Common Name
49 | # must be used.
50 | if key == 'commonName':
51 | if _dnsname_to_pat(value).match(hostname):
52 | return
53 | dnsnames.append(value)
54 | if len(dnsnames) > 1:
55 | raise CertificateError("hostname %r "
56 | "doesn't match either of %s"
57 | % (hostname, ', '.join(map(repr, dnsnames))))
58 | elif len(dnsnames) == 1:
59 | raise CertificateError("hostname %r "
60 | "doesn't match %r"
61 | % (hostname, dnsnames[0]))
62 | else:
63 | raise CertificateError("no appropriate commonName or "
64 | "subjectAltName fields were found")
65 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/status_codes.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | from .structures import LookupDict
4 |
5 | _codes = {
6 |
7 | # Informational.
8 | 100: ('continue',),
9 | 101: ('switching_protocols',),
10 | 102: ('processing',),
11 | 103: ('checkpoint',),
12 | 122: ('uri_too_long', 'request_uri_too_long'),
13 | 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'),
14 | 201: ('created',),
15 | 202: ('accepted',),
16 | 203: ('non_authoritative_info', 'non_authoritative_information'),
17 | 204: ('no_content',),
18 | 205: ('reset_content', 'reset'),
19 | 206: ('partial_content', 'partial'),
20 | 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'),
21 | 208: ('im_used',),
22 |
23 | # Redirection.
24 | 300: ('multiple_choices',),
25 | 301: ('moved_permanently', 'moved', '\\o-'),
26 | 302: ('found',),
27 | 303: ('see_other', 'other'),
28 | 304: ('not_modified',),
29 | 305: ('use_proxy',),
30 | 306: ('switch_proxy',),
31 | 307: ('temporary_redirect', 'temporary_moved', 'temporary'),
32 | 308: ('resume_incomplete', 'resume'),
33 |
34 | # Client Error.
35 | 400: ('bad_request', 'bad'),
36 | 401: ('unauthorized',),
37 | 402: ('payment_required', 'payment'),
38 | 403: ('forbidden',),
39 | 404: ('not_found', '-o-'),
40 | 405: ('method_not_allowed', 'not_allowed'),
41 | 406: ('not_acceptable',),
42 | 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'),
43 | 408: ('request_timeout', 'timeout'),
44 | 409: ('conflict',),
45 | 410: ('gone',),
46 | 411: ('length_required',),
47 | 412: ('precondition_failed', 'precondition'),
48 | 413: ('request_entity_too_large',),
49 | 414: ('request_uri_too_large',),
50 | 415: ('unsupported_media_type', 'unsupported_media', 'media_type'),
51 | 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'),
52 | 417: ('expectation_failed',),
53 | 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'),
54 | 422: ('unprocessable_entity', 'unprocessable'),
55 | 423: ('locked',),
56 | 424: ('failed_dependency', 'dependency'),
57 | 425: ('unordered_collection', 'unordered'),
58 | 426: ('upgrade_required', 'upgrade'),
59 | 428: ('precondition_required', 'precondition'),
60 | 429: ('too_many_requests', 'too_many'),
61 | 431: ('header_fields_too_large', 'fields_too_large'),
62 | 444: ('no_response', 'none'),
63 | 449: ('retry_with', 'retry'),
64 | 450: ('blocked_by_windows_parental_controls', 'parental_controls'),
65 | 499: ('client_closed_request',),
66 |
67 | # Server Error.
68 | 500: ('internal_server_error', 'server_error', '/o\\', '✗'),
69 | 501: ('not_implemented',),
70 | 502: ('bad_gateway',),
71 | 503: ('service_unavailable', 'unavailable'),
72 | 504: ('gateway_timeout',),
73 | 505: ('http_version_not_supported', 'http_version'),
74 | 506: ('variant_also_negotiates',),
75 | 507: ('insufficient_storage',),
76 | 509: ('bandwidth_limit_exceeded', 'bandwidth'),
77 | 510: ('not_extended',),
78 | }
79 |
80 | codes = LookupDict(name='status_codes')
81 |
82 | for (code, titles) in list(_codes.items()):
83 | for title in titles:
84 | setattr(codes, title, code)
85 | if not title.startswith('\\'):
86 | setattr(codes, title.upper(), code)
87 |
--------------------------------------------------------------------------------
/NZBmegasearch/requests/structures.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.structures
5 | ~~~~~~~~~~~~~~~~~~~
6 |
7 | Data structures that power Requests.
8 |
9 | """
10 |
11 | import os
12 | from itertools import islice
13 |
14 |
15 | class IteratorProxy(object):
16 | """docstring for IteratorProxy"""
17 |
18 | def __init__(self, i):
19 | self.i = i
20 | # self.i = chain.from_iterable(i)
21 |
22 | def __iter__(self):
23 | return self.i
24 |
25 | def __len__(self):
26 | if hasattr(self.i, '__len__'):
27 | return len(self.i)
28 | if hasattr(self.i, 'len'):
29 | return self.i.len
30 | if hasattr(self.i, 'fileno'):
31 | return os.fstat(self.i.fileno()).st_size
32 |
33 | def read(self, n):
34 | return "".join(islice(self.i, None, n))
35 |
36 |
37 | class CaseInsensitiveDict(dict):
38 | """Case-insensitive Dictionary
39 |
40 | For example, ``headers['content-encoding']`` will return the
41 | value of a ``'Content-Encoding'`` response header."""
42 |
43 | @property
44 | def lower_keys(self):
45 | if not hasattr(self, '_lower_keys') or not self._lower_keys:
46 | self._lower_keys = dict((k.lower(), k) for k in list(self.keys()))
47 | return self._lower_keys
48 |
49 | def _clear_lower_keys(self):
50 | if hasattr(self, '_lower_keys'):
51 | self._lower_keys.clear()
52 |
53 | def __setitem__(self, key, value):
54 | dict.__setitem__(self, key, value)
55 | self._clear_lower_keys()
56 |
57 | def __delitem__(self, key):
58 | dict.__delitem__(self, self.lower_keys.get(key.lower(), key))
59 | self._lower_keys.clear()
60 |
61 | def __contains__(self, key):
62 | return key.lower() in self.lower_keys
63 |
64 | def __getitem__(self, key):
65 | # We allow fall-through here, so values default to None
66 | if key in self:
67 | return dict.__getitem__(self, self.lower_keys[key.lower()])
68 |
69 | def get(self, key, default=None):
70 | if key in self:
71 | return self[key]
72 | else:
73 | return default
74 |
75 |
76 | class LookupDict(dict):
77 | """Dictionary lookup object."""
78 |
79 | def __init__(self, name=None):
80 | self.name = name
81 | super(LookupDict, self).__init__()
82 |
83 | def __repr__(self):
84 | return '' % (self.name)
85 |
86 | def __getitem__(self, key):
87 | # We allow fall-through here, so values default to None
88 |
89 | return self.__dict__.get(key, None)
90 |
91 | def get(self, key, default=None):
92 | return self.__dict__.get(key, default)
93 |
--------------------------------------------------------------------------------
/NZBmegasearch/static/arrow-down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/arrow-down.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/cfg_cp_offline.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/cfg_cp_offline.jpg
--------------------------------------------------------------------------------
/NZBmegasearch/static/cfg_offline.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/cfg_offline.jpg
--------------------------------------------------------------------------------
/NZBmegasearch/static/cp_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/cp_logo.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/error.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/error_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/error_hover.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/favicon.ico
--------------------------------------------------------------------------------
/NZBmegasearch/static/imdb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/imdb.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/loadingicon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/loadingicon.gif
--------------------------------------------------------------------------------
/NZBmegasearch/static/log.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/log.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/nzb2_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/nzb2_16.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/nzb2_16_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/nzb2_16_no.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/nzb2_16_ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/nzb2_16_ok.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/off.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/ok.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/ok_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/ok_hover.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/options.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/options.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/predb_1st.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/predb_1st.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/predb_2nd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/predb_2nd.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/reset.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/
2 | v2.0 | 20110126
3 | License: none (public domain)
4 | */
5 |
6 | html, body, div, span, applet, object, iframe,
7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8 | a, abbr, acronym, address, big, cite, code,
9 | del, dfn, em, img, ins, kbd, q, s, samp,
10 | small, strike, strong, sub, sup, tt, var,
11 | b, u, i, center,
12 | dl, dt, dd, ol, ul, li,
13 | fieldset, form, label, legend,
14 | table, caption, tbody, tfoot, thead, tr, th, td,
15 | article, aside, canvas, details, embed,
16 | figure, figcaption, footer, header, hgroup,
17 | menu, nav, output, ruby, section, summary,
18 | time, mark, audio, video {
19 | margin: 0;
20 | padding: 0;
21 | border: 0;
22 | font-size: 100%;
23 | font: inherit;
24 | vertical-align: baseline;
25 | }
26 |
27 | /* HTML5 display-role reset for older browsers */
28 | article, aside, details, figcaption, figure,
29 | footer, header, hgroup, menu, nav, section {
30 | display: block;
31 | }
32 |
33 | body {
34 | line-height: 1;
35 | }
36 |
37 | ol, ul {
38 | list-style: none;
39 | }
40 |
41 | blockquote, q {
42 | quotes: none;
43 | }
44 |
45 | blockquote:before, blockquote:after,
46 | q:before, q:after {
47 | content: '';
48 | content: none;
49 | }
50 |
51 | table {
52 | border-collapse: collapse;
53 | border-spacing: 0;
54 | }
--------------------------------------------------------------------------------
/NZBmegasearch/static/restart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/restart.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/sab2_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/sab2_16.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/sab2_16_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/sab2_16_no.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/sab2_16_ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/sab2_16_ok.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/sb_cp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/sb_cp.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/show_config.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/show_config.jpg
--------------------------------------------------------------------------------
/NZBmegasearch/static/show_search.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/show_search.jpg
--------------------------------------------------------------------------------
/NZBmegasearch/static/sick_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/sick_logo.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/thetvdb16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/thetvdb16.png
--------------------------------------------------------------------------------
/NZBmegasearch/static/title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mirabis/usntssearch/a45c784287303dc9c787ad2ab0c98eeb72f98836/NZBmegasearch/static/title.png
--------------------------------------------------------------------------------
/NZBmegasearch/templates/api.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NZBMegasearch
6 | NZBMegasearch Feed
7 | https://github.com/Mirabis/usntssearch
8 | en-gb
9 | 0byte
10 |
11 |
12 | https://github.com/Mirabis/usntssearch
13 | NZBMegasearch
14 | https://github.com/pillone/usntssearch
15 | Visit https://github.com/Mirabis/usntssearch - We stand on the shoulders of giants
16 |
17 |
18 |
19 |
20 | {% for row in results -%}
21 |
22 | {{ row['title'] }}
23 | {{ row['encodedurl'] }}
24 | {{ row['url'] }}
25 | {{ row['providerurl'] }}
26 | {{ row['age'] }}
27 | {{ row['title'] }} -- NZBMegasearch: {{ row['providertitle'] }}
28 |
29 |
30 |
31 |
32 | {% if typeres == 1 -%}
33 | TV
34 |
35 | {%- endif %}
36 |
37 | {% if typeres == 0 -%}
38 | Movies
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | {%- endif %}
59 |
60 |
61 |
62 | {%- endfor %}
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/NZBmegasearch/templates/api_default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NZBMegasearch
6 | NZBMegasearch Feed
7 | https://github.com/pillone/usntssearch
8 | en-gb
9 | 0byte
10 |
11 |
12 | https://github.com/pillone/usntssearch
13 | NZBMegasearch
14 | https://github.com/pillone/usntssearch
15 | Visit https://github.com/pillone/usntssearch - We stand on the shoulders of giants
16 |
17 |
18 |
19 |
20 | World.NZB.Megasearch.Tour.S01E01
21 | http://bogusurl.bog/details/1234567890123432523523
22 | http://bogusurl.bog/getnzb/1234567890123432523523.nzb&i=470&r=438204209348230
23 | http://bogusurl.info/details/1234567890123432523523#comments
24 | Mon, 1 Jan 1970 00:00:00 +0000
25 | TV > SD
26 | World.NZB.Megasearch.Tour.S01E01-0byte
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | World.NZB.Megasearch.Tour.S01E02
36 | http://bogusurl.bog/details/1234567890123432523523
37 | http://bogusurl.bog/getnzb/1234567890123432523523.nzb&i=470&r=438204209348230
38 | http://bogusurl.info/details/1234567890123432523523#comments
39 | Mon, 1 Jan 1970 00:00:00 +0000
40 | TV > SD
41 | World.NZB.Megasearch.Tour.S01E02-0byte
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/NZBmegasearch/templates/api_error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/NZBmegasearch/templates/connectinfo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NZB MegasearcH
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Connection to SICKBEARD
15 |
16 |
17 | Sickbeard connectivity is always active.
18 | In Sickbeard: go to Config/Search Providers and add a custom Newznab provider, no API key needed (unless explicitly set in the config).
19 |
20 |
21 |
22 |
23 |
24 |
25 |
Connection to COUCHPOTATO
26 |
27 |
28 | Couchpotato connectivity is always active.
29 | In Couchpotato: go to Settings/Providers and add a custom Newznab provider with API key 123 (any key number will work unless explicitly set in the config).
30 | Below is an example of NZBMegasearcH configured with port 5000:
31 |
32 |
33 |
34 |
35 |
16 | This site does not store any NZB or XML regarding content posted on newsgroups.
17 | No usenet servers are accessed or crawled.
18 |
19 |
20 | This site consists of an automated search engine that
21 | only queries, without storing, available information present in other websites.
22 |
23 |
24 | Zero content is stored on this site. There is no database at all.
25 | Each search result is compiled on the fly. Moreover, we do not store search results.
26 | We are not responsible of the content listed on the crawled web indeces.
27 |
28 |
29 | We merely act as a data transport mechanism.
30 | We do not host any of the indexed content that you see on this site.
31 | We do not provide access to copyrighted material.
32 |
33 |
34 | Please note that all the DMCA requests have to be made to the crawled websites clearly specified
35 | in each line of result list. They host the NZB files. We do not store NZB.
36 | Send an email to XXXX@XXXX for DMCA requests, they
37 | will be dealt with accordingly and you will receive a response within 72 hours.
38 | In the vast majority of cases, we require requests to be made via postal mail.
39 | Please email the above address to find out the relevant agent address,
40 | which can change depending on your country of operation. Requests via email are
41 | possible, but will require an agreement to be made between XXXX and the
42 | copyright holder (or valid agent), in regards to what constitutes a valid notification - as well
43 | as outlining a process that makes all parties happy.
44 |
45 |
46 |
47 |
48 |