3Scraper for http://newlyrics.gomtv.com/
15from lib.audiofile
import AudioFile
22GOM_URL =
'http://newlyrics.gomtv.com/cgi-bin/lyrics.cgi?cmd=find_get_lyrics&file_key=%s&title=%s&artist=%s&from=gomaudio_local'
25 nfkd_data = unicodedata.normalize(
'NFKD', data)
26 return u"".join([c
for c
in nfkd_data
if not unicodedata.combining(c)])
31 privide Gom specific function, such as key
from mp3
37 buf = musf.ReadAudioStream(100*1024)
49 s,ms = divmod(msec/10,100)
60 log(
'%s: searching lyrics for %s - %s' % (__title__, song.artist, song.title), debug=self.
DEBUG)
61 lyrics = Lyrics(settings=self.
settings)
63 lyrics.source = __title__
67 ext = os.path.splitext(song.filepath)[1].lower()
68 sup_ext = [
'.mp3',
'.ogg',
'.wma',
'.flac',
'.ape',
'.wav']
69 if ext
in sup_ext
and key ==
None:
70 key = gomClient.GetKeyFromFile(song.filepath)
73 url = GOM_URL %(key, urllib.parse.quote(
remove_accents(song.title).encode(
'euc-kr')), urllib.parse.quote(
remove_accents(song.artist).encode(
'euc-kr')))
74 response = requests.get(url, timeout=10)
75 response.encoding =
'euc-kr'
78 log(
'%s: %s::%s (%d) [%s]' % (
79 __title__, self.__class__.__name__,
80 sys.exc_info()[2].tb_frame.f_code.co_name,
81 sys.exc_info()[2].tb_lineno,
85 if Page[:Page.find(
'>')+1] !=
'<lyrics_reply result="0">':
87 syncs = re.compile(
'<sync start="(\d+)">([^<]*)</sync>').findall(Page)
89 lyrline.append(
'[ti:%s]' %song.title)
90 lyrline.append(
'[ar:%s]' %song.artist)
93 t =
'%02d:%02d.%02d' % gomClient.mSecConv(int(sync[0]))
96 s = sync[1].replace(
''',
"'").replace(
'"',
'"')
97 lyrline.append(
'[%s]%s' %(t,s))
100 lyrics.lyrics =
'\n'.join(lyrline)
def __init__(self, *args, **kwargs)
def get_lyrics(self, song, key=None, ext=None)
None log(str msg, int level=LOGDEBUG)