mirror of
https://github.com/zoriya/guessit.git
synced 2026-06-06 11:52:55 +00:00
Remame extension property to container with extension tag
This commit is contained in:
@@ -9,7 +9,7 @@ from .markers.path import PATH_MARKER
|
||||
from .markers.groups import GROUPS_MARKER
|
||||
|
||||
from .properties.episodes import EPISODES
|
||||
from .properties.extension import EXTENSION
|
||||
from .properties.container import CONTAINER
|
||||
from .properties.format import FORMAT
|
||||
from .properties.video_codec import VIDEO_CODEC
|
||||
from .properties.audio_codec import AUDIO_CODEC
|
||||
@@ -37,7 +37,7 @@ REBULK.rebulk(PATH_MARKER)
|
||||
REBULK.rebulk(GROUPS_MARKER)
|
||||
|
||||
REBULK.rebulk(EPISODES)
|
||||
REBULK.rebulk(EXTENSION)
|
||||
REBULK.rebulk(CONTAINER)
|
||||
REBULK.rebulk(FORMAT)
|
||||
REBULK.rebulk(VIDEO_CODEC)
|
||||
REBULK.rebulk(AUDIO_CODEC)
|
||||
|
||||
@@ -11,7 +11,8 @@ def marker_comparator_predicate(match):
|
||||
Match predicate used in comparator
|
||||
"""
|
||||
return not match.private and \
|
||||
match.name not in ['extension', 'properCount', 'title', 'episodeTitle', 'alternativeTitle']
|
||||
match.name not in ['properCount', 'title', 'episodeTitle', 'alternativeTitle'] and \
|
||||
not (match.name == 'container' and 'extension' in match.tags)
|
||||
|
||||
|
||||
def marker_weight(matches, marker):
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Container support
|
||||
"""
|
||||
from rebulk import Rebulk
|
||||
|
||||
import regex as re
|
||||
|
||||
from ..common.validators import seps_surround
|
||||
|
||||
CONTAINER = Rebulk().regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
|
||||
CONTAINER.defaults(name='container',
|
||||
formatter=lambda value: value[1:],
|
||||
tags=['extension'],
|
||||
conflict_solver=lambda match, other: other
|
||||
if other.name in ['format', 'videoCodec'] or
|
||||
other.name == 'container' and 'extension' not in other.tags
|
||||
else '__default__')
|
||||
|
||||
subtitles = ['srt', 'idx', 'sub', 'ssa', 'ass']
|
||||
info = ['nfo']
|
||||
videos = ['3g2', '3gp', '3gp2', 'asf', 'avi', 'divx', 'flv', 'm4v', 'mk2',
|
||||
'mka', 'mkv', 'mov', 'mp4', 'mp4a', 'mpeg', 'mpg', 'ogg', 'ogm',
|
||||
'ogv', 'qt', 'ra', 'ram', 'rm', 'ts', 'wav', 'webm', 'wma', 'wmv',
|
||||
'iso', 'vob']
|
||||
torrent = ['torrent']
|
||||
|
||||
CONTAINER.regex(r'\.\L<exts>$', exts=subtitles, tags=['extension', 'subtitle'])
|
||||
CONTAINER.regex(r'\.\L<exts>$', exts=info, tags=['extension', 'info'])
|
||||
CONTAINER.regex(r'\.\L<exts>$', exts=videos, tags=['extension', 'video'])
|
||||
CONTAINER.regex(r'\.\L<exts>$', exts=torrent, tags=['extension', 'torrent'])
|
||||
|
||||
|
||||
CONTAINER.defaults(name='container',
|
||||
validator=seps_surround,
|
||||
conflict_solver=lambda match, other: match
|
||||
if other.name in ['format', 'videoCodec'] or other.name == 'container' and 'extension' in other.tags
|
||||
else '__default__')
|
||||
|
||||
CONTAINER.string(*[sub for sub in subtitles if sub not in ['sub']], tags=['subtitle'])
|
||||
CONTAINER.string(*videos, tags=['video'])
|
||||
CONTAINER.string(*torrent, tags=['torrent'])
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Contry
|
||||
Country
|
||||
"""
|
||||
# pylint: disable=no-member
|
||||
from __future__ import unicode_literals
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Season/Episode numbering support
|
||||
'''
|
||||
from rebulk import Rebulk
|
||||
|
||||
import regex as re
|
||||
|
||||
from ..common.validators import seps_surround
|
||||
|
||||
EXTENSION = Rebulk().regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
|
||||
EXTENSION.defaults(name='extension',
|
||||
formatter=lambda value: value[1:],
|
||||
conflict_solver=lambda match, other: other
|
||||
if other.name in ['container', 'format', 'videoCodec']
|
||||
else '__default__')
|
||||
|
||||
subtitles = ['srt', 'idx', 'sub', 'ssa', 'ass']
|
||||
info = ['nfo']
|
||||
videos = ['3g2', '3gp', '3gp2', 'asf', 'avi', 'divx', 'flv', 'm4v', 'mk2',
|
||||
'mka', 'mkv', 'mov', 'mp4', 'mp4a', 'mpeg', 'mpg', 'ogg', 'ogm',
|
||||
'ogv', 'qt', 'ra', 'ram', 'rm', 'ts', 'wav', 'webm', 'wma', 'wmv',
|
||||
'iso', 'vob']
|
||||
torrent = ['torrent']
|
||||
|
||||
EXTENSION.regex(r'\.\L<exts>$', exts=subtitles, tags=['subtitle'])
|
||||
EXTENSION.regex(r'\.\L<exts>$', exts=info, tags=['info'])
|
||||
EXTENSION.regex(r'\.\L<exts>$', exts=videos, tags=['video'])
|
||||
EXTENSION.regex(r'\.\L<exts>$', exts=torrent, tags=['torrent'])
|
||||
|
||||
|
||||
EXTENSION.defaults(name='container',
|
||||
validator=seps_surround,
|
||||
conflict_solver=lambda match, other: match
|
||||
if other.name in ['extension', 'format', 'videoCodec']
|
||||
else '__default__')
|
||||
|
||||
EXTENSION.string(*subtitles, tags=['subtitle'])
|
||||
EXTENSION.string(*videos, tags=['video'])
|
||||
EXTENSION.string(*torrent, tags=['torrent'])
|
||||
@@ -11,7 +11,6 @@ import regex as re
|
||||
import babelfish
|
||||
|
||||
from rebulk import Rebulk, Rule, RemoveMatch, RenameMatch
|
||||
|
||||
from ..common.words import iter_words, COMMON_WORDS
|
||||
from ..common.validators import seps_surround
|
||||
|
||||
@@ -217,7 +216,9 @@ class SubtitleExtensionRule(Rule):
|
||||
consequence = RenameMatch('subtitleLanguage')
|
||||
|
||||
def when(self, matches, context):
|
||||
subtitle_extension = matches.named('extension', lambda match: 'subtitle' in match.tags, 0)
|
||||
subtitle_extension = matches.named('container',
|
||||
lambda match: 'extension' in match.tags and'subtitle' in match.tags,
|
||||
0)
|
||||
if subtitle_extension:
|
||||
subtitle_language = matches.previous(subtitle_extension, lambda match: match.name == 'language', 0)
|
||||
if subtitle_language:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
format: HDTV
|
||||
videoCodec: XviD
|
||||
releaseGroup: 0TV
|
||||
extension: avi
|
||||
container: avi
|
||||
|
||||
? Series/dexter/Dexter.5x02.Hello,.Bandit.ENG.-.sub.FR.HDTV.XviD-AlFleNi-TeaM.[tvu.org.ru].avi
|
||||
: title: Dexter
|
||||
@@ -22,7 +22,7 @@
|
||||
videoCodec: XviD
|
||||
releaseGroup: AlFleNi-TeaM
|
||||
website: tvu.org.ru
|
||||
extension: avi
|
||||
container: avi
|
||||
|
||||
? Series/Treme/Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi
|
||||
: title: Treme
|
||||
@@ -782,7 +782,7 @@
|
||||
season: 2
|
||||
title: Something
|
||||
episodeTitle: Title
|
||||
extension: torrent
|
||||
container: torrent
|
||||
|
||||
? Something.Season.2of5.3of9.Ep.Title.HDTV.torrent
|
||||
: episodeCount: 9
|
||||
@@ -792,7 +792,7 @@
|
||||
seasonCount: 5
|
||||
title: Something
|
||||
episodeTitle: Title
|
||||
extension: torrent
|
||||
container: torrent
|
||||
|
||||
? Something.Other.Season.3of5.Complete.HDTV.torrent
|
||||
: format: HDTV
|
||||
@@ -800,7 +800,7 @@
|
||||
season: 3
|
||||
seasonCount: 5
|
||||
title: Something Other
|
||||
extension: torrent
|
||||
container: torrent
|
||||
|
||||
? Something.Other.Season.1-3.avi
|
||||
: season: [1, 2, 3]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
format: HD-DVD
|
||||
audioCodec: DTS
|
||||
videoCodec: h264
|
||||
extension: mkv
|
||||
container: mkv
|
||||
releaseGroup: ESiR
|
||||
|
||||
? Movies/El Dia de la Bestia (1995)/El.dia.de.la.bestia.DVDrip.Spanish.DivX.by.Artik[SEDG].avi
|
||||
@@ -18,7 +18,7 @@
|
||||
language: spanish
|
||||
videoCodec: DivX
|
||||
releaseGroup: Artik[SEDG]
|
||||
extension: avi
|
||||
container: avi
|
||||
|
||||
? Movies/Dark City (1998)/Dark.City.(1998).DC.BDRip.720p.DTS.X264-CHD.mkv
|
||||
: title: Dark City
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
? Some movie (2000)/Some movie (2001).mkv
|
||||
? Some movie (2001)/Some movie.mkv
|
||||
: year: 2001
|
||||
extension: mkv
|
||||
container: mkv
|
||||
|
||||
@@ -374,7 +374,7 @@
|
||||
title: Something
|
||||
episodeTitle: Title
|
||||
type: episode
|
||||
extension: torrent
|
||||
container: torrent
|
||||
|
||||
? Show-A (US) - Episode Title S02E09 hdtv
|
||||
: options: -n
|
||||
|
||||
Reference in New Issue
Block a user