Skip to content

Commit

Permalink
Use cached video only when keyword args match
Browse files Browse the repository at this point in the history
  • Loading branch information
ratoaq2 authored and labrys committed May 8, 2016
1 parent 4122e8b commit e403290
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sickbeard/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,12 @@ def get_video(video_path, subtitles_dir=None, subtitles=True, embedded_subtitles
:rtype: subliminal.video.Video
"""
key = video_key.format(video_path=video_path)
video = region.get(key, expiration_time=VIDEO_EXPIRATION_TIME)
if video != NO_VALUE:
payload = {'subtitles_dir': subtitles_dir, 'subtitles': subtitles, 'embedded_subtitles': embedded_subtitles,
'release_name': release_name}
cached_payload = region.get(key, expiration_time=VIDEO_EXPIRATION_TIME)
if cached_payload != NO_VALUE and {k: v for k, v in cached_payload.iteritems() if k != 'video'} == payload:
logger.debug(u'Found cached video information under key %s', key)
return video
return cached_payload['video']

try:
video_path = _encode(video_path)
Expand All @@ -575,7 +577,8 @@ def get_video(video_path, subtitles_dir=None, subtitles=True, embedded_subtitles
refine(video, episode_refiners=episode_refiners, embedded_subtitles=embedded_subtitles,
release_name=release_name)

region.set(key, video)
payload['video'] = video
region.set(key, payload)
logger.debug(u'Video information cached under key %s', key)

return video
Expand Down

0 comments on commit e403290

Please sign in to comment.