Skip to content

Instantly share code, notes, and snippets.

@hisinsub
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save hisinsub/ceeddf6d48cad5e1543c to your computer and use it in GitHub Desktop.

Select an option

Save hisinsub/ceeddf6d48cad5e1543c to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import hashlib
import urllib2
import xml.dom.minidom as xml
ALSONG_URL = "http://lyrics.alsong.net/alsongwebservice/service1.asmx"
ALSONG_TMPL = '''\
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="ALSongWebServer/Service1Soap" xmlns:ns1="ALSongWebServer" xmlns:ns3="ALSongWebServer/Service1Soap12">
<SOAP-ENV:Body>
<ns1:GetLyric5>
<ns1:stQuery>
<ns1:strChecksum>%s</ns1:strChecksum>
<ns1:strVersion>2.2</ns1:strVersion>
<ns1:strMACAddress />
<ns1:strIPAddress />
</ns1:stQuery>
</ns1:GetLyric5>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'''
file = u"임재범 - 사랑이라서.mp3"
# 이 구간이 문제인데요...
f = open(file, 'rb')
data = f.read(160*1024)
# 첫 160kb 를 어떻게 읽어드리는 지를 잘 모르겠습니다.
m = hashlib.md5()
m.update(data)
strChecksum = m.hexdigest()
print strChecksum
# Make a request string
headers = { 'Content-Type': 'text/xml; charset=utf-8' }
request = urllib2.Request(ALSONG_URL, ALSONG_TMPL % key, headers)
# Print Alsong's response
response = urllib2.urlopen(request)
print response.read()
@sunghwan2789
Copy link
Copy Markdown

일단 ID3가 뭔가, 구조가 어떻게 되나, 공부하면 이해가 빠를듯,,ㅋ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment