Esempio n. 1
0
 def sanitize_imdb_title(string_value, ignore_characters=None):
     # Remove (I), (II), ... from imdb titles (this is added when there are multiple titles with the same name)
     # Example response from imdb: see http://www.imdb.com/find?q=Aftermath&s=tt&mx=20
     string_value = re.sub('^(.+)(\(\w+\))$', r'\1', string_value)
     # Sanitize on ascii level (replaces à by a)
     string_value = unidecode(string_value)
     return utils.sanitize(string_value, ignore_characters)
Esempio n. 2
0
    def skip_show(self, wanted_item_index, title, season=None):
        if not season:
            return PageTemplate(filename='/home/home-skipshow.mako').render(
                wanted_item_index=wanted_item_index, title=title)
        else:
            if not wanted_item_index:
                raise cherrypy.HTTPError(400, 'No wanted_item index supplied')
            if not title:
                raise cherrypy.HTTPError(400, 'No show supplied')
            # Check if season is a number to be sure
            if not season == '00':
                season = text_type(int(season))
            config_season = season
            # Check if already skipped
            title_sanitized = utils.sanitize(title)
            for x in autosubliminal.SKIPSHOW:
                if title_sanitized == utils.sanitize(x):
                    for s in autosubliminal.SKIPSHOW[x].split(','):
                        if s == season or s == '00':
                            utils.add_notification_message(
                                'Already skipped show %s season %s.' %
                                (title, season))
                            redirect('/home')
                    # Not skipped yet, skip all or append season the seasons to skip
                    if season == '00':
                        config_season = '00'
                    else:
                        seasons = autosubliminal.SKIPSHOW[x].split(',')
                        seasons.append(season)
                        config_season = ','.join(sorted(seasons))
            # Skip show
            if subchecker.skip_show(wanted_item_index, season):
                config.write_config_property('skipshow', title, config_season)
                config.apply_skipshow()
                if season == '00':
                    utils.add_notification_message(
                        'Skipped show %s all seasons.' % title)
                else:
                    utils.add_notification_message(
                        'Skipped show %s season %s.' % (title, season))
            else:
                utils.add_notification_message(
                    'Could not skip show! Please check the log file!', 'error')

            redirect('/home')
Esempio n. 3
0
 def _query_api(self, title, year=None, language='en'):
     name = title
     if year:
         name += ' (' + text_type(year) + ')'
     log.info('Querying tvdb api for %s', name)
     # Return a tvdb_api_v2.models.series_search.SeriesSearch object
     # Make sure to convert it to native string before searching (to prevent unicode encoding error)
     series_search = self._client.search_series_by_name(utils.s2n(name),
                                                        language=language)
     for series_search_data in series_search.data:
         if utils.sanitize(
                 series_search_data.series_name) == utils.sanitize(name):
             return series_search_data
         elif series_search_data.aliases:
             # If no match, fallback to aliases (if aliases are available)
             for alias in series_search_data.aliases:
                 if utils.sanitize(alias) == utils.sanitize(name):
                     return series_search_data
         else:
             continue
Esempio n. 4
0
 def skip_movie(self, wanted_item_index, title, year):
     if not wanted_item_index:
         raise cherrypy.HTTPError(400, 'No wanted_item index supplied')
     if not title:
         raise cherrypy.HTTPError(400, 'No title supplied')
     movie = title
     if year:
         movie += ' (' + year + ')'
     # Check if already skipped
     movie_sanitized = utils.sanitize(movie)
     for x in autosubliminal.SKIPMOVIE:
         if movie_sanitized == utils.sanitize(x):
             utils.add_notification_message('Already skipped movie %s.' %
                                            movie)
             redirect('/home')
     # Skip movie
     if subchecker.skip_movie(wanted_item_index):
         config.write_config_property('skipmovie', movie, '00')
         config.apply_skipmovie()
         utils.add_notification_message('Skipped movie %s.' % movie)
     else:
         utils.add_notification_message(
             'Could not skip movie! Please check the log file!', 'error')
     redirect('/home')
Esempio n. 5
0
def test_sanitize():
    assert sanitize('(Mr.-Robot :)') == 'mr robot'