Skip to content

Commit

Permalink
Merge pull request #10840 from pymedusa/release/release-1.0.6
Browse files Browse the repository at this point in the history
Release/release 1.0.6
  • Loading branch information
medariox authored Jul 25, 2022
2 parents cb13ff9 + e1c1c57 commit 400903a
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 62 deletions.
36 changes: 35 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
## 1.0.6 (25-07-2022)

#### Improvements
- Remove the `Download` field from the display-show table. Isn't used anymore. ([10813](https://github.com/pymedusa/Medusa/pull/10813))

#### Fixes
- Fixed borders in tables where diplay: flex is used on a table cell. ([10813](https://github.com/pymedusa/Medusa/pull/10813))
- Fix keys for caching recommended shows in recommended.dbm. ([10827](https://github.com/pymedusa/Medusa/pull/10827))
- Fix using download handler with deluge / deluged. ([10828](https://github.com/pymedusa/Medusa/pull/10828))
- History page: Fix filtering by multiple fields ([10832](https://github.com/pymedusa/Medusa/pull/10832))
- Fix error when parsing files without subs ([10837](https://github.com/pymedusa/Medusa/pull/10837))

-----

## 1.0.5 (06-07-2022)

#### Fixes
- Only auto change the status of an episode, when directly triggered through the web ui. ([10806](https://github.com/pymedusa/Medusa/pull/10806))

-----

## 1.0.4 (05-07-2022)

#### Improvements
Expand All @@ -14,7 +30,7 @@
- Homepage: Fix loading shows from localCache ([10779](https://github.com/pymedusa/Medusa/pull/10779))
- Fix Erai-raws formatted anime release guessit parsing ([10791](https://github.com/pymedusa/Medusa/pull/10791))
- Fix switching branch ([10798](https://github.com/pymedusa/Medusa/pull/10798))

-----

## 1.0.3 (10-06-2022)
Expand All @@ -28,6 +44,8 @@
- Fix NullReferenceError on testRename page when postprocessing method is symlink
- Fix a specific guessit test

-----

## 1.0.2 (31-05-2022)

#### Fixes
Expand Down Expand Up @@ -62,6 +80,8 @@
- Disable guessit cache for postprocessing ([10532](https://github.com/pymedusa/Medusa/pull/10532))
- Fix .plexmatch file misread as xml causing warnings ([10510](https://github.com/pymedusa/Medusa/pull/10510))

-----

## 0.5.29 (11-04-2022)

#### New Features
Expand All @@ -73,6 +93,8 @@
#### Fixes
- Fix joining segments in log for failed episodes ([10472](https://github.com/pymedusa/Medusa/pull/10472))

-----

## 0.5.28 (01-04-2022)

#### Improvements
Expand All @@ -82,11 +104,15 @@
- Fix Mass update page ([10447](https://github.com/pymedusa/Medusa/pull/10447))
- Fix re-load episodes when navigatin from testRename to displayShow ([10465](https://github.com/pymedusa/Medusa/pull/10465))

-----

## 0.5.27 (29-03-2022)

#### Fixes
- Fix backup / restore page ([10447](https://github.com/pymedusa/Medusa/pull/10447))

-----

## 0.5.26 (28-03-2022)

#### Improvements
Expand All @@ -96,6 +122,8 @@
#### Fixes
- Fix postprocessing loop when not using Failed Download Handling ([10435](https://github.com/pymedusa/Medusa/pull/10435))

-----

## 0.5.25 (08-03-2022)

#### New Features
Expand All @@ -114,6 +142,8 @@
- Fix provider MoreThenTv ([10391](https://github.com/pymedusa/Medusa/pull/10391))
- Fix Manage mass-update: Starting the refresh action ([10377](https://github.com/pymedusa/Medusa/pull/10377))

-----

## 0.5.24 (15-02-2022)

#### Improvements
Expand All @@ -122,6 +152,8 @@
#### Fixes
- Fix searching for season packs. ([10345](https://github.com/pymedusa/Medusa/pull/10345))

-----

## 0.5.23 (11-02-2022)

#### New Features
Expand Down Expand Up @@ -217,6 +249,8 @@
- Prevent recommended shows (imdb) to cache empty responses to the api. ([9797](https://github.com/pymedusa/Medusa/pull/9797))
- Fix download handler throwing errors connecting to NZBget. ([9801](https://github.com/pymedusa/Medusa/pull/9801))

-----

## 0.5.16 (13-08-2021)

#### New Features
Expand Down
6 changes: 4 additions & 2 deletions medusa/clients/torrent/deluge.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ def _set_torrent_label(self, result):
def _set_torrent_ratio(self, result):

ratio = result.ratio
if not ratio:
return

# blank is default client ratio, so we also shouldn't set ratio
if ratio and float(ratio) >= 0:
if float(ratio) >= 0:
if self.version >= (2, 0):
post_data = json.dumps({
'method': 'core.set_torrent_options',
Expand Down Expand Up @@ -468,7 +470,7 @@ def _set_torrent_ratio(self, result):

return not self.response.json()['error']

elif ratio and float(ratio) == -1:
elif float(ratio) == -1:
# Disable stop at ratio to seed forever
if self.version >= (2, 0):
post_data = json.dumps({
Expand Down
29 changes: 21 additions & 8 deletions medusa/clients/torrent/deluged.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ def get_status(self, info_hash):
client_status.progress = int(torrent['progress'])

# Store destination
client_status.destination = torrent['download_location']
if torrent.get('download_location'):
client_status.destination = torrent['download_location']

# Store resource
client_status.resource = torrent['name']
Expand Down Expand Up @@ -480,14 +481,26 @@ def set_torrent_ratio(self, torrent_id, ratio):
:rtype: bool
"""
try:
# blank is default client ratio, so we also shouldn't set ratio
self.connect()
if self.get_version() >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_at_ratio': True})
self.client.core.set_torrent_options(torrent_id, {'stop_ratio': ratio})
else:
self.client.core.set_torrent_stop_at_ratio(torrent_id, True)
self.client.core.set_torrent_stop_ratio(torrent_id, ratio)

version = self.get_version()
if float(ratio) >= 0:
if version >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_at_ratio': True})
else:
self.client.core.set_torrent_stop_at_ratio(torrent_id, True)

if version >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_ratio': ratio})
else:
self.client.core.set_torrent_stop_ratio(torrent_id, ratio)

elif float(ratio) == -1:
# Disable stop at ratio to seed forever
if version >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_at_ratio': False})
else:
self.client.core.set_torrent_stop_at_ratio(torrent_id, False)
except Exception:
return False
else:
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.5'
VERSION = '1.0.6'

USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
version=VERSION, system=platform.system(), release=platform.release(),
Expand Down
8 changes: 8 additions & 0 deletions medusa/helper/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class EpisodePostProcessingAbortException(ApplicationException):
"""


class EpisodePostProcessingPostponedException(ApplicationException):
"""
The episode post-processing delayed.
Meaning we abort the postprocess and not update the client status if applicable.
"""


class FailedPostProcessingFailedException(ApplicationException):
"""
The failed post-processing failed
Expand Down
30 changes: 24 additions & 6 deletions medusa/process_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from medusa.helper.exceptions import (
EpisodePostProcessingAbortException,
EpisodePostProcessingFailedException,
EpisodePostProcessingPostponedException,
FailedPostProcessingFailedException,
ex
)
Expand Down Expand Up @@ -156,11 +157,13 @@ def process_path(self):
if (
self.process_single_resource
and (process_results.failed or not process_results.succeeded)
and not process_results.postpone_processing
):
process_results.process_failed(self.path)

# In case we have an info_hash or (nzbid), update the history table with the pp results.
if self.info_hash:
# Skip the history update when the postponed (because of missing subs) flag was enabled.
if self.info_hash and not process_results.postpone_processing:
self.update_history_processed(process_results)

return process_results
Expand Down Expand Up @@ -268,8 +271,13 @@ def __init__(self, path, process_method=None, failed=False, episodes=[], process
self.failed = failed
self.resource_name = None
self.result = True
# Processing aborted. So we don't want to trigger any failed download handling.
# We do want to update the history client status.
self.aborted = False
# Processing succeeded. Trigger failed downlaod handling and update history client status.
self.succeeded = True
# Processing postponed. Stop postprocessing and don't update history client status.
self.postpone_processing = False
self.missed_files = []
self.unwanted_files = []
self.allowed_extensions = app.ALLOWED_EXTENSIONS
Expand Down Expand Up @@ -873,9 +881,11 @@ def process_media(self, path, video_files, force=False, is_priority=None, ignore
processor = post_processor.PostProcessor(file_path, self.resource_name,
self.process_method, is_priority)

if app.POSTPONE_IF_NO_SUBS:
if app.POSTPONE_IF_NO_SUBS and self.process_single_resource:
if not self._process_postponed(processor, file_path, video, ignore_subs):
continue
raise EpisodePostProcessingPostponedException(
f'Postponing processing for file path {file_path} and resource {self.resource_name}'
)

self.result = processor.process()
process_fail_message = ''
Expand All @@ -888,16 +898,24 @@ def process_media(self, path, video_files, force=False, is_priority=None, ignore
self.result = True
self.aborted = True
process_fail_message = ex(error)
except EpisodePostProcessingPostponedException as error:
processor = None
self.result = True
process_fail_message = ex(error)

if processor:
self._output += processor._output

if self.result:
if not self.aborted:
self.log_and_output('Processing succeeded for {file_path}', **{'file_path': file_path})
else:
if self.aborted:
self.log_and_output('Processing aborted for {file_path}: {process_fail_message}',
level=logging.WARNING, **{'file_path': file_path, 'process_fail_message': process_fail_message})
elif self.postpone_processing:
self.log_and_output('Processing postponed for {file_path}: {process_fail_message}',
level=logging.INFO, **{'file_path': file_path, 'process_fail_message': process_fail_message})
else:
self.log_and_output('Processing succeeded for {file_path}', **{'file_path': file_path})

else:
self.log_and_output('Processing failed for {file_path}: {process_fail_message}',
level=logging.WARNING, **{'file_path': file_path, 'process_fail_message': process_fail_message})
Expand Down
17 changes: 16 additions & 1 deletion medusa/schedulers/download_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def _check_postprocess(self, client):
ClientStatusEnum.COMPLETED.value,
ClientStatusEnum.FAILED.value,
ClientStatusEnum.SEEDED.value,
ClientStatusEnum.COMPLETED.value | ClientStatusEnum.SEEDED.value,
ClientStatusEnum.COMPLETED.value | ClientStatusEnum.PAUSED.value,
ClientStatusEnum.COMPLETED.value | ClientStatusEnum.SEEDED.value | ClientStatusEnum.PAUSED.value,
],
):
try:
Expand Down Expand Up @@ -328,7 +331,19 @@ def _check_torrent_ratio(self, client):
self.save_status_to_history(history_result, ClientStatus(status_string='SeededAction'))

def _postprocess(self, path, info_hash, resource_name, failed=False, client_type=None):
"""Queue a postprocess action."""
"""Queue a postprocess action.
:param path: Path to process
:type path: str
:param info_hash: info hash
:type info_hash: str
:param resource_name: Resource name
:type resource_name: str
:param failed: Flag to determin if this was a failed download
:type failed: bool
:param client_type: Client type ('nzb', 'torrent')
:type client_type: str
"""
# Use the info hash get a segment of episodes.
history_items = self.main_db_con.select(
'SELECT * FROM history WHERE info_hash = ?',
Expand Down
29 changes: 22 additions & 7 deletions medusa/server/api/v2/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
from __future__ import unicode_literals

import json
import logging
from os.path import basename

from medusa import db
from medusa.common import DOWNLOADED, FAILED, SNATCHED, SUBTITLED, statusStrings
from medusa.indexers.utils import indexer_id_to_name
from medusa.logger.adapters.style import BraceAdapter
from medusa.providers import get_provider_class
from medusa.providers.generic_provider import GenericProvider
from medusa.schedulers.download_handler import ClientStatus
from medusa.server.api.v2.base import BaseRequestHandler
from medusa.tv.series import Series, SeriesIdentifier


log = BraceAdapter(logging.getLogger(__name__))
log.logger.addHandler(logging.NullHandler())


class HistoryHandler(BaseRequestHandler):
"""History request handler."""

Expand Down Expand Up @@ -60,6 +66,7 @@ def get(self, series_slug, path_param):
return self._ok(data=results[0])

where = []
where_with_ops = []

if series_slug is not None:
series_identifier = SeriesIdentifier.from_slug(series_slug)
Expand Down Expand Up @@ -102,24 +109,32 @@ def get(self, series_slug, path_param):
where += [filter_field]
params += [filter_value]

if where:
sql_base += ' WHERE ' + ' AND '.join(f'{item} = ?' for item in where)

# Add size query (with operator)
if size_operator and size:
sql_base += f' {"AND" if where else "WHERE"} size {size_operator} ?'
params.append(int(size) * 1024 * 1024)
try:
size = int(size) * 1024 * 1024
where_with_ops += [f' size {size_operator} ? ']
params.append(size)
except ValueError:
log.info('Could not parse {size} into a valid number', {'size': size})

# Add provider with like %provider%
if provider:
sql_base += f' {"AND" if where else "WHERE"} provider LIKE ?'
where_with_ops += [' provider LIKE ? ']
params.append(f'%%{provider}%%')

# Search resource with like %resource%
if resource:
sql_base += f' {"AND" if where else "WHERE"} resource LIKE ?'
where_with_ops += [' resource LIKE ? ']
params.append(f'%%{resource}%%')

if where:
sql_base += ' WHERE ' + ' AND '.join(f'{item} = ?' for item in where)

if where_with_ops:
sql_base += ' WHERE ' if not where else ' AND '
sql_base += ' AND '.join(where_with_ops)

if sort is not None and len(sort) == 1: # Only support one sort column right now.
field = sort[0].get('field').lower()
order = sort[0].get('type')
Expand Down
Loading

0 comments on commit 400903a

Please sign in to comment.