Skip to content

Commit

Permalink
Merge pull request #11888 from pymedusa/release/release-1.0.22
Browse files Browse the repository at this point in the history
Release/release 1.0.22
  • Loading branch information
medariox authored Dec 13, 2024
2 parents 34a67cf + 0a24b7c commit d996387
Show file tree
Hide file tree
Showing 45 changed files with 483 additions and 144 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/node-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ jobs:
working-directory: ./themes-default/slim
run: yarn test
- name: Upload coverage to Codecov
working-directory: ./themes-default/slim
run: yarn coverage
uses: codecov/codecov-action@v5
10 changes: 5 additions & 5 deletions .github/workflows/python-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
pip install -r test_requirements.txt
- name: Test with tox
run: tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v5
2 changes: 1 addition & 1 deletion .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
python-version: [3.12]

steps:
- uses: actions/checkout@v2
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 1.0.22 (13-12-2024)

#### New Features
- UI component add anime white / blacklist (Thanks to @p0psicles)
- Add support for Python 3.12 and remove support for Python 3.7

#### Improvements
- Don't replace allowed quality unless it's preferred quality (Thanks to @fredhen)
- Calendar route should write appropriate header (Thanks to @pidario)
- Update Theoldschool torrent provider (Thanks to @IamMika23)
- Update YGG torrent provider (Thanks to @StudioEtrange)
- Increase EZTV torrent provider search results (Thanks to @fawkescapacitor)

#### Fixes
- Fix error added by Qbittorrent 5.0 (Thanks to @borntohonk)
- Fix CDN errors when updating scene exceptions

-----

## 1.0.21 (03-04-2024)

#### Improvements
Expand Down
16 changes: 8 additions & 8 deletions ext/boto/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@
# This is probably running on App Engine.
expanduser = (lambda x: x)

from boto.vendored import six
import six

from boto.vendored.six import BytesIO, StringIO
from boto.vendored.six.moves import filter, http_client, map, _thread, \
urllib, zip
from boto.vendored.six.moves.queue import Queue
from boto.vendored.six.moves.urllib.parse import parse_qs, quote, unquote, \
from six import BytesIO, StringIO
from six.moves import filter, http_client, map, _thread, urllib, zip
from six.moves.queue import Queue
from six.moves.urllib.parse import parse_qs, quote, unquote, \
urlparse, urlsplit
from boto.vendored.six.moves.urllib.parse import unquote_plus
from boto.vendored.six.moves.urllib.request import urlopen
from six.moves.urllib.parse import unquote_plus
from six.moves.urllib.request import urlopen


if six.PY3:
# StandardError was removed, so use the base exception type instead
Expand Down
23 changes: 14 additions & 9 deletions ext/boto/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MyFancyAuth(AuthPlugin):
"""

import glob
import imp
import importlib.util
import os.path


Expand Down Expand Up @@ -66,16 +66,21 @@ def get_plugin(cls, requested_capability=None):
return result


def _load_module_with_importlib(name, path):
spec = importlib.util.find_spec(name, path)
if spec:
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
else:
raise ImportError(f"Module {name} not found in path {path}")


def _import_module(filename):
(path, name) = os.path.split(filename)
(name, ext) = os.path.splitext(name)

(file, filename, data) = imp.find_module(name, [path])
try:
return imp.load_module(name, file, filename, data)
finally:
if file:
file.close()
(name, _) = os.path.splitext(name)

return _load_module_with_importlib(name, [path])

_plugin_loaded = False

Expand Down
8 changes: 4 additions & 4 deletions ext/imdbpie/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import diskcache
from dateutil.tz import tzutc
from dateutil.parser import parse
import boto.utils
from six import ensure_text
from six.moves.urllib.parse import urlparse, parse_qs, quote
from boto import provider
from boto.provider import Provider
from boto.connection import HTTPRequest
from boto.auth import HmacAuthV3HTTPHandler

Expand All @@ -42,7 +42,7 @@ def canonical_query_string(self, http_request):
return ''
qs_parts = []
for param in sorted(http_request.params):
value = boto.utils.get_utf8_value(http_request.params[param])
value = ensure_text(http_request.params[param])
param_ = quote(param, safe='-_.~')
value_ = quote(value, safe='-_.~')
qs_parts.append('{0}={1}'.format(param_, value_))
Expand Down Expand Up @@ -118,7 +118,7 @@ def get_auth_headers(self, url_path):
handler = ZuluHmacAuthV3HTTPHandler(
host=HOST,
config={},
provider=provider.Provider(
provider=Provider(
name='aws',
access_key=creds['accessKeyId'],
secret_key=creds['secretAccessKey'],
Expand Down
8 changes: 4 additions & 4 deletions lib/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
except ImportError:
importlib_machinery = None

from pkg_resources.extern import appdirs
import appdirs
from pkg_resources.extern import packaging
__import__('pkg_resources.extern.packaging.version')
__import__('pkg_resources.extern.packaging.specifiers')
Expand Down Expand Up @@ -2169,7 +2169,7 @@ def resolve_egg_link(path):
return next(dist_groups, ())


register_finder(pkgutil.ImpImporter, find_on_path)
register_finder(pkgutil.zipimporter, find_on_path)

if hasattr(importlib_machinery, 'FileFinder'):
register_finder(importlib_machinery.FileFinder, find_on_path)
Expand Down Expand Up @@ -2210,7 +2210,7 @@ def _handle_ns(packageName, path_item):
# capture warnings due to #1111
with warnings.catch_warnings():
warnings.simplefilter("ignore")
loader = importer.find_module(packageName)
loader = importer.find_spec(packageName)

if loader is None:
return None
Expand Down Expand Up @@ -2324,7 +2324,7 @@ def file_ns_handler(importer, path_item, packageName, module):
return subpath


register_namespace_handler(pkgutil.ImpImporter, file_ns_handler)
register_namespace_handler(pkgutil.zipimporter, file_ns_handler)
register_namespace_handler(zipimport.zipimporter, file_ns_handler)

if hasattr(importlib_machinery, 'FileFinder'):
Expand Down
2 changes: 2 additions & 0 deletions medusa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ def initialize(self, console_logging=True):
app.TORRENT_PATH = check_setting_str(app.CFG, 'TORRENT', 'torrent_path', '')
app.TORRENT_SEED_TIME = check_setting_int(app.CFG, 'TORRENT', 'torrent_seed_time', 0)
app.TORRENT_PAUSED = bool(check_setting_int(app.CFG, 'TORRENT', 'torrent_paused', 0))
app.TORRENT_STOPPED = bool(check_setting_int(app.CFG, 'TORRENT', 'torrent_stopped', 0))
app.TORRENT_HIGH_BANDWIDTH = bool(check_setting_int(app.CFG, 'TORRENT', 'torrent_high_bandwidth', 0))
app.TORRENT_LABEL = check_setting_str(app.CFG, 'TORRENT', 'torrent_label', '')
app.TORRENT_LABEL_ANIME = check_setting_str(app.CFG, 'TORRENT', 'torrent_label_anime', '')
Expand Down Expand Up @@ -1854,6 +1855,7 @@ def save_config():
new_config['TORRENT']['torrent_path'] = app.TORRENT_PATH
new_config['TORRENT']['torrent_seed_time'] = int(app.TORRENT_SEED_TIME)
new_config['TORRENT']['torrent_paused'] = int(app.TORRENT_PAUSED)
new_config['TORRENT']['torrent_stopped'] = int(app.TORRENT_STOPPED)
new_config['TORRENT']['torrent_high_bandwidth'] = int(app.TORRENT_HIGH_BANDWIDTH)
new_config['TORRENT']['torrent_label'] = app.TORRENT_LABEL
new_config['TORRENT']['torrent_label_anime'] = app.TORRENT_LABEL_ANIME
Expand Down
6 changes: 4 additions & 2 deletions medusa/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def __init__(self):
self.CONFIG_INI = 'config.ini'
self.GIT_ORG = 'pymedusa'
self.GIT_REPO = 'Medusa'
self.BASE_PYMEDUSA_URL = 'https://cdn.pymedusa.com'
self.CHANGES_URL = '{base_url}/news/CHANGELOG.md'.format(base_url=self.BASE_PYMEDUSA_URL)
self.BASE_MEDUSA_URL = 'https://raw.githubusercontent.com/pymedusa/Medusa/refs/heads/master'
self.BASE_PYMEDUSA_URL = 'https://raw.githubusercontent.com/pymedusa/medusa.github.io/refs/heads/master'
self.CHANGES_URL = '{base_url}/CHANGELOG.md'.format(base_url=self.BASE_MEDUSA_URL)
self.APPLICATION_URL = 'https://github.com/{org}/{repo}'.format(org=self.GIT_ORG, repo=self.GIT_REPO)
self.DONATIONS_URL = '{0}/wiki/Donations'.format(self.APPLICATION_URL)
self.WIKI_URL = '{0}/wiki'.format(self.APPLICATION_URL)
Expand Down Expand Up @@ -372,6 +373,7 @@ def __init__(self):
self.TORRENT_PATH = ''
self.TORRENT_SEED_TIME = None
self.TORRENT_PAUSED = False
self.TORRENT_STOPPED = False
self.TORRENT_HIGH_BANDWIDTH = False
self.TORRENT_LABEL = ''
self.TORRENT_LABEL_ANIME = ''
Expand Down
16 changes: 14 additions & 2 deletions medusa/clients/torrent/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ def _set_torrent_pause(self, result):
"""
return True

def _set_torrent_stop(self, result):
"""Return the True/False from the client when a torrent is set with stop.
:param result:
:type result: medusa.classes.SearchResult
:return:
:rtype: bool
"""
return True

@staticmethod
def _get_info_hash(result):
if result.url.startswith('magnet:'):
Expand Down Expand Up @@ -238,8 +248,10 @@ def send_torrent(self, result):
log.warning('{name}: Unable to send Torrent', {'name': self.name})
return False

if not self._set_torrent_pause(result):
log.error('{name}: Unable to set the pause for Torrent', {'name': self.name})
if self._set_torrent_pause(result) or self._set_torrent_stop(result):
log.info('{name}: Able to set the pause/stop for Torrent', {'name': self.name})
else:
log.error('{name}: Unable to set the pause/stop for Torrent', {'name': self.name})

if not self._set_torrent_label(result):
log.error('{name}: Unable to set the label for Torrent', {'name': self.name})
Expand Down
18 changes: 17 additions & 1 deletion medusa/clients/torrent/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ def _set_torrent_priority(self, result):
def _set_torrent_pause(self, result):
return self.pause_torrent(result.hash, state='pause' if app.TORRENT_PAUSED else 'resume')

def _set_torrent_stop(self, result):
return self.stop_torrent(result.hash, state='stop' if app.TORRENT_STOPPED else 'start')

def pause_torrent(self, info_hash, state='pause'):
"""Pause torrent."""
command = 'api/v2/torrents' if self.api >= (2, 0, 0) else 'command'
Expand All @@ -249,6 +252,16 @@ def pause_torrent(self, info_hash, state='pause'):
}
return self._request(method='post', data=data, cookies=self.session.cookies)

def stop_torrent(self, info_hash, state='stop'):
"""Stop torrent."""
command = 'api/v2/torrents' if self.api >= (2, 0, 0) else 'command'
hashes_key = 'hashes' if self.api >= (1, 18, 0) else 'hash'
self.url = urljoin(self.host, '{command}/{state}'.format(command=command, state=state))
data = {
hashes_key: info_hash.lower()
}
return self._request(method='post', data=data, cookies=self.session.cookies)

def _remove(self, info_hash, from_disk=False):
"""Remove torrent from client using given info_hash.
Expand Down Expand Up @@ -398,10 +411,13 @@ def get_status(self, info_hash):
if torrent['state'] in ('pausedDL', 'stalledDL'):
client_status.set_status_string('Paused')

if torrent['state'] in ('stoppdDL'):
client_status.set_status_string('Stopped')

if torrent['state'] == 'error':
client_status.set_status_string('Failed')

if torrent['state'] in ('uploading', 'queuedUP', 'checkingUP', 'forcedUP', 'stalledUP', 'pausedUP'):
if torrent['state'] in ('uploading', 'queuedUP', 'checkingUP', 'forcedUP', 'stalledUP', 'pausedUP', 'stoppedUP'):
client_status.set_status_string('Completed')

# if torrent['ratio'] >= torrent['max_ratio']:
Expand Down
7 changes: 2 additions & 5 deletions 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.21'
VERSION = '1.0.22'

USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
version=VERSION, system=platform.system(), release=platform.release(),
Expand Down Expand Up @@ -615,10 +615,7 @@ def should_replace(ep_status, old_quality, new_quality, allowed_qualities, prefe
if new_quality in preferred_qualities:
return True, 'New quality is preferred. Accepting new quality'

if new_quality > old_quality:
return True, 'New quality is higher quality (and allowed). Accepting new quality'
else:
return False, 'New quality is same/lower quality (and not preferred). Ignoring new quality'
return False, 'Existing quality is allowed and new quality is not a preferred quality. Ignoring new quality'

else:
# Allowed quality should never be replaced
Expand Down
2 changes: 1 addition & 1 deletion medusa/notifiers/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _sendjoin(self, title, message, join_api=None, join_device=None, force=False

join_api = join_api or app.JOIN_API
join_device = join_device or app.JOIN_DEVICE
icon_url = 'https://cdn.pymedusa.com/images/ico/favicon-310.png'
icon_url = '{base_url}/images/ico/favicon-310.png'.format(base_url=app.BASE_PYMEDUSA_URL)

params = {'title': title, 'text': message, 'deviceId': join_device, 'apikey': join_api, 'icon': icon_url}

Expand Down
2 changes: 1 addition & 1 deletion medusa/notifiers/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _send_slack(self, message=None, webhook=None):
data = {
'text': message,
'username': 'MedusaBot',
'icon_url': 'https://cdn.pymedusa.com/images/ico/favicon-310.png'
'icon_url': '{base_url}/images/ico/favicon-310.png'.format(base_url=app.BASE_PYMEDUSA_URL)
}

try:
Expand Down
21 changes: 19 additions & 2 deletions medusa/process_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,23 @@ def __init__(self, path, process_method=None, failed=False, episodes=[], process
self.episodes = episodes
self.process_single_resource = process_single_resource

def _is_tv_download_dir(self, path):
"""Check if the path exists, combine with the tv_download_dir path if available."""
if not app.TV_DOWNLOAD_DIR:
self.log_and_output('tv_download_dir not set, not using it', level=logging.DEBUG)
return False

if not os.path.isdir(app.TV_DOWNLOAD_DIR):
self.log_and_output('tv_download_dir set, but cant resove to a local directory', level=logging.DEBUG)
return False

if not helpers.real_path(path) != helpers.real_path(app.TV_DOWNLOAD_DIR):
self.log_and_output('real path didnt match for the path: [] but cant resove to a local directory',
level=logging.DEBUG, **{'path': helpers.real_path(path), 'tv_download_dir': helpers.real_path(app.TV_DOWNLOAD_DIR)})
return False

return True

@property
def directory(self):
"""Return the root directory we are going to process."""
Expand All @@ -305,13 +322,13 @@ def directory(self, path):

# If the client and the application are not on the same machine,
# translate the directory into a network directory
elif all([app.TV_DOWNLOAD_DIR, os.path.isdir(app.TV_DOWNLOAD_DIR),
helpers.real_path(path) == helpers.real_path(app.TV_DOWNLOAD_DIR)]):
elif self._is_tv_download_dir(path):
directory = os.path.join(
app.TV_DOWNLOAD_DIR,
os.path.abspath(path).split(os.path.sep)[-1]
)
self.log_and_output('Trying to use folder: {directory}', level=logging.DEBUG, **{'directory': directory})

else:
self.log_and_output(
'Unable to figure out what folder to process.'
Expand Down
Loading

0 comments on commit d996387

Please sign in to comment.