Skip to content

Commit

Permalink
Merge 8caa3cf into 1a9cf06
Browse files Browse the repository at this point in the history
  • Loading branch information
ratoaq2 committed Jan 23, 2017
2 parents 1a9cf06 + 8caa3cf commit 9a8667c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
23 changes: 14 additions & 9 deletions guessit/rules/properties/episode_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,17 @@ class TitleToEpisodeTitle(Rule):

def when(self, matches, context):
titles = matches.named('title')

if len(titles) < 2:
return

title_groups = defaultdict(list)
for title in titles:
title_groups[title.value].append(title)

if len(title_groups) < 2:
return

episode_titles = []
main_titles = []
for title in titles:
if matches.previous(title, lambda match: match.name == 'episode'):
episode_titles.append(title)
else:
main_titles.append(title)

if episode_titles:
return episode_titles
Expand Down Expand Up @@ -199,7 +195,15 @@ class Filepart2EpisodeTitle(Rule):
AAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBB
If BBBB contains episode and AAA contains a hole followed by seasonNumber
Then title is to be found in AAAA.
then title is to be found in AAAA.
or
Serie name/SO1E01-episode_title.mkv
AAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBB
If BBBB contains season and episode and AAA contains a hole
then title is to be found in AAAA.
"""
consequence = AppendMatch('title')

Expand All @@ -213,7 +217,8 @@ def when(self, matches, context):

episode_number = matches.range(filename.start, filename.end, lambda match: match.name == 'episode', 0)
if episode_number:
season = matches.range(directory.start, directory.end, lambda match: match.name == 'season', 0)
season = (matches.range(directory.start, directory.end, lambda match: match.name == 'season', 0) or
matches.range(filename.start, filename.end, lambda match: match.name == 'season', 0))
if season:
hole = matches.holes(directory.start, directory.end, formatter=cleanup, seps=title_seps,
predicate=lambda match: match.value, index=0)
Expand Down
8 changes: 8 additions & 0 deletions guessit/test/episodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2901,3 +2901,11 @@
video_codec: h264
release_group: CasStudio
type: episode

? /tv/Daniel Tiger's Neighborhood/S02E06 - Playtime Is Different.mp4
: season: 2
episode: 6
title: Daniel Tiger's Neighborhood
episode_title: Playtime Is Different
container: mp4
type: episode

0 comments on commit 9a8667c

Please sign in to comment.