示例#1
0
    def find_song_info(self, html):
        ret = True

        pattern = 'og:title" content="(.*) - (.*) Songtext"'

        regex = common.get_matches_by_pattern(html, pattern)
        if regex:
            self.artist = self.sanitize(regex.group(1))
            self.title = self.sanitize(regex.group(2))

        return ret
示例#2
0
    def parse_song_info(self, html):
        pattern = u'<title>(.+?) 歌詞 / .*</title>'
        self.title = common.get_first_group_by_pattern(html, pattern)

        pattern = u"<div class='artists'>歌:(.*) 作詞:(.*) 作曲:(.*)</div>"
        matches = common.get_matches_by_pattern(html, pattern)
        if not matches:
            return False

        self.artist = matches.group(1)
        self.lyricist = matches.group(2)
        self.composer = matches.group(3)

        return True
示例#3
0
    def find_song_info(self, content):
        pattern = 'og:description" content="(.*)"'
        og_desc = common.get_first_group_by_pattern(content, pattern)
        if og_desc:
            pattern = u'(.*?)「(.*?)」'
            matches = common.get_matches_by_pattern(og_desc, pattern)
            if matches:
                artist = matches.group(1)
                artist = artist.replace(u'歌詞サーチ ', '')
                self.artist = artist
                self.title  = matches.group(2)
            else:
                logging.debug('og desc: %s' % (og_desc))

        prefix = '="lyrics_info_text"'
        suffix = '</div>'
        info_text = common.find_string_by_prefix_suffix(content, prefix, suffix, False)
        if not info_text:
            logging.info('Failed to find lyrics info text')
        one_line = info_text.replace('\n', '')

        patterns = {
            'lyricist': u'>作詞</p><p class="info_detail">(.*?)</p>',
            'composer': u'>作曲</p><p class="info_detail">(.*?)</p>',
        }

        for key in patterns:
            pattern = patterns[key]

            value = common.get_first_group_by_pattern(one_line, pattern)
            if value:
                value = common.strip_tags(common.htmlspecialchars_decode(value)).strip()
                setattr(self, key, value)
            else:
                logging.debug('Failed to get %s, pattern: %s' % (key, pattern, ))

        return True