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

0.7.x #404

Merged
merged 28 commits into from Mar 4, 2015
Merged

0.7.x #404

Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3b832a4
updated guessit and babelfish minimum requirements
caronc Sep 18, 2014
e6dc714
Eliminated Dict Comprehensions (PEP 274) references to allow sublimin…
caronc Sep 18, 2014
14c7443
applied guessit v0.7 support
caronc Sep 18, 2014
71d206a
allow searching for subtitles by best score; not exclusively hearing …
caronc Sep 18, 2014
73a4e5a
subliminal bugfix to prevent multiple matched subtitles from differen…
caronc Sep 18, 2014
3b52a93
added ability to prioritize multiple matched subtitles; Download Hear…
caronc Sep 18, 2014
88a2cb9
added graceful handling of subtitle providers that are simply offline…
caronc Sep 18, 2014
4702284
podnapisi website changes maded in Aug 2014 broke this provider in su…
caronc Sep 18, 2014
1e9588e
Added support for titles that contain quotes
caronc Oct 18, 2014
827c75f
better handling of duplicate download prevention
caronc Nov 11, 2014
6cdf189
Fixed TVSubtitles.net matching
caronc Nov 11, 2014
87aefa3
Massive overhaul on testing to make it Python v2.6 compatible
caronc Nov 11, 2014
90d06e2
logging output slighly adjusted (added some clarity and removed some …
caronc Nov 11, 2014
d635269
removed bierdopje provider since it's not referenced anymore anyway (…
caronc Nov 11, 2014
3c7634f
eliminated bierdopje entry point to fix testing issue
caronc Nov 11, 2014
bc575ea
comparison functions added to help with 3rd party filtering
caronc Nov 30, 2014
7fef3cf
scoring adjustments moved into compute_score() and some logging cleanup
caronc Nov 30, 2014
e6bd704
scan_video() now takes pre-guessed video as optional input. This grants
caronc Dec 7, 2014
d45e3b0
improved logging for provider debugging
caronc Jan 26, 2015
a25640b
fixes #425; I'm not proud of this fix; but it resolves the issue.
caronc Jan 26, 2015
3acbefb
fixes #428; I'm not proud of this fix; but it resolves the issue.
caronc Jan 26, 2015
6c28336
Merge branch '0.7.x' of github:caronc/subliminal into 0.7.x
caronc Jan 28, 2015
e45fe70
updated requirements
caronc Jan 29, 2015
a86694d
updated requirements so that Travis CI doesn't haul in guessit v0.10
caronc Jan 29, 2015
1b7291e
Merge branch '0.7.x' of github:caronc/subliminal into 0.7.x
caronc Jan 30, 2015
c74aa01
random user agent determined at runtime; default user-agent reference…
caronc Feb 1, 2015
16ddb8a
addic7ed timeout reverted back to 10 second timeout
caronc Feb 1, 2015
407cbe1
series/movie title sanitization refactored
caronc Feb 1, 2015
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

scoring adjustments moved into compute_score() and some logging cleanup

  • Loading branch information
caronc committed Nov 30, 2014
commit 7fef3cfc93beab76c122b760a073b73d11488bae
@@ -74,7 +74,10 @@ def list_subtitles(videos, languages, providers=None, provider_configs=None):
except:
logger.exception('Unexpected error in provider %r', provider_entry_point.name)
continue
logger.info('Found %d subtitles', len(provider_subtitles))
logger.info('Found %d subtitle(s) on %s' % (
len(provider_subtitles),
provider_entry_point.name,
))
subtitles[provider_video].extend(provider_subtitles)
except ProviderNotAvailable:
logger.warning('Provider %r is not available, discarding it', provider_entry_point.name)
@@ -207,10 +210,10 @@ def download_best_subtitles(videos, languages, providers=None, provider_configs=
continue
Provider = provider_entry_point.load()
if not Provider.languages & languages - subtitle_languages:
logger.info('Skipping provider %r: no language to search for', provider_entry_point.name)
logger.debug('Skipping provider %r: no language to search for', provider_entry_point.name)
continue
if not [v for v in videos if Provider.check(v)]:
logger.info('Skipping provider %r: no video to search for', provider_entry_point.name)
logger.debug('Skipping provider %r: video type not hosted here.', provider_entry_point.name)
continue
provider = Provider(**provider_configs.get(provider_entry_point.name, {}))
try:
@@ -253,27 +256,30 @@ def download_best_subtitles(videos, languages, providers=None, provider_configs=
except:
logger.exception('Unexpected error in provider %r', provider_name)
continue
logger.info('Found %d subtitles', len(provider_subtitles))
logger.info('Found %d subtitle(s) on %s' % (
len(provider_subtitles),
provider_name,
))
subtitles.extend(provider_subtitles)

# find the best subtitles and download them
for subtitle, score in sorted([(s, s.compute_score(video)) for s in subtitles],
key=operator.itemgetter(1), reverse=True):
for subtitle, score in sorted([(s, s.compute_score(video, hi_score_adjust)) \
for s in subtitles], key=operator.itemgetter(1), reverse=True):

# filter
if subtitle.provider_name in discarded_providers:
logger.debug('Skipping subtitle from discarded provider %r', subtitle.provider_name)
continue

if hearing_impaired is not None:
if subtitle.hearing_impaired != hearing_impaired:
logger.debug('Skipping subtitle: hearing impaired != %r', hearing_impaired)
continue
elif subtitle.hearing_impaired and hi_score_adjust != 0:
# Priortization (adjust score)
score += hi_score_adjust

if score < min_score:
logger.debug('Skipping subtitle: score < %d', min_score)
continue

if subtitle.language in downloaded_languages:
logger.debug('Skipping subtitle: %r already downloaded', subtitle.language)
continue
@@ -33,7 +33,7 @@ def compute_matches(self, video):
"""
raise NotImplementedError

def compute_score(self, video):
def compute_score(self, video, hi_score_adjust=0):
"""Compute the score of the subtitle against the `video`
There are equivalent matches so that a provider can match one element or its equivalent. This is
@@ -47,6 +47,7 @@ def compute_score(self, video):
:param video: the video to compute the score against
:type video: :class:`~subliminal.video.Video`
:param hi_score_adjust: adjust hearing impaired matched videos by this value
:return: score of the subtitle
:rtype: int
@@ -69,7 +70,15 @@ def compute_score(self, video):
matches -= set(['season', 'episode'])
# add other scores
score += sum([video.scores[match] for match in matches])
logger.info('Computed score %d with matches %r', score, initial_matches)

# Adjust scoring if hearing impaired subtitles are detected
if self.hearing_impaired and hi_score_adjust != 0:
logger.debug('Hearing impaired subtitle score adjusted ' + \
'by %d' % hi_score_adjust)
# Priortization (adjust score)
score += hi_score_adjust

logger.debug('Computed score %d with matches %r', score, initial_matches)
return score

def __repr__(self):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.