Skip to content

Commit

Permalink
Merge 78687f4 into 22c5a9e
Browse files Browse the repository at this point in the history
  • Loading branch information
medariox committed Sep 30, 2018
2 parents 22c5a9e + 78687f4 commit 086f880
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 95 deletions.
6 changes: 3 additions & 3 deletions docs/user/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use :func:`~subliminal.core.scan_videos` on an existing directory path to scan a
Here video information was guessed based on the name of the video, you can access some video attributes:

>>> video.video_codec
'h264'
'H.264'
>>> video.release_group
'LOL'

Expand Down Expand Up @@ -95,8 +95,8 @@ them to the video and tell you exactly what matches with :meth:`~subliminal.subt

>>> for s in subtitles[video]:
... sorted(s.get_matches(video))
['episode', 'format', 'release_group', 'season', 'series', 'video_codec', 'year']
['episode', 'format', 'season', 'series', 'year']
['episode', 'release_group', 'season', 'series', 'source', 'video_codec', 'year']
['episode', 'season', 'series', 'source', 'year']

And then compute a score with those matches with :func:`~subliminal.score.compute_score`:

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def find_version(*file_paths):
# requirements
setup_requirements = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else []

install_requirements = ['guessit>=2.0.1', 'babelfish>=0.5.2', 'enzyme>=0.4.1', 'beautifulsoup4>=4.4.0',
install_requirements = ['guessit>=3.0.0', 'babelfish>=0.5.2', 'enzyme>=0.4.1', 'beautifulsoup4>=4.4.0',
'requests>=2.0', 'click>=4.0', 'dogpile.cache>=0.6.0', 'stevedore>=1.20.0',
'chardet>=2.3.0', 'pysrt>=1.0.1', 'six>=1.9.0', 'appdirs>=1.3', 'rarfile>=2.7',
'pytz>=2012c']
Expand Down
6 changes: 3 additions & 3 deletions subliminal/providers/addic7ed.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def get_matches(self, video):
# resolution
if video.resolution and self.version and video.resolution in self.version.lower():
matches.add('resolution')
# format
if video.format and self.version and video.format.lower() in self.version.lower():
matches.add('format')
# source
if video.source and self.version and video.source.lower() in self.version.lower():
matches.add('source')
# other properties
matches |= guess_matches(video, guessit(self.version), partial=True)

Expand Down
6 changes: 3 additions & 3 deletions subliminal/refiners/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def refine(video, embedded_subtitles=True, **kwargs):

# video codec
if video_track.codec_id == 'V_MPEG4/ISO/AVC':
video.video_codec = 'h264'
video.video_codec = 'H.264'
logger.debug('Found video_codec %s', video.video_codec)
elif video_track.codec_id == 'V_MPEG4/ISO/SP':
video.video_codec = 'DivX'
logger.debug('Found video_codec %s', video.video_codec)
elif video_track.codec_id == 'V_MPEG4/ISO/ASP':
video.video_codec = 'XviD'
video.video_codec = 'Xvid'
logger.debug('Found video_codec %s', video.video_codec)
else:
logger.warning('MKV has no video track')
Expand All @@ -61,7 +61,7 @@ def refine(video, embedded_subtitles=True, **kwargs):
audio_track = mkv.audio_tracks[0]
# audio codec
if audio_track.codec_id == 'A_AC3':
video.audio_codec = 'AC3'
video.audio_codec = 'Dolby Digital'
logger.debug('Found audio_codec %s', video.audio_codec)
elif audio_track.codec_id == 'A_DTS':
video.audio_codec = 'DTS'
Expand Down
40 changes: 20 additions & 20 deletions subliminal/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* season
* episode
* release_group
* format
* source
* audio_codec
* resolution
* hearing_impaired
Expand All @@ -37,11 +37,11 @@

#: Scores for episodes
episode_scores = {'hash': 359, 'series': 180, 'year': 90, 'season': 30, 'episode': 30, 'release_group': 15,
'format': 7, 'audio_codec': 3, 'resolution': 2, 'video_codec': 2, 'hearing_impaired': 1}
'source': 7, 'audio_codec': 3, 'resolution': 2, 'video_codec': 2, 'hearing_impaired': 1}

#: Scores for movies
movie_scores = {'hash': 119, 'title': 60, 'year': 30, 'release_group': 15,
'format': 7, 'audio_codec': 3, 'resolution': 2, 'video_codec': 2, 'hearing_impaired': 1}
'source': 7, 'audio_codec': 3, 'resolution': 2, 'video_codec': 2, 'hearing_impaired': 1}

#: Equivalent release groups
equivalent_release_groups = ({'LOL', 'DIMENSION'}, {'ASAP', 'IMMERSE', 'FLEET'}, {'AVS', 'SVA'})
Expand Down Expand Up @@ -152,30 +152,30 @@ def solve_episode_equations():
from sympy import Eq, solve, symbols

hash, series, year, season, episode, release_group = symbols('hash series year season episode release_group')
format, audio_codec, resolution, video_codec = symbols('format audio_codec resolution video_codec')
source, audio_codec, resolution, video_codec = symbols('source audio_codec resolution video_codec')
hearing_impaired = symbols('hearing_impaired')

equations = [
# hash is best
Eq(hash, series + year + season + episode + release_group + format + audio_codec + resolution + video_codec),
Eq(hash, series + year + season + episode + release_group + source + audio_codec + resolution + video_codec),

# series counts for the most part in the total score
Eq(series, year + season + episode + release_group + format + audio_codec + resolution + video_codec + 1),
Eq(series, year + season + episode + release_group + source + audio_codec + resolution + video_codec + 1),

# year is the second most important part
Eq(year, season + episode + release_group + format + audio_codec + resolution + video_codec + 1),
Eq(year, season + episode + release_group + source + audio_codec + resolution + video_codec + 1),

# season is important too
Eq(season, release_group + format + audio_codec + resolution + video_codec + 1),
Eq(season, release_group + source + audio_codec + resolution + video_codec + 1),

# episode is equally important to season
Eq(episode, season),

# release group is the next most wanted match
Eq(release_group, format + audio_codec + resolution + video_codec + 1),
Eq(release_group, source + audio_codec + resolution + video_codec + 1),

# format counts as much as audio_codec, resolution and video_codec
Eq(format, audio_codec + resolution + video_codec),
# source counts as much as audio_codec, resolution and video_codec
Eq(source, audio_codec + resolution + video_codec),

# audio_codec is more valuable than video_codec
Eq(audio_codec, video_codec + 1),
Expand All @@ -190,32 +190,32 @@ def solve_episode_equations():
Eq(hearing_impaired, 1),
]

return solve(equations, [hash, series, year, season, episode, release_group, format, audio_codec, resolution,
return solve(equations, [hash, series, year, season, episode, release_group, source, audio_codec, resolution,
hearing_impaired, video_codec])


def solve_movie_equations():
from sympy import Eq, solve, symbols

hash, title, year, release_group = symbols('hash title year release_group')
format, audio_codec, resolution, video_codec = symbols('format audio_codec resolution video_codec')
source, audio_codec, resolution, video_codec = symbols('source audio_codec resolution video_codec')
hearing_impaired = symbols('hearing_impaired')

equations = [
# hash is best
Eq(hash, title + year + release_group + format + audio_codec + resolution + video_codec),
Eq(hash, title + year + release_group + source + audio_codec + resolution + video_codec),

# title counts for the most part in the total score
Eq(title, year + release_group + format + audio_codec + resolution + video_codec + 1),
Eq(title, year + release_group + source + audio_codec + resolution + video_codec + 1),

# year is the second most important part
Eq(year, release_group + format + audio_codec + resolution + video_codec + 1),
Eq(year, release_group + source + audio_codec + resolution + video_codec + 1),

# release group is the next most wanted match
Eq(release_group, format + audio_codec + resolution + video_codec + 1),
Eq(release_group, source + audio_codec + resolution + video_codec + 1),

# format counts as much as audio_codec, resolution and video_codec
Eq(format, audio_codec + resolution + video_codec),
# source counts as much as audio_codec, resolution and video_codec
Eq(source, audio_codec + resolution + video_codec),

# audio_codec is more valuable than video_codec
Eq(audio_codec, video_codec + 1),
Expand All @@ -230,5 +230,5 @@ def solve_movie_equations():
Eq(hearing_impaired, 1),
]

return solve(equations, [hash, title, year, release_group, format, audio_codec, resolution, hearing_impaired,
return solve(equations, [hash, title, year, release_group, source, audio_codec, resolution, hearing_impaired,
video_codec])
6 changes: 3 additions & 3 deletions subliminal/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ def guess_matches(video, guess, partial=False):
# resolution
if video.resolution and 'screen_size' in guess and guess['screen_size'] == video.resolution:
matches.add('resolution')
# format
if video.format and 'format' in guess and guess['format'].lower() == video.format.lower():
matches.add('format')
# source
if video.source and 'source' in guess and guess['source'].lower() == video.source.lower():
matches.add('source')
# video_codec
if video.video_codec and 'video_codec' in guess and guess['video_codec'] == video.video_codec:
matches.add('video_codec')
Expand Down
12 changes: 6 additions & 6 deletions subliminal/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Video(object):
Represent a video, existing or not.
:param str name: name or path of the video.
:param str format: format of the video (HDTV, WEB-DL, BluRay, ...).
:param str source: source of the video (HDTV, Web, Blu-ray, ...).
:param str release_group: release group of the video.
:param str resolution: resolution of the video stream (480p, 720p, 1080p or 1080i).
:param str video_codec: codec of the video stream.
Expand All @@ -35,13 +35,13 @@ class Video(object):
:param set subtitle_languages: existing subtitle languages.
"""
def __init__(self, name, format=None, release_group=None, resolution=None, video_codec=None, audio_codec=None,
def __init__(self, name, source=None, release_group=None, resolution=None, video_codec=None, audio_codec=None,
imdb_id=None, hashes=None, size=None, subtitle_languages=None):
#: Name or path of the video
self.name = name

#: Format of the video (HDTV, WEB-DL, BluRay, ...)
self.format = format
#: Source of the video (HDTV, Web, Blu-ray, ...)
self.source = source

#: Release group of the video
self.release_group = release_group
Expand Down Expand Up @@ -176,7 +176,7 @@ def fromguess(cls, name, guess):
episode = min(episode_guess) if episode_guess and isinstance(episode_guess, list) else episode_guess

return cls(name, guess['title'], guess.get('season', 1), episode, title=guess.get('episode_title'),
year=guess.get('year'), format=guess.get('format'), original_series='year' not in guess,
year=guess.get('year'), source=guess.get('source'), original_series='year' not in guess,
release_group=guess.get('release_group'), resolution=guess.get('screen_size'),
video_codec=guess.get('video_codec'), audio_codec=guess.get('audio_codec'))

Expand Down Expand Up @@ -220,7 +220,7 @@ def fromguess(cls, name, guess):
if 'title' not in guess:
raise ValueError('Insufficient data to process the guess')

return cls(name, guess['title'], format=guess.get('format'), release_group=guess.get('release_group'),
return cls(name, guess['title'], source=guess.get('source'), release_group=guess.get('release_group'),
resolution=guess.get('screen_size'), video_codec=guess.get('video_codec'),
audio_codec=guess.get('audio_codec'), year=guess.get('year'))

Expand Down

0 comments on commit 086f880

Please sign in to comment.