Example #1
0
    def _save_to_patterns(self, metadata, content):
        """ Save content to file expanded from given patterns

        Arguments:
        - `metadata`:
        - `content`:
        """
        file_patterns = self._config.get_string_list('General/lrc-filename',
                                                     DEFAULT_FILE_PATTERNS)
        path_patterns = self._config.get_string_list('General/lrc-path',
                                                     DEFAULT_PATH_PATTERNS)
        for path_pat in path_patterns:
            try:
                path = expand_path(path_pat, metadata)
            except:
                continue
            for file_pat in file_patterns:
                try:
                    filename = expand_file(file_pat, metadata)
                    fullpath = os.path.join(path, filename + '.lrc')
                    uri = osdlyrics.utils.path2uri(fullpath)
                    if save_to_uri(uri, content):
                        return uri
                except osdlyrics.pattern.PatternException:
                    pass
        return ''
Example #2
0
    def _save_to_patterns(self, metadata, content):
        """ Save content to file expanded from given patterns

        Arguments:
        - `metadata`:
        - `content`:
        """
        file_patterns = self._config.get_string_list('General/lrc-filename',
                                                     DEFAULT_FILE_PATTERNS)
        path_patterns = self._config.get_string_list('General/lrc-path',
                                                     DEFAULT_PATH_PATTERNS)
        for path_pat in path_patterns:
            try:
                path = expand_path(path_pat, metadata)
            except osdlyrics.pattern.PatternException:
                continue
            for file_pat in file_patterns:
                try:
                    filename = expand_file(file_pat, metadata)
                except osdlyrics.pattern.PatternException:
                    continue
                fullpath = os.path.join(path, filename + '.lrc')
                uri = osdlyrics.utils.path2uri(fullpath)
                if save_to_uri(uri, content):
                    return uri
        return ''
Example #3
0
 def _expand_patterns(self, metadata):
     file_patterns = self._config.get_string_list("General/lrc-filename", DEFAULT_FILE_PATTERNS)
     path_patterns = self._config.get_string_list("General/lrc-path", DEFAULT_PATH_PATTERNS)
     for path_pat in path_patterns:
         try:
             path = expand_path(path_pat, metadata)
         except:
             continue
         for file_pat in file_patterns:
             try:
                 filename = expand_file(file_pat, metadata)
                 fullpath = os.path.join(path, filename + ".lrc")
                 if os.path.isfile(fullpath):
                     return fullpath
             except osdlyrics.pattern.PatternException:
                 pass
     return None
Example #4
0
 def _expand_patterns(self, metadata):
     file_patterns = self._config.get_string_list('General/lrc-filename',
                                                  DEFAULT_FILE_PATTERNS)
     path_patterns = self._config.get_string_list('General/lrc-path',
                                                  DEFAULT_PATH_PATTERNS)
     for path_pat in path_patterns:
         try:
             path = expand_path(path_pat, metadata)
         except:
             continue
         for file_pat in file_patterns:
             try:
                 filename = expand_file(file_pat, metadata)
                 fullpath = os.path.join(path, filename + '.lrc')
                 if os.path.isfile(fullpath):
                     return fullpath
             except osdlyrics.pattern.PatternException:
                 pass
     return None
Example #5
0
 def _expand_patterns(self, metadata):
     file_patterns = self._config.get_string_list('General/lrc-filename',
                                                  DEFAULT_FILE_PATTERNS)
     path_patterns = self._config.get_string_list('General/lrc-path',
                                                  DEFAULT_PATH_PATTERNS)
     for path_pat in path_patterns:
         try:
             path = expand_path(path_pat, metadata)
         except osdlyrics.pattern.PatternException:
             logger.exception('expand gg')
             continue
         for file_pat in file_patterns:
             try:
                 filename = expand_file(file_pat, metadata)
             except osdlyrics.pattern.PatternException:
                 continue
             fullpath = os.path.join(path, filename + '.lrc')
             if os.path.isfile(fullpath):
                 return fullpath
     return None