Skip to content

Commit

Permalink
Add back shooter and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
medariox committed Apr 7, 2016
1 parent 89a4599 commit a511338
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
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, hash_itasa
from .utils import hash_itasa, hash_napiprojekt, hash_opensubtitles, hash_shooter, hash_thesubdb
from .video import VIDEO_EXTENSIONS, Episode, Movie, Video

#: Supported archive extensions
Expand Down Expand Up @@ -385,6 +385,7 @@ def scan_video(path):
logger.debug('Size is %d', video.size)
video.hashes['itasa'] = hash_itasa(path)
video.hashes['opensubtitles'] = hash_opensubtitles(path)
video.hashes['shooter'] = hash_shooter(path)
video.hashes['thesubdb'] = hash_thesubdb(path)
video.hashes['napiprojekt'] = hash_napiprojekt(path)
logger.debug('Computed hashes %r', video.hashes)
Expand Down
2 changes: 1 addition & 1 deletion lib/subliminal/providers/podnapisi.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class PodnapisiProvider(Provider):
"""Podnapisi Provider."""
languages = ({Language('por', 'BR'), Language('srp', script='Latn')} |
{Language.fromalpha2(l) for l in language_converters['alpha2'].codes})
server_url = 'http://podnapisi.net/subtitles/'
server_url = 'http://podnapisi.eu/subtitles/'

def initialize(self):
self.session = Session()
Expand Down
1 change: 1 addition & 0 deletions lib/subliminal/providers/shooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, language, hash, download_link):
self.hash = hash
self.download_link = download_link

@property
def id(self):
return self.download_link

Expand Down
22 changes: 22 additions & 0 deletions lib/subliminal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import struct


def hash_itasa(video_path):
"""Compute a hash using ItaSA's algorithm.
Expand Down Expand Up @@ -49,6 +50,27 @@ def hash_opensubtitles(video_path):
return returnedhash


def hash_shooter(video_path):
"""Compute a hash using Shooter's algorithm
:param string video_path: path of the video
:return: the hash
:rtype: string
"""
filesize = os.path.getsize(video_path)
readsize = 4096
if os.path.getsize(video_path) < readsize * 2:
return None
offsets = (readsize, filesize // 3 * 2, filesize // 3, filesize - readsize * 2)
filehash = []
with open(video_path, 'rb') as f:
for offset in offsets:
f.seek(offset)
filehash.append(hashlib.md5(f.read(readsize)).hexdigest())
return ';'.join(filehash)


def hash_thesubdb(video_path):
"""Compute a hash using TheSubDB's algorithm.
Expand Down

0 comments on commit a511338

Please sign in to comment.