[TV] Split matcher into separate modules
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
|||||||
|
from .main import ShowMatcher
|
||||||
|
|
||||||
|
|
||||||
|
def autoload():
|
||||||
|
return ShowMatcher()
|
||||||
|
|
||||||
|
config = []
|
||||||
+2
-61
@@ -1,19 +1,9 @@
|
|||||||
from couchpotato import CPLog
|
from couchpotato import fireEvent, CPLog, tryInt
|
||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
|
||||||
from couchpotato.core.media._base.matcher.base import MatcherBase
|
from couchpotato.core.media._base.matcher.base import MatcherBase
|
||||||
from couchpotato.core.media._base.providers.base import MultiProvider
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
autoload = 'ShowMatcher'
|
|
||||||
|
|
||||||
|
|
||||||
class ShowMatcher(MultiProvider):
|
|
||||||
|
|
||||||
def getTypes(self):
|
|
||||||
return [Season, Episode]
|
|
||||||
|
|
||||||
|
|
||||||
class Base(MatcherBase):
|
class Base(MatcherBase):
|
||||||
|
|
||||||
@@ -80,52 +70,3 @@ class Base(MatcherBase):
|
|||||||
identifier[key] = tryInt(value, value)
|
identifier[key] = tryInt(value, value)
|
||||||
|
|
||||||
return identifier
|
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
@@ -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
|
||||||
Executable
+9
@@ -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
@@ -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