Skip to content

Commit

Permalink
Merge 12218c0 into e203912
Browse files Browse the repository at this point in the history
  • Loading branch information
h3llrais3r committed Jan 25, 2019
2 parents e203912 + 12218c0 commit 27f8361
Show file tree
Hide file tree
Showing 66 changed files with 3,049 additions and 937 deletions.
25 changes: 20 additions & 5 deletions autosubliminal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ def initialize():
# Cache settings
_init_cache(python_version_changed)

# Guessit settings
_init_guessit()

# Subliminal settings
SUBLIMINALPROVIDERMANAGER = _init_subliminal(python_version_changed)
SUBLIMINALPROVIDERCONFIGS = {}
Expand Down Expand Up @@ -330,9 +333,7 @@ def _check_python_version_change():


def _init_cache(replace):
"""
Initialize internal cache.
"""
"""Initialize internal cache."""

# Imports
from autosubliminal.core.cache import MutexFileLock, clear_mako_cache, region
Expand All @@ -354,9 +355,23 @@ def _init_cache(replace):
replace_existing_backend=replace)


def _init_subliminal(replace):
def _init_guessit():
"""Initialize guessit.
Make sure that guessit.guessit(...) always uses our custom version.
"""
Initialize subliminal.

# Imports
import guessit
from autosubliminal.parsers import guessit as custom_guessit

# Use our custom guessit parser by default
guessit.guessit = custom_guessit


def _init_subliminal(replace):
"""Initialize subliminal.
This must always be done AFTER the registration of our fake_entry_points.
Therefore the imports must be done here, otherwise the 'subliminal.providers' entry point is already initialized
before we could register it ourselves.
Expand Down
10 changes: 5 additions & 5 deletions autosubliminal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ def _upgrade_config(from_version, to_version):
# video.scores['season'] = 6
# video.scores['year'] = 24
# --> these 4 should always be matched by default -> not visible in GUI -> showminmatchscore = 60
# video.scores['format'] = 3
# video.scores['source'] = 3
# video.scores['resolution'] = 2
# video.scores['release_group'] = 6
# video.scores['video_codec'] = 2
Expand Down Expand Up @@ -1532,7 +1532,7 @@ def _upgrade_config(from_version, to_version):
# video.scores['episode'] = 11
# --> these 4 should always be matched by default -> not visible in GUI -> showminmatchscore = 110
# video.scores['release_group'] = 11
# video.scores['format'] = 6
# video.scores['source'] = 6
# video.scores['resolution'] = 4
# video.scores['video_codec'] = 4
# --> these 4 are configurable -> max showminmatchscore = 110 + 11 + 6 + 4 + 4 = 135
Expand All @@ -1545,7 +1545,7 @@ def _upgrade_config(from_version, to_version):
# video.scores['year'] = 12
# --> these 2 should always be matched by default -> not visible in GUI -> showminmatchscore = 35
# video.scores['release_group'] = 11
# video.scores['format'] = 6
# video.scores['source'] = 6
# video.scores['resolution'] = 4
# video.scores['video_codec'] = 4
# --> these 4 are configurable -> max showminmatchscore = 35 + 11 + 6 + 4 + 4 = 60
Expand Down Expand Up @@ -1582,7 +1582,7 @@ def _upgrade_config(from_version, to_version):
# 'episode': 30
# --> these 4 should always be matched by default -> not visible in GUI -> showminmatchscore = 330
# 'release_group': 15
# 'format': 7
# 'source': 7
# 'resolution': 2
# 'video_codec': 2
# --> these 4 are configurable -> max showminmatchscore = 330 + 15 + 7 + 2 + 2 = 356
Expand All @@ -1599,7 +1599,7 @@ def _upgrade_config(from_version, to_version):
# 'year': 30
# --> these 2 should always be matched by default -> not visible in GUI -> showminmatchscore = 90
# 'release_group': 15
# 'format': 7
# 'source': 7
# 'resolution': 2
# 'video_codec': 2
# --> these 4 are configurable -> max showminmatchscore = 90 + 15 + 7 + 2 + 2 = 116
Expand Down
2 changes: 1 addition & 1 deletion autosubliminal/core/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def from_guess(cls, guess):
year=cls._property_from_guess(guess, 'year'),
season=cls._property_from_guess(guess, 'season'),
episode=cls._property_from_guess(guess, 'episode'),
source=cls._property_from_guess(guess, 'format'),
source=cls._property_from_guess(guess, 'source'),
quality=cls._property_from_guess(guess, 'screen_size'),
codec=cls._property_from_guess(guess, 'video_codec'),
releasegrp=cls._property_from_guess(guess, 'release_group'))
Expand Down
23 changes: 23 additions & 0 deletions autosubliminal/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# coding=utf-8

from time import time

from autosubliminal.parsers.guessit import default_api


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:
:type options: str|dict
:return:
:rtype:
"""
start_time = time()
custom_options = dict(options) if options else dict()
result = default_api.guessit(string, options=custom_options)
result['parsing_time'] = time() - start_time

return result
9 changes: 9 additions & 0 deletions autosubliminal/parsers/guessit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding=utf-8

from guessit.api import default_api

from autosubliminal.parsers.guessit.rules import rules

# Add our custom rules to the default guessit api
default_api.configure({})
default_api.rebulk.rebulk(rules())

0 comments on commit 27f8361

Please sign in to comment.