Browse Source

Merge pull request #2570 from fuzeman/tv_searcher

[TV] WEB-DL matcher fix, updated 'searcher.get_search_title'
pull/2574/head
Joel Kåberg 12 years ago
parent
commit
f591c56dd4
  1. 2
      couchpotato/core/media/_base/searcher/main.py
  2. 8
      couchpotato/core/media/movie/searcher/main.py
  3. 16
      couchpotato/core/media/show/searcher/main.py
  4. 12
      couchpotato/core/plugins/matcher/main.py
  5. 4
      couchpotato/core/providers/base.py
  6. 4
      couchpotato/core/providers/nzb/newznab/main.py
  7. 4
      couchpotato/core/providers/torrent/sceneaccess/main.py
  8. 2
      libs/caper/__init__.py
  9. 12
      libs/caper/helpers.py
  10. 7
      libs/caper/matcher.py
  11. 5
      libs/caper/parsers/scene.py
  12. 2
      libs/caper/result.py

2
couchpotato/core/media/_base/searcher/main.py

@ -171,7 +171,7 @@ class Searcher(SearcherBase):
return False
def correctWords(self, rel_name, media):
media_title = fireEvent('searcher.get_search_title', media, single = True)
media_title = fireEvent('searcher.get_search_title', media['library'], single = True)
media_words = re.split('\W+', simplifyString(media_title))
rel_name = simplifyString(rel_name)

8
couchpotato/core/media/movie/searcher/main.py

@ -210,7 +210,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
if media.get('type') != 'movie': return
media_title = fireEvent('searcher.get_search_title', media, single = True)
media_title = fireEvent('searcher.get_search_title', media['library'], single = True)
imdb_results = kwargs.get('imdb_results', False)
retention = Env.setting('retention', section = 'nzb')
@ -343,9 +343,9 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
log.error('Failed searching for next release: %s', traceback.format_exc())
return False
def getSearchTitle(self, media):
if media['type'] == 'movie':
return getTitle(media['library'])
def getSearchTitle(self, library, include_identifier = False):
if library['type'] == 'movie':
return getTitle(library)
class SearchSetupError(Exception):
pass

16
couchpotato/core/media/show/searcher/main.py

@ -19,8 +19,8 @@ class ShowSearcher(Plugin):
# TODO come back to this later, think this could be handled better
quality_map = {
'webdl_1080p': {'resolution': ['1080p'], 'source': ['webdl']},
'webdl_720p': {'resolution': ['720p'], 'source': ['webdl']},
'webdl_1080p': {'resolution': ['1080p'], 'source': ['webdl', ['web', 'dl']]},
'webdl_720p': {'resolution': ['720p'], 'source': ['webdl', ['web', 'dl']]},
'hdtv_720p': {'resolution': ['720p'], 'source': ['hdtv']},
'hdtv_sd': {'resolution': ['480p', None], 'source': ['hdtv']},
@ -133,11 +133,11 @@ class ShowSearcher(Plugin):
return ret
def getSearchTitle(self, media):
if media['type'] not in ['show', 'season', 'episode']:
def getSearchTitle(self, library, include_identifier = False):
if library['type'] not in ['show', 'season', 'episode']:
return
show, season, episode = self.getLibraries(media['library'])
show, season, episode = self.getLibraries(library)
if not show:
return None
@ -172,8 +172,12 @@ class ShowSearcher(Plugin):
else:
return None
# Return show title if we aren't including the identifier
if not include_identifier:
return title
# Add the identifier to search title
identifier = fireEvent('library.identifier', media['library'], single = True)
identifier = fireEvent('library.identifier', library, single = True)
# TODO this needs to support other identifier formats
if identifier['season']:

12
couchpotato/core/plugins/matcher/main.py

@ -40,9 +40,19 @@ class Matcher(Plugin):
for match in chain.info[group]:
for ck, cv in match.items():
if ck in tags and simplifyString(cv) in tags[ck]:
if ck not in tags:
continue
if isinstance(cv, basestring) and simplifyString(cv) in tags[ck]:
found_tags.append(ck)
elif isinstance(cv, list):
simple_list = [simplifyString(x) for x in cv]
if simple_list in tags[ck]:
found_tags.append(ck)
log.debug('tags found: %s, required: %s' % (found_tags, tags.keys()))
if set(tags.keys()) == set(found_tags):
return True

4
couchpotato/core/providers/base.py

@ -207,7 +207,9 @@ class YarrProvider(Provider):
self._search(media, quality, results)
# Search possible titles
else:
for title in possibleTitles(fireEvent('searcher.get_search_title', media, single = True)):
media_title = fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
for title in possibleTitles(media_title):
self._searchOnTitle(title, media, quality, results)
return results

4
couchpotato/core/providers/nzb/newznab/main.py

@ -191,7 +191,7 @@ class Movie(MovieProvider, Base):
class Season(SeasonProvider, Base):
def buildUrl(self, media, api_key):
search_title = fireEvent('searcher.get_search_title', media['library']['root_library'])
search_title = fireEvent('searcher.get_search_title', media['library'])
identifier = fireEvent('library.identifier', media['library'])
query = tryUrlencode({
@ -206,7 +206,7 @@ class Season(SeasonProvider, Base):
class Episode(EpisodeProvider, Base):
def buildUrl(self, media, api_key):
search_title = fireEvent('searcher.get_search_title', media['library']['root_library'])
search_title = fireEvent('searcher.get_search_title', media['library'])
identifier = fireEvent('library.identifier', media['library'])
query = tryUrlencode({

4
couchpotato/core/providers/torrent/sceneaccess/main.py

@ -122,7 +122,7 @@ class Season(SeasonProvider, Base):
]
def buildUrl(self, media, quality):
return self._buildUrl(fireEvent('searcher.get_search_title', media['library']['root_library']), quality['identifier'])
return self._buildUrl(fireEvent('searcher.get_search_title', media['library']), quality['identifier'])
class Episode(EpisodeProvider, Base):
@ -132,4 +132,4 @@ class Episode(EpisodeProvider, Base):
]
def buildUrl(self, media, quality):
return self._buildUrl(fireEvent('searcher.get_search_title', media['library']['root_library']), quality['identifier'])
return self._buildUrl(fireEvent('searcher.get_search_title', media['library']), quality['identifier'])

2
libs/caper/__init__.py

@ -19,7 +19,7 @@ from caper.parsers.anime import AnimeParser
from caper.parsers.scene import SceneParser
__version_info__ = ('0', '2', '3')
__version_info__ = ('0', '2', '4')
__version_branch__ = 'master'
__version__ = "%s%s" % (

12
libs/caper/helpers.py

@ -51,6 +51,18 @@ def clean_dict(target, remove=None):
return target
def update_dict(a, b):
for key, value in b.items():
if key not in a:
a[key] = value
elif isinstance(a[key], dict) and isinstance(value, dict):
update_dict(a[key], value)
elif isinstance(a[key], list):
a[key].append(value)
else:
a[key] = [a[key], value]
def xrange_six(start, stop=None, step=None):
if stop is not None and step is not None:
if PY3:

7
libs/caper/matcher.py

@ -14,13 +14,16 @@
import re
from logr import Logr
from caper.helpers import is_list_type
from caper.helpers import is_list_type, update_dict
class FragmentMatcher(object):
def __init__(self, pattern_groups):
self.regex = {}
self.construct_patterns(pattern_groups)
def construct_patterns(self, pattern_groups):
for group_name, patterns in pattern_groups:
if group_name not in self.regex:
self.regex[group_name] = []
@ -120,7 +123,7 @@ class FragmentMatcher(object):
match = fragment_pattern.match(cur_fragment.value)
if match:
result.update(match.groupdict())
update_dict(result, match.groupdict())
else:
success = False
break

5
libs/caper/parsers/scene.py

@ -77,9 +77,12 @@ PATTERN_GROUPS = [
'PDTV',
'DSR',
'DVDRiP',
'WEBDL' # TODO support 'WEB.DL' tag
'WEBDL'
]),
# For 'WEB-DL', 'WEB DL', etc...
('(?P<source>WEB)', '(?P<source>DL)'),
(r'(?P<codec>%s)', [
'x264',
'XViD'

2
libs/caper/result.py

@ -95,7 +95,7 @@ class CaperResult(object):
self.chains.append(chain)
for chain in self.chains:
chain.weights.append(chain.num_matched / float(max_matched))
chain.weights.append(chain.num_matched / float(max_matched or chain.num_matched))
chain.finish()
self.chains.sort(key=lambda chain: chain.weight, reverse=True)

Loading…
Cancel
Save