Skip to content

Commit

Permalink
Merge pull request #6386 from pymedusa/release/release-0.3.1
Browse files Browse the repository at this point in the history
Release/release 0.3.1
  • Loading branch information
medariox authored Mar 20, 2019
2 parents 94fae84 + 4411832 commit 721c3f8
Show file tree
Hide file tree
Showing 46 changed files with 932 additions and 458 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
install:
- pip install --upgrade pip
- pip install dredd_hooks
- pip install 'PyYAML<4'
- pip install 'PyYAML>=5.1'
- pip install six
- nvm install v10.7.0
- 'curl -o- -L https://yarnpkg.com/install.sh | bash'
Expand All @@ -73,7 +73,7 @@ jobs:
install:
- pip install --upgrade pip
- pip install dredd_hooks
- pip install 'PyYAML<4'
- pip install 'PyYAML>=5.1'
- pip install six
- nvm install v10.7.0
- 'curl -o- -L https://yarnpkg.com/install.sh | bash'
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.3.1 (2019-03-20)

#### Fixes
- Fixed auto update causing DB issues ([#6356](https://github.com/pymedusa/Medusa/pull/6356))
- Fixed sending Kodi notifications (Python 3) ([#6355](https://github.com/pymedusa/Medusa/pull/6355))
- Fixed sending Slack notifications (Python 3) ([#6355](https://github.com/pymedusa/Medusa/pull/6355))
- Fixed possible error while getting AniDB scene exceptions (Python 3) ([#6355](https://github.com/pymedusa/Medusa/pull/6355))

-----

## 0.3.0 (2019-03-13)

#### New Features
Expand Down
17 changes: 10 additions & 7 deletions ext/cfscrape/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import copy
import logging
import random
import re
from copy import deepcopy
from time import sleep
import time

import js2py

Expand All @@ -16,7 +16,7 @@
# Disallow parsing of the unsafe 'pyimport' statement in Js2Py.
js2py.disable_pyimport()

__version__ = "1.9.5-Custom"
__version__ = "1.9.6-Custom"

DEFAULT_USER_AGENTS = [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
Expand Down Expand Up @@ -73,14 +73,14 @@ def request(self, method, url, *args, **kwargs):
return resp

def solve_cf_challenge(self, resp, **original_kwargs):
sleep(self.delay) # Cloudflare requires a delay before solving the challenge
start_time = time.time()

body = resp.text
parsed_url = urlparse(resp.url)
domain = parsed_url.netloc
submit_url = "%s://%s/cdn-cgi/l/chk_jschl" % (parsed_url.scheme, domain)

cloudflare_kwargs = deepcopy(original_kwargs)
cloudflare_kwargs = copy.deepcopy(original_kwargs)
params = cloudflare_kwargs.setdefault("params", {})
headers = cloudflare_kwargs.setdefault("headers", {})
headers["Referer"] = resp.url
Expand All @@ -91,7 +91,6 @@ def solve_cf_challenge(self, resp, **original_kwargs):

# Extract the arithmetic operation
js = self.extract_js(body, domain)

except Exception as e:
# Something is wrong with the page.
# This may indicate Cloudflare has changed their anti-bot
Expand All @@ -107,6 +106,10 @@ def solve_cf_challenge(self, resp, **original_kwargs):
# performing other types of requests even as the first request.
method = resp.request.method
cloudflare_kwargs["allow_redirects"] = False

end_time = time.time()
time.sleep(self.delay - (end_time - start_time)) # Cloudflare requires a delay before solving the challenge

redirect = self.request(method, submit_url, **cloudflare_kwargs)

redirect_location = urlparse(redirect.headers["Location"])
Expand All @@ -118,7 +121,7 @@ def solve_cf_challenge(self, resp, **original_kwargs):
def extract_js(self, body, domain):
js = re.search(r"setTimeout\(function\(\){\s+(var "
"s,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n", body).group(1)
js = re.sub(r"a\.value = (.+ \+ t\.length).+", r"\1", js)
js = re.sub(r"a\.value = (.+ \+ t\.length(\).toFixed\(10\))?).+", r"\1", js)
js = re.sub(r"\s{3,}[a-z](?: = |\.).+", "", js).replace("t.length", str(len(domain)))

# Strip characters that could be used to exit the string context
Expand Down
4 changes: 2 additions & 2 deletions ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:: | `CacheControl` | [0.12.5](https://pypi.org/project/CacheControl/0.12.5/) | **`medusa`** | ext | Module: `cachecontrol`
:: | `certifi` | [2019.3.9](https://pypi.org/project/certifi/2019.3.9/) | **`medusa`**, `traktor`, `requests` | ext | -
:: | `chardet` | [3.0.4](https://pypi.org/project/chardet/3.0.4/) | **`medusa`**, `beautifulsoup4`, `feedparser`, `html5lib`, `pysrt`, `requests`, `subliminal` | ext | -
:: | `cloudflare-scrape` | pymedusa/[320456e](https://github.com/pymedusa/cloudflare-scrape/tree/320456e8b28cedb807363a7a892b1379db843f66) | **`medusa`** | ext | Module: `cfscrape`
:: | `cloudflare-scrape` | pymedusa/[2a5af1d](https://github.com/pymedusa/cloudflare-scrape/tree/2a5af1d4928b70f0cf1640564d618be51cf22332) | **`medusa`** | ext | Module: `cfscrape`
:: | <code><b>configobj</b>.py</code><br>`validate.py`<br>`_version.py` | [5.0.6](https://pypi.org/project/configobj/5.0.6/) | **`medusa`** | ext | -
:: | <code><b>configparser</b>.py</code><br>`backports.configparser` | [3.7.3](https://pypi.org/project/configparser/3.7.3/) | `adba` | **ext2** | -
:: | <code><b>contextlib2</b>.py</code> | [0.5.5](https://pypi.org/project/contextlib2/0.5.5/) | **`medusa`**, `tvdbapiv2` | ext | Markers: `python_version < '3.5'`
Expand Down Expand Up @@ -69,7 +69,7 @@
:: | `validators` | [0.12.4](https://pypi.org/project/validators/0.12.4/) | **`medusa`** | ext | -
:: | `webencodings` | [0.5.1](https://pypi.org/project/webencodings/0.5.1/) | `html5lib` | ext | -
:: | `wrapt` | [1.10.11](https://pypi.org/project/wrapt/1.10.11/) | `deprecated` | ext | -
:: | `PyYAML` | [3.13](https://pypi.org/project/PyYAML/3.13/) | `knowit` | **ext2 ext3** | Module: `yaml`
:: | `PyYAML` | [5.1](https://pypi.org/project/PyYAML/5.1/) | `knowit` | **ext2 ext3** | Module: `yaml`

Notes:
- `ext` compatible with python2 and python3
Expand Down
107 changes: 99 additions & 8 deletions ext2/yaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,53 @@
from loader import *
from dumper import *

__version__ = '3.13'
__version__ = '5.1'

try:
from cyaml import *
__with_libyaml__ = True
except ImportError:
__with_libyaml__ = False


#------------------------------------------------------------------------------
# Warnings control
#------------------------------------------------------------------------------

# 'Global' warnings state:
_warnings_enabled = {
'YAMLLoadWarning': True,
}

# Get or set global warnings' state
def warnings(settings=None):
if settings is None:
return _warnings_enabled

if type(settings) is dict:
for key in settings:
if key in _warnings_enabled:
_warnings_enabled[key] = settings[key]

# Warn when load() is called without Loader=...
class YAMLLoadWarning(RuntimeWarning):
pass

def load_warning(method):
if _warnings_enabled['YAMLLoadWarning'] is False:
return

import warnings

message = (
"calling yaml.%s() without Loader=... is deprecated, as the "
"default Loader is unsafe. Please read "
"https://msg.pyyaml.org/load for full details."
) % method

warnings.warn(message, YAMLLoadWarning, stacklevel=3)

#------------------------------------------------------------------------------
def scan(stream, Loader=Loader):
"""
Scan a YAML stream and produce scanning tokens.
Expand Down Expand Up @@ -61,45 +100,97 @@ def compose_all(stream, Loader=Loader):
finally:
loader.dispose()

def load(stream, Loader=Loader):
def load(stream, Loader=None):
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
"""
if Loader is None:
load_warning('load')
Loader = FullLoader

loader = Loader(stream)
try:
return loader.get_single_data()
finally:
loader.dispose()

def load_all(stream, Loader=Loader):
def load_all(stream, Loader=None):
"""
Parse all YAML documents in a stream
and produce corresponding Python objects.
"""
if Loader is None:
load_warning('load_all')
Loader = FullLoader

loader = Loader(stream)
try:
while loader.check_data():
yield loader.get_data()
finally:
loader.dispose()

def full_load(stream):
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
Resolve all tags except those known to be
unsafe on untrusted input.
"""
return load(stream, FullLoader)

def full_load_all(stream):
"""
Parse all YAML documents in a stream
and produce corresponding Python objects.
Resolve all tags except those known to be
unsafe on untrusted input.
"""
return load_all(stream, FullLoader)

def safe_load(stream):
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
Resolve only basic YAML tags.
Resolve only basic YAML tags. This is known
to be safe for untrusted input.
"""
return load(stream, SafeLoader)

def safe_load_all(stream):
"""
Parse all YAML documents in a stream
and produce corresponding Python objects.
Resolve only basic YAML tags.
Resolve only basic YAML tags. This is known
to be safe for untrusted input.
"""
return load_all(stream, SafeLoader)

def unsafe_load(stream):
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
Resolve all tags, even those known to be
unsafe on untrusted input.
"""
return load(stream, UnsafeLoader)

def unsafe_load_all(stream):
"""
Parse all YAML documents in a stream
and produce corresponding Python objects.
Resolve all tags, even those known to be
unsafe on untrusted input.
"""
return load_all(stream, UnsafeLoader)

def emit(events, stream=None, Dumper=Dumper,
canonical=None, indent=None, width=None,
allow_unicode=None, line_break=None):
Expand Down Expand Up @@ -161,11 +252,11 @@ def serialize(node, stream=None, Dumper=Dumper, **kwds):
return serialize_all([node], stream, Dumper=Dumper, **kwds)

def dump_all(documents, stream=None, Dumper=Dumper,
default_style=None, default_flow_style=None,
default_style=None, default_flow_style=False,
canonical=None, indent=None, width=None,
allow_unicode=None, line_break=None,
encoding='utf-8', explicit_start=None, explicit_end=None,
version=None, tags=None):
version=None, tags=None, sort_keys=True):
"""
Serialize a sequence of Python objects into a YAML stream.
If stream is None, return the produced string instead.
Expand All @@ -183,7 +274,7 @@ def dump_all(documents, stream=None, Dumper=Dumper,
canonical=canonical, indent=indent, width=width,
allow_unicode=allow_unicode, line_break=line_break,
encoding=encoding, version=version, tags=tags,
explicit_start=explicit_start, explicit_end=explicit_end)
explicit_start=explicit_start, explicit_end=explicit_end, sort_keys=sort_keys)
try:
dumper.open()
for data in documents:
Expand Down
4 changes: 2 additions & 2 deletions ext2/yaml/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def compose_node(self, parent, index):
anchor = event.anchor
if anchor is not None:
if anchor in self.anchors:
raise ComposerError("found duplicate anchor %r; first occurence"
raise ComposerError("found duplicate anchor %r; first occurrence"
% anchor.encode('utf-8'), self.anchors[anchor].start_mark,
"second occurence", event.start_mark)
"second occurrence", event.start_mark)
self.descend_resolver(parent, index)
if self.check_event(ScalarEvent):
node = self.compose_scalar_node(anchor)
Expand Down
Loading

0 comments on commit 721c3f8

Please sign in to comment.