Skip to content

Instantly share code, notes, and snippets.

@Jeswang
Created February 16, 2012 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Jeswang/1844416 to your computer and use it in GitHub Desktop.
Save Jeswang/1844416 to your computer and use it in GitHub Desktop.
Download MV from 音悦台
# coding=utf-8
from BeautifulSoup import *
import sys, httplib
import re
import os
import urllib,urllib2
def getMVName(url):
c=urllib2.urlopen(url)
soup=BeautifulSoup(c.read())
name=soup.find('h1', id='videoTitle').contents[0]
print name
name = urllib.unquote(name)
return name
if __name__ == '__main__':
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
print '输入MV所在网址'
url = raw_input()
if url[0:7] != 'http://':
url = 'http://' + url
print '正在获取名字...'
mvName = getMVName(url)
print mvName
videoId = url[31:]
#print videoId
print '正在获取MV的下载地址'
params = urllib.urlencode({'flex': 'true', 'videoId': videoId})
con = httplib.HTTPConnection("www.yinyuetai.com")
con.request("POST", "/player/get-video-info", params, headers)
r = con.getresponse()
if r.status == 200:
print "Success", "\n"
else:
print "Failed", "\n"
exit()
result = r.read()
con.close()
p=re.compile('http://h.+?.flv')
urls = list(set(p.findall(result)))
print urls
wgetCommand = u'wget ' + urls[0] + u' -O "' + mvName + u'.flv"'
#print wgetCommand
os.system(wgetCommand.encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment