1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
__author__ = "QCF"
''' 网易云音乐外链转换 网易云音乐歌单信息 '''
import re
def Translate(url): if not (bool(re.match(r'https\://music.163.com/#/playlist\?id\=',url)) or \ bool(re.match(r'https\://music.163.com/#/song\?id\=',url))): END = (-1, '') else: url_class, url_id = re.findall(r'/#/(\w+)\?id\=(\d+)',url)[0] if url_class == "song": END = (url_class, "http://music.163.com/song/media/outer/url?id={}.mp3".format(url_id)) elif url_class == "playlist": END = (url_class, "http://music.163.com/api/playlist/detail?id={}".format(url_id)) else: END = (-1, '') return END
if __name__ == "__main__": while True: url = input("Please input the url of music.163.com(q to exit):\n\t") if url == 'q': break try: url_class, url_real = Translate(url) if url_class == -1: print("[*]Invaid url") print('-'*50) continue elif url_class == "song": print("[*]The song's downloading url is:\n\t{}".format(url_real)) print('-'*50) elif url_class == "playlist": print("[*]The playlist's infomation url is:\n\t{}".format(url_real)) print('-'*50) except Exception as e: print("[*]",e) print('-'*50)
|