Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update guessit to 3.0.0 (+subliminal update) #4244

Merged
merged 56 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
df636da
Update guessit to v3.0.0
sharkykh May 22, 2018
09eee54
Initial update to guessit 3
medariox Mar 13, 2018
fbf463c
Mostly format => source changes and renames
sharkykh May 22, 2018
dafac41
Fix SourceStandardizer rule
sharkykh May 22, 2018
78fa87f
Remove ScreenSizeStandardizer - fixed upstream
sharkykh May 22, 2018
6408ea0
Discard custom 4320p screen_size match - fixed upstream
sharkykh May 22, 2018
e0fad24
Remove FixSeasonRangeWithGap - fixed upstream
sharkykh May 22, 2018
983b940
Remove unused `website_rebulk`
sharkykh May 22, 2018
08c86a7
'DolbyDigital' => 'Dolby Digital' => 'AC3'
sharkykh May 22, 2018
a204ddb
Fix `Quality.to_guessit_source`
sharkykh May 22, 2018
7886588
Split Rip/Mux from plain
sharkykh May 22, 2018
4dab8de
Workarounds - temporary!
sharkykh May 22, 2018
a470f3e
Merge branch 'develop' into feature/guessit-3
sharkykh May 26, 2018
a8d51b0
Merge branch 'develop' into feature/guessit-3
sharkykh May 28, 2018
68af1f5
Merge branch 'develop' into feature/guessit-3
sharkykh Jun 6, 2018
d752085
Update guessit_map and 4K => 2160p
sharkykh Jun 6, 2018
ae1cb74
Fix Quality.to_guessit_source
sharkykh Jun 6, 2018
40c2858
Update guessit conversions to support 4320p (8K)
sharkykh Jun 6, 2018
2e4a1cb
Merge branch 'develop' into feature/guessit-3
sharkykh Jun 21, 2018
25b7af8
Fix test_common.py
sharkykh Jun 21, 2018
2bc983a
Merge branch 'develop' into feature/guessit-3
sharkykh Jul 13, 2018
f226c14
Remove ignore from renovate.json
sharkykh Jul 13, 2018
48da662
Update vendored packages list
sharkykh Jul 13, 2018
42ce194
Merge branch 'develop' into feature/guessit-3
sharkykh Aug 21, 2018
cb2faba
Fix test with invalid release group and absolute numbering
medariox Aug 21, 2018
e5772b0
guessit changes that don't need fixes
medariox Aug 25, 2018
c300d74
Fix invalid episode titles between ep ranges
medariox Aug 29, 2018
1c56e54
Stop testing absurd naming
medariox Aug 29, 2018
db430d3
Update guessit result
medariox Aug 29, 2018
a108efa
Fix wrong season parsed from year
medariox Aug 29, 2018
ecc2613
Remove clean_groupname workaround
sharkykh Aug 29, 2018
ddbc156
Remove workaround note
sharkykh Aug 29, 2018
23cd910
Merge branch 'develop' into feature/guessit-3
sharkykh Aug 29, 2018
1251619
Python 2/3 compatibility
sharkykh Aug 29, 2018
14e2c14
without -> with
sharkykh Aug 29, 2018
3a1e8ad
Update tests
medariox Aug 29, 2018
a0f54e9
Use custom subliminal version that supports guessit v3
medariox Aug 29, 2018
6e83d7b
video.source -> video.source
medariox Aug 29, 2018
f29b7da
video.format -> video.source
medariox Aug 29, 2018
fbf6f9d
video.format -> video.source
medariox Aug 29, 2018
cb44942
Fix subtitles download tests
medariox Aug 30, 2018
5535ffe
Merge branch 'develop' into feature/guessit-3
medariox Aug 30, 2018
5fdf22c
format -> source
sharkykh Aug 29, 2018
6c9b037
Fix parent folder replacing episode title, add test
medariox Aug 30, 2018
5828dea
Merge branch 'develop' into feature/guessit-3
medariox Aug 30, 2018
4dbf95a
Revert subtitles download test fix (not needed anymore)
medariox Aug 30, 2018
a03e734
Improve previous fix
medariox Aug 30, 2018
88385bb
Optimized previous fix
medariox Aug 31, 2018
f21ea87
Fix audio profile messing up title. Fixes #3300
medariox Sep 1, 2018
6ccdea2
Make fix more generic to fix more invalid guesses
medariox Sep 1, 2018
c984ebb
Merge branch 'develop' into feature/guessit-3
medariox Sep 1, 2018
cafb505
Merge branch 'develop' into feature/guessit-3
sharkykh Sep 4, 2018
0ad07ce
Update ext/readme.md
sharkykh Sep 4, 2018
e54e116
Merge branch 'develop' into feature/guessit-3
medariox Sep 6, 2018
1468c54
Update CHANGELOG.md
sharkykh Sep 6, 2018
9dc6ede
Merge branch 'develop' into feature/guessit-3
medariox Sep 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Unreleased

#### New Features

#### Improvements
- Updated `guessit` to version 3.0.0 ([#4244](https://github.com/pymedusa/Medusa/pull/4244))

#### Fixes
- Fixed many release name parsing issues as a result of updating `guessit` ([#4244](https://github.com/pymedusa/Medusa/pull/4244))

-----

## 0.2.9 (2018-09-06)
Expand Down
1 change: 1 addition & 0 deletions ext/guessit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"""
from .api import guessit, GuessItApi
from .options import ConfigurationException
from .rules.common.quantity import Size

from .__version__ import __version__
8 changes: 7 additions & 1 deletion ext/guessit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
from guessit.options import argument_parser, parse_options, load_config


try:
from collections import OrderedDict
except ImportError: # pragma: no-cover
from ordereddict import OrderedDict # pylint:disable=import-error


def guess_filename(filename, options):
"""
Guess a single filename using given options
Expand All @@ -45,7 +51,7 @@ def guess_filename(filename, options):
import yaml
from guessit import yamlutils

ystr = yaml.dump({filename: dict(guess)}, Dumper=yamlutils.CustomDumper, default_flow_style=False,
ystr = yaml.dump({filename: OrderedDict(guess)}, Dumper=yamlutils.CustomDumper, default_flow_style=False,
allow_unicode=True)
i = 0
for yline in ystr.splitlines():
Expand Down
2 changes: 1 addition & 1 deletion ext/guessit/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
Version module
"""
# pragma: no cover
__version__ = '2.1.4'
__version__ = '3.0.0'
117 changes: 84 additions & 33 deletions ext/guessit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
"""
API functions that can be used by external software
"""

try:
from collections import OrderedDict
except ImportError: # pragma: no-cover
from ordereddict import OrderedDict # pylint:disable=import-error

import os
import traceback

import six

from rebulk.introspector import introspect

from .rules import rebulk_builder
from .options import parse_options
from .options import parse_options, load_config
from .__version__ import __version__


Expand All @@ -41,12 +43,25 @@ def __init__(self, string, options):
self.options = options


def configure(options, rules_builder=rebulk_builder):
"""
Load rebulk rules according to advanced configuration in options dictionary.

:param options:
:type options: dict
:param rules_builder:
:type rules_builder:
:return:
"""
default_api.configure(options, rules_builder=rules_builder, force=True)


def guessit(string, options=None):
"""
Retrieves all matches from string as a dict
:param string: the filename or release name
:type string: str
:param options: the filename or release name
:param options:
:type options: str|dict
:return:
:rtype:
Expand All @@ -58,7 +73,7 @@ def properties(options=None):
"""
Retrieves all properties with possible values that can be guessed
:param options:
:type options:
:type options: str|dict
:return:
:rtype:
"""
Expand All @@ -70,53 +85,88 @@ class GuessItApi(object):
An api class that can be configured with custom Rebulk configuration.
"""

def __init__(self, rebulk):
"""
:param rebulk: Rebulk instance to use.
:type rebulk: Rebulk
:return:
:rtype:
"""
self.rebulk = rebulk
def __init__(self):
"""Default constructor."""
self.rebulk = None

@staticmethod
def _fix_option_encoding(value):
@classmethod
def _fix_encoding(cls, value):
if isinstance(value, list):
return [GuessItApi._fix_option_encoding(item) for item in value]
return [cls._fix_encoding(item) for item in value]
if isinstance(value, dict):
return {cls._fix_encoding(k): cls._fix_encoding(v) for k, v in value.items()}
if six.PY2 and isinstance(value, six.text_type):
return value.encode("utf-8")
return value.encode('utf-8')
if six.PY3 and isinstance(value, six.binary_type):
return value.decode('ascii')
return value

def guessit(self, string, options=None):
def configure(self, options, rules_builder=rebulk_builder, force=False):
"""
Load rebulk rules according to advanced configuration in options dictionary.

:param options:
:type options: str|dict
:param rules_builder:
:type rules_builder:
:param force:
:return:
:rtype: dict
"""
options = parse_options(options, True)
should_load = force or not self.rebulk
advanced_config = options.pop('advanced_config', None)

if should_load and not advanced_config:
advanced_config = load_config(options)['advanced_config']

options = self._fix_encoding(options)

if should_load:
advanced_config = self._fix_encoding(advanced_config)
self.rebulk = rules_builder(advanced_config)

return options

def guessit(self, string, options=None): # pylint: disable=too-many-branches
"""
Retrieves all matches from string as a dict
:param string: the filename or release name
:type string: str
:param options: the filename or release name
:type string: str|Path
:param options:
:type options: str|dict
:return:
:rtype:
"""
try:
options = parse_options(options, True)
from pathlib import Path
if isinstance(string, Path):
try:
# Handle path-like object
string = os.fspath(string)
except AttributeError:
string = str(string)
except ImportError:
pass

try:
options = self.configure(options)
result_decode = False
result_encode = False

fixed_options = {}
for (key, value) in options.items():
key = GuessItApi._fix_option_encoding(key)
value = GuessItApi._fix_option_encoding(value)
fixed_options[key] = value
options = fixed_options

if six.PY2 and isinstance(string, six.text_type):
string = string.encode("utf-8")
result_decode = True
if six.PY3 and isinstance(string, six.binary_type):
string = string.decode('ascii')
result_encode = True
if six.PY2:
if isinstance(string, six.text_type):
string = string.encode("utf-8")
result_decode = True
elif isinstance(string, six.binary_type):
string = six.binary_type(string)
if six.PY3:
if isinstance(string, six.binary_type):
string = string.decode('ascii')
result_encode = True
elif isinstance(string, six.text_type):
string = six.text_type(string)

matches = self.rebulk.matches(string, options)
if result_decode:
for match in matches:
Expand All @@ -139,6 +189,7 @@ def properties(self, options=None):
:return:
:rtype:
"""
options = self.configure(options)
unordered = introspect(self.rebulk, options).properties
ordered = OrderedDict()
for k in sorted(unordered.keys(), key=six.text_type):
Expand All @@ -148,4 +199,4 @@ def properties(self, options=None):
return ordered


default_api = GuessItApi(rebulk_builder())
default_api = GuessItApi()
Loading