Exemple #1
0
    def findEpisode (self, episode, manualSearch=False):

        nzbResults = generic.NZBProvider.findEpisode(self, episode, manualSearch)

        # if we got some results then use them no matter what.
        # OR
        # return anyway unless we're doing a manual search
        if nzbResults or not manualSearch:
            return nzbResults

        nameList = set(sceneHelpers.allPossibleShowNames(episode.show))
        searchStr = " OR ".join(['^"'+x+' - %dx%02d"'%(episode.season, episode.episode) for x in nameList])

        logger.log("Searching newzbin for string "+searchStr, logger.DEBUG)

        data = self._getRSSData(searchStr)

        results = []

        try:
            responseSoup = etree.ElementTree(etree.XML(data))
            items = responseSoup.getiterator('item')
        except Exception, e:
            logger.log("Error trying to load Newzbin RSS feed: "+str(e), logger.ERROR)
            return results
    def _get_episode_search_strings(self, ep_obj):

        nameList = set(sceneHelpers.allPossibleShowNames(ep_obj.show))
        if not ep_obj.show.is_air_by_date:
            searchStr = " OR ".join(['^"'+x+' - %dx%02d"'%(ep_obj.season, ep_obj.episode) for x in nameList])
        else:
            searchStr = " OR ".join(['^"'+x+' - '+str(ep_obj.airdate)+'"' for x in nameList])
        return [searchStr]
Exemple #3
0
    def _get_episode_search_strings(self, ep_obj):

        nameList = set(sceneHelpers.allPossibleShowNames(ep_obj.show))
        if not ep_obj.show.is_air_by_date:
            searchStr = " OR ".join(['^"'+x+' - %dx%02d"'%(ep_obj.season, ep_obj.episode) for x in nameList])
        else:
            searchStr = " OR ".join(['^"'+x+' - '+str(ep_obj.airdate)+'"' for x in nameList])
        return [searchStr]
Exemple #4
0
    def _test_allPossibleShowNames(self,
                                   name,
                                   tvdbid=0,
                                   tvrname=None,
                                   expected=[]):

        result = sceneHelpers.allPossibleShowNames(Show(name, tvdbid, tvrname))
        self.assertTrue(
            len(set(expected).intersection(set(result))) == len(expected))
 def _test_allPossibleShowNames(self, name, tvdbid=0, tvrname=None, expected=[]):
     
     class Show:
         def __init__(self, name, tvdbid, tvrname):
             self.name = name
             self.tvdbid = tvdbid
             self.tvrname = tvrname
     
     
     result = sceneHelpers.allPossibleShowNames(Show(name, tvdbid, tvrname))
     self.assertTrue(len(set(expected).intersection(set(result))) == len(expected))
    def _get_season_search_strings(self, show, season):

        nameList = set(sceneHelpers.allPossibleShowNames(show))

        if show.is_air_by_date:
            suffix = ''
        else:
            suffix = 'x'
        searchTerms = ['^"'+x+' - '+str(season)+suffix+'"' for x in nameList]
        #searchTerms += ['^"'+x+' - Season '+str(season)+'"' for x in nameList]
        searchStr = " OR ".join(searchTerms)

        searchStr += " -subpack -extras"

        logger.log("Searching newzbin for string "+searchStr, logger.DEBUG)
        
        return [searchStr]
Exemple #7
0
    def _get_season_search_strings(self, show, season):

        nameList = set(sceneHelpers.allPossibleShowNames(show))

        if show.is_air_by_date:
            suffix = ''
        else:
            suffix = 'x'
        searchTerms = ['^"'+x+' - '+str(season)+suffix+'"' for x in nameList]
        #searchTerms += ['^"'+x+' - Season '+str(season)+'"' for x in nameList]
        searchStr = " OR ".join(searchTerms)

        searchStr += " -subpack -extras"

        logger.log("Searching newzbin for string "+searchStr, logger.DEBUG)
        
        return [searchStr]
Exemple #8
0
def isGoodResult(result, show):
	"""
	Use an automatically-created regex to make sure the result actually is the show it claims to be
	"""
	
	showNames = map(sceneHelpers.sanitizeSceneName, sceneHelpers.allPossibleShowNames(show))
	
	for curName in set(showNames):
		curRegex = '^' + re.sub('[\.\-]', '\W+', curName) + '\W+(?:(?:S\d\d)|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx])))'
		logger.log("Checking if show "+result.name+" matches " + curRegex, logger.DEBUG)
		
		match = re.search(curRegex, result.name, re.I)
		
		if match:
			return True
	
	logger.log("Provider gave result "+result.name+" but that doesn't seem like a valid result for "+show.name+" so I'm ignoring it")
	return False
Exemple #9
0
    def findSeasonResults(self, show, season):

        results = {}

        nameList = set(sceneHelpers.allPossibleShowNames(show))

        searchTerms = ['^"'+x+' - '+str(season)+'x"' for x in nameList]
        #searchTerms += ['^"'+x+' - Season '+str(season)+'"' for x in nameList]
        searchStr = " OR ".join(searchTerms)

        searchStr += " -subpack -extras"

        logger.log("Searching newzbin for string "+searchStr, logger.DEBUG)

        data = self._getRSSData(searchStr)

        try:
            responseSoup = etree.ElementTree(etree.XML(data))
            items = responseSoup.getiterator('item')
        except Exception, e:
            logger.log("Error trying to load Newzbin RSS feed: "+str(e), logger.ERROR)
            return results
 def _test_allPossibleShowNames(self, name, tvdbid=0, tvrname=None, expected=[]):
     
     result = sceneHelpers.allPossibleShowNames(Show(name, tvdbid, tvrname))
     self.assertTrue(len(set(expected).intersection(set(result))) == len(expected))