Skip to content

Commit

Permalink
Re-add Itasa subtitle provider
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandog committed Apr 7, 2016
1 parent 2cb64c7 commit 89a4599
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/subliminal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def convert(self, value, param, ctx):
@click.group(context_settings={'max_content_width': 100}, epilog='Suggestions and bug reports are greatly appreciated: '
'https://github.com/Diaoul/subliminal/')
@click.option('--addic7ed', type=click.STRING, nargs=2, metavar='USERNAME PASSWORD', help='Addic7ed configuration.')
@click.option('--itasa', type=click.STRING, nargs=2, metavar='USERNAME PASSWORD', help='ItaSA configuration.')
@click.option('--legendastv', type=click.STRING, nargs=2, metavar='USERNAME PASSWORD', help='LegendasTV configuration.')
@click.option('--opensubtitles', type=click.STRING, nargs=2, metavar='USERNAME PASSWORD',
help='OpenSubtitles configuration.')
Expand All @@ -224,7 +225,7 @@ def convert(self, value, param, ctx):
@click.option('--debug', is_flag=True, help='Print useful information for debugging subliminal and for reporting bugs.')
@click.version_option(__version__)
@click.pass_context
def subliminal(ctx, addic7ed, legendastv, opensubtitles, subscenter, cache_dir, debug):
def subliminal(ctx, addic7ed, itasa, legendastv, opensubtitles, subscenter, cache_dir, debug):
"""Subtitles, faster than your thoughts."""
# create cache directory
try:
Expand All @@ -248,6 +249,8 @@ def subliminal(ctx, addic7ed, legendastv, opensubtitles, subscenter, cache_dir,
ctx.obj = {'provider_configs': {}}
if addic7ed:
ctx.obj['provider_configs']['addic7ed'] = {'username': addic7ed[0], 'password': addic7ed[1]}
if itasa:
ctx.obj['provider_configs']['itasa'] = {'username': itasa[0], 'password': itasa[1]}
if legendastv:
ctx.obj['provider_configs']['legendastv'] = {'username': legendastv[0], 'password': legendastv[1]}
if opensubtitles:
Expand Down
3 changes: 2 additions & 1 deletion lib/subliminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .extensions import provider_manager, refiner_manager
from .score import compute_score as default_compute_score
from .subtitle import SUBTITLE_EXTENSIONS, get_subtitle_path
from .utils import hash_napiprojekt, hash_opensubtitles, hash_thesubdb
from .utils import hash_napiprojekt, hash_opensubtitles, hash_thesubdb, hash_itasa
from .video import VIDEO_EXTENSIONS, Episode, Movie, Video

#: Supported archive extensions
Expand Down Expand Up @@ -383,6 +383,7 @@ def scan_video(path):
video.size = os.path.getsize(path)
if video.size > 10485760:
logger.debug('Size is %d', video.size)
video.hashes['itasa'] = hash_itasa(path)
video.hashes['opensubtitles'] = hash_opensubtitles(path)
video.hashes['thesubdb'] = hash_thesubdb(path)
video.hashes['napiprojekt'] = hash_napiprojekt(path)
Expand Down
13 changes: 13 additions & 0 deletions lib/subliminal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
import re
import struct

def hash_itasa(video_path):
"""Compute a hash using ItaSA's algorithm.
:param str video_path: path of the video.
:return: the hash.
:rtype: str
"""
readsize = 1024 * 1024 * 10
with open(video_path, 'rb') as f:
data = f.read(readsize)
return hashlib.md5(data).hexdigest()


def hash_opensubtitles(video_path):
"""Compute a hash using OpenSubtitles' algorithm.
Expand Down

0 comments on commit 89a4599

Please sign in to comment.