[TV] Split matcher into separate modules
This commit is contained in:
7
couchpotato/core/media/show/matcher/__init__.py
Executable file
7
couchpotato/core/media/show/matcher/__init__.py
Executable file
@@ -0,0 +1,7 @@
|
||||
from .main import ShowMatcher
|
||||
|
||||
|
||||
def autoload():
|
||||
return ShowMatcher()
|
||||
|
||||
config = []
|
||||
@@ -1,19 +1,9 @@
|
||||
from couchpotato import CPLog
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.helpers.variable import tryInt
|
||||
from couchpotato import fireEvent, CPLog, tryInt
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.media._base.matcher.base import MatcherBase
|
||||
from couchpotato.core.media._base.providers.base import MultiProvider
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
autoload = 'ShowMatcher'
|
||||
|
||||
|
||||
class ShowMatcher(MultiProvider):
|
||||
|
||||
def getTypes(self):
|
||||
return [Season, Episode]
|
||||
|
||||
|
||||
class Base(MatcherBase):
|
||||
|
||||
@@ -80,52 +70,3 @@ class Base(MatcherBase):
|
||||
identifier[key] = tryInt(value, value)
|
||||
|
||||
return identifier
|
||||
|
||||
|
||||
class Episode(Base):
|
||||
type = 'show.episode'
|
||||
|
||||
def correctIdentifier(self, chain, media):
|
||||
identifier = self.getChainIdentifier(chain)
|
||||
if not identifier:
|
||||
log.info2('Wrong: release identifier is not valid (unsupported or missing identifier)')
|
||||
return False
|
||||
|
||||
# TODO - Parse episode ranges from identifier to determine if they are multi-part episodes
|
||||
if any([x in identifier for x in ['episode_from', 'episode_to']]):
|
||||
log.info2('Wrong: releases with identifier ranges are not supported yet')
|
||||
return False
|
||||
|
||||
required = fireEvent('library.identifier', media, single = True)
|
||||
|
||||
# TODO - Support air by date episodes
|
||||
# TODO - Support episode parts
|
||||
|
||||
if identifier != required:
|
||||
log.info2('Wrong: required identifier (%s) does not match release identifier (%s)', (required, identifier))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class Season(Base):
|
||||
type = 'show.season'
|
||||
|
||||
def correctIdentifier(self, chain, media):
|
||||
identifier = self.getChainIdentifier(chain)
|
||||
if not identifier:
|
||||
log.info2('Wrong: release identifier is not valid (unsupported or missing identifier)')
|
||||
return False
|
||||
|
||||
# TODO - Parse episode ranges from identifier to determine if they are season packs
|
||||
if any([x in identifier for x in ['episode_from', 'episode_to']]):
|
||||
log.info2('Wrong: releases with identifier ranges are not supported yet')
|
||||
return False
|
||||
|
||||
required = fireEvent('library.identifier', media, single = True)
|
||||
|
||||
if identifier != required:
|
||||
log.info2('Wrong: required identifier (%s) does not match release identifier (%s)', (required, identifier))
|
||||
return False
|
||||
|
||||
return True
|
||||
30
couchpotato/core/media/show/matcher/episode.py
Executable file
30
couchpotato/core/media/show/matcher/episode.py
Executable file
@@ -0,0 +1,30 @@
|
||||
from couchpotato import fireEvent, CPLog
|
||||
from couchpotato.core.media.show.matcher.base import Base
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Episode(Base):
|
||||
type = 'show.episode'
|
||||
|
||||
def correctIdentifier(self, chain, media):
|
||||
identifier = self.getChainIdentifier(chain)
|
||||
if not identifier:
|
||||
log.info2('Wrong: release identifier is not valid (unsupported or missing identifier)')
|
||||
return False
|
||||
|
||||
# TODO - Parse episode ranges from identifier to determine if they are multi-part episodes
|
||||
if any([x in identifier for x in ['episode_from', 'episode_to']]):
|
||||
log.info2('Wrong: releases with identifier ranges are not supported yet')
|
||||
return False
|
||||
|
||||
required = fireEvent('library.identifier', media, single = True)
|
||||
|
||||
# TODO - Support air by date episodes
|
||||
# TODO - Support episode parts
|
||||
|
||||
if identifier != required:
|
||||
log.info2('Wrong: required identifier (%s) does not match release identifier (%s)', (required, identifier))
|
||||
return False
|
||||
|
||||
return True
|
||||
9
couchpotato/core/media/show/matcher/main.py
Executable file
9
couchpotato/core/media/show/matcher/main.py
Executable file
@@ -0,0 +1,9 @@
|
||||
from couchpotato.core.media._base.providers.base import MultiProvider
|
||||
from couchpotato.core.media.show.matcher.episode import Episode
|
||||
from couchpotato.core.media.show.matcher.season import Season
|
||||
|
||||
|
||||
class ShowMatcher(MultiProvider):
|
||||
|
||||
def getTypes(self):
|
||||
return [Season, Episode]
|
||||
27
couchpotato/core/media/show/matcher/season.py
Executable file
27
couchpotato/core/media/show/matcher/season.py
Executable file
@@ -0,0 +1,27 @@
|
||||
from couchpotato import fireEvent, CPLog
|
||||
from couchpotato.core.media.show.matcher.base import Base
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Season(Base):
|
||||
type = 'show.season'
|
||||
|
||||
def correctIdentifier(self, chain, media):
|
||||
identifier = self.getChainIdentifier(chain)
|
||||
if not identifier:
|
||||
log.info2('Wrong: release identifier is not valid (unsupported or missing identifier)')
|
||||
return False
|
||||
|
||||
# TODO - Parse episode ranges from identifier to determine if they are season packs
|
||||
if any([x in identifier for x in ['episode_from', 'episode_to']]):
|
||||
log.info2('Wrong: releases with identifier ranges are not supported yet')
|
||||
return False
|
||||
|
||||
required = fireEvent('library.identifier', media, single = True)
|
||||
|
||||
if identifier != required:
|
||||
log.info2('Wrong: required identifier (%s) does not match release identifier (%s)', (required, identifier))
|
||||
return False
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user