Skip to content

Commit

Permalink
Merge pull request #11583 from pymedusa/release/release-1.0.19
Browse files Browse the repository at this point in the history
Release/release 1.0.19
  • Loading branch information
medariox committed Dec 12, 2023
2 parents b8bec48 + d65b7c9 commit c5a1e37
Show file tree
Hide file tree
Showing 20 changed files with 239 additions and 44 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 1.0.19 (12-12-2023)

#### Improvements
- Add many network timezones (Thanks to @YogSottot)
- Add a few new logos (Thanks to @purevertigo)
- Update some Python dependencies

#### Fixes
- Add try/catch block around localStorage.setItem call (Thanks to @dotsam)
- Validate webhook URL for Slack and Discord (Thanks to @sylwia-budzynska)

-----

## 1.0.18 (29-10-2023)

#### Improvements
Expand Down
185 changes: 158 additions & 27 deletions ext/markdown2.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ext | `importlib-resources` | [5.4.0](https://pypi.org/project/importlib-resourc
ext | `jsonrpclib-pelix` | [0.4.3.2](https://pypi.org/project/jsonrpclib-pelix/0.4.3.2/) | **`medusa`** | Module: `jsonrpclib`
ext | **`knowit`** | [0.4.0](https://github.com/ratoaq2/knowit/tree/0.4.0) | **`medusa`** | -
ext | `Mako` | [1.2.4](https://pypi.org/project/Mako/1.2.4/) | **`medusa`** | Module: `mako`
ext | `markdown2` | [2.4.9](https://pypi.org/project/markdown2/2.4.9/) | **`medusa`** | File: `markdown2.py`
ext | `markdown2` | [2.4.11](https://pypi.org/project/markdown2/2.4.11/) | **`medusa`** | File: `markdown2.py`
ext | `MarkupSafe` | [1.1.1](https://pypi.org/project/MarkupSafe/1.1.1/) | `Mako` | Module: `markupsafe`
ext | **`msgpack`** | [0.5.6](https://pypi.org/project/msgpack/0.5.6/) | `CacheControl` | -
ext | **`oauthlib`** | [3.0.0](https://pypi.org/project/oauthlib/3.0.0/) | `requests-oauthlib` | -
Expand Down Expand Up @@ -65,7 +65,7 @@ ext | `trans` | [2.1.0](https://pypi.org/project/trans/2.1.0/) | `imdbpie` | Fil
ext | `ttl-cache` | [1.6](https://pypi.org/project/ttl-cache/1.6/) | **`medusa`**, `adba` | File: `ttl_cache.py`
ext | **`tvdbapiv2`** | pymedusa/[d6d0e9d](https://github.com/pymedusa/tvdbv2/tree/d6d0e9d98071c2d646beb997b336edbb0e98dfb7) | **`medusa`** | -
ext | `typing-extensions` | [4.1.1](https://pypi.org/project/typing-extensions/4.1.1/) | `importlib_metadata` | File: `typing_extensions.py`
ext | **`urllib3`** | [1.26.16](https://pypi.org/project/urllib3/1.26.16/) | `requests` | -
ext | **`urllib3`** | [1.26.18](https://pypi.org/project/urllib3/1.26.18/) | `requests` | -
ext | **`validators`** | [0.20.0](https://pypi.org/project/validators/0.20.0/) | **`medusa`** | -
ext | **`webencodings`** | [0.5.1](https://pypi.org/project/webencodings/0.5.1/) | `html5lib` | -
ext | **`wrapt`** | [1.14.1](https://pypi.org/project/wrapt/1.14.1/) | `deprecated` | -
Expand Down
18 changes: 18 additions & 0 deletions ext/urllib3/_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,24 @@ def getlist(self, key, default=__marker):
else:
return vals[1:]

def _prepare_for_method_change(self):
"""
Remove content-specific header fields before changing the request
method to GET or HEAD according to RFC 9110, Section 15.4.
"""
content_specific_headers = [
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-Type",
"Content-Length",
"Digest",
"Last-Modified",
]
for header in content_specific_headers:
self.discard(header)
return self

# Backwards compatibility for httplib
getheaders = getlist
getallmatchingheaders = getlist
Expand Down
2 changes: 1 addition & 1 deletion ext/urllib3/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This file is protected via CODEOWNERS
__version__ = "1.26.17"
__version__ = "1.26.18"
5 changes: 5 additions & 0 deletions ext/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from socket import error as SocketError
from socket import timeout as SocketTimeout

from ._collections import HTTPHeaderDict
from .connection import (
BaseSSLError,
BrokenPipeError,
Expand Down Expand Up @@ -843,7 +844,11 @@ def _is_ssl_error_message_from_http_proxy(ssl_error):
redirect_location = redirect and response.get_redirect_location()
if redirect_location:
if response.status == 303:
# Change the method according to RFC 9110, Section 15.4.4.
method = "GET"
# And lose the body not to transfer anything sensitive.
body = None
headers = HTTPHeaderDict(headers)._prepare_for_method_change()

try:
retries = retries.increment(method, url, response=response, _pool=self)
Expand Down
3 changes: 1 addition & 2 deletions ext/urllib3/contrib/securetransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@
import threading
import weakref

import six

from .. import util
from ..packages import six
from ..util.ssl_ import PROTOCOL_TLS_CLIENT
from ._securetransport.bindings import CoreFoundation, Security, SecurityConst
from ._securetransport.low_level import (
Expand Down
7 changes: 5 additions & 2 deletions ext/urllib3/poolmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import functools
import logging

from ._collections import RecentlyUsedContainer
from ._collections import HTTPHeaderDict, RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme
from .exceptions import (
LocationValueError,
Expand Down Expand Up @@ -382,9 +382,12 @@ def urlopen(self, method, url, redirect=True, **kw):
# Support relative URLs for redirecting.
redirect_location = urljoin(url, redirect_location)

# RFC 7231, Section 6.4.4
if response.status == 303:
# Change the method according to RFC 9110, Section 15.4.4.
method = "GET"
# And lose the body not to transfer anything sensitive.
kw["body"] = None
kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change()

retries = kw.get("retries")
if not isinstance(retries, Retry):
Expand Down
2 changes: 1 addition & 1 deletion medusa/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
log.logger.addHandler(logging.NullHandler())

INSTANCE_ID = text_type(uuid.uuid1())
VERSION = '1.0.18'
VERSION = '1.0.19'

USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
version=VERSION, system=platform.system(), release=platform.release(),
Expand Down
14 changes: 13 additions & 1 deletion medusa/notifiers/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import unicode_literals

import logging
import re
from builtins import object

from medusa import app
Expand Down Expand Up @@ -33,9 +34,20 @@ class Notifier(object):
https://discordapp.com
"""

WEBHOOK_PATTERN = r'https://discord\.com/api/webhooks/.*'

def is_valid_webhook(self, url):
"""Determine if a given webhook URL matches the predefined pattern."""
return re.match(self.WEBHOOK_PATTERN, url) is not None

def _send_discord_msg(self, title, msg, webhook=None, tts=None, override_avatar=None):
"""Collect the parameters and send the message to the discord webhook."""
webhook = app.DISCORD_WEBHOOK if webhook is None else webhook
if not self.is_valid_webhook(webhook):
msg = f'The webhook URL ({webhook}) you provided is not valid'
log.warning(msg)
return False, msg

tts = app.DISCORD_TTS if tts is None else tts
override_avatar = app.DISCORD_OVERRIDE_AVATAR if override_avatar is None else override_avatar

Expand Down Expand Up @@ -79,7 +91,7 @@ def _send_discord_msg(self, title, msg, webhook=None, tts=None, override_avatar=
else:
message = http_status_code.get(error.response.status_code, message)
except Exception as error:
message = 'Error while sending Discord message: {0} '.format(error)
message = 'Error while sending Discord message: {0}'.format(error)
finally:
log.info(message)
return success, message
Expand Down
12 changes: 11 additions & 1 deletion medusa/notifiers/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import json
import logging
import re
from builtins import object

from medusa import app, common
Expand All @@ -19,6 +20,8 @@
class Notifier(object):
"""Slack notifier class."""

WEBHOOK_PATTERN = r'https://hooks\.slack\.com/services/.*'

def notify_snatch(self, title, message, **kwargs):
"""
Send a notification to a Slack channel when an episode is snatched.
Expand Down Expand Up @@ -85,12 +88,19 @@ def test_notify(self, slack_webhook):
"""
return self._notify_slack('This is a test notification from Medusa', force=True, webhook=slack_webhook)

def is_valid_webhook(self, url):
"""Determine if a given webhook URL matches the predefined pattern."""
return re.match(self.WEBHOOK_PATTERN, url) is not None

def _send_slack(self, message=None, webhook=None):
"""Send the http request using the Slack webhook."""
webhook = webhook or app.SLACK_WEBHOOK
if not self.is_valid_webhook(webhook):
log.warning(f'The webhook URL ({webhook}) you provided is not valid')
return False

log.info('Sending slack message: {message}', {'message': message})
log.info('Sending slack message to url: {url}', {'url': webhook})
log.info('Sending slack message to url: {url}', {'url': webhook})

headers = {'Content-Type': 'application/json'}
data = {
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ imdbpie==5.6.5
jsonrpclib-pelix==0.4.3.2
knowit==0.4.0
Mako==1.2.4
markdown2==2.4.9
markdown2==2.4.11
profilehooks==1.12.0
PyGithub==1.45
PyJWT==2.7.0
Expand All @@ -38,5 +38,5 @@ tornado==6.1
tornroutes==0.5.1
ttl-cache==1.6
tvdbapiv2 @ https://codeload.github.com/pymedusa/tvdbv2/tar.gz/d6d0e9d98071c2d646beb997b336edbb0e98dfb7
urllib3==1.26.17
urllib3==1.26.18
validators==0.20.0
6 changes: 5 additions & 1 deletion themes-default/slim/src/store/modules/shows.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,11 @@ const actions = {

// Update (namespaced) localStorage
const namespace = rootState.config.system.webRoot ? `${rootState.config.system.webRoot}_` : '';
localStorage.setItem(`${namespace}shows`, JSON.stringify(state.shows));
try {
localStorage.setItem(`${namespace}shows`, JSON.stringify(state.shows));
} catch (error) {
console.warn(error);
}
},
updateShowQueueItem(context, queueItem) {
// Update store's search queue item. (provided through websocket)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added themes/dark/assets/img/network/prime-video.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/dark/assets/js/medusa-runtime.js.map

Large diffs are not rendered by default.

Binary file added themes/light/assets/img/network/prime-video.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/light/assets/js/medusa-runtime.js.map

Large diffs are not rendered by default.

0 comments on commit c5a1e37

Please sign in to comment.