diff --git a/src/api.py b/src/api.py index e5759d97..56d6813b 100644 --- a/src/api.py +++ b/src/api.py @@ -68,7 +68,9 @@ def rawHttpRequest(self, method, action, query=None, urlencoded=None, callback=N # 登录 def login(self, username, password): - action = 'http://music.163.com/api/login/' + if(username[0] == '@'): + return self.phone_login(username, password); + action = 'https://music.163.com/api/login/' data = { 'username': username, 'password': hashlib.md5( password ).hexdigest(), @@ -78,6 +80,19 @@ def login(self, username, password): return self.httpRequest('POST', action, data) except: return {'code': 501} + + # 手机登录 + def phone_login(self, username, password): + action = 'https://music.163.com/api/login/cellphone' + data = { + 'phone': username[1:], + 'password': hashlib.md5( password ).hexdigest(), + 'rememberLogin': 'true' + } + try: + return self.httpRequest('POST', action, data) + except: + return {'code': 501} # 用户歌单 def user_playlist(self, uid, offset=0, limit=100): diff --git a/src/ui.py b/src/ui.py index 43802ffb..1676e15b 100644 --- a/src/ui.py +++ b/src/ui.py @@ -194,7 +194,7 @@ def build_search_menu(self): def build_login(self): curses.noecho() - info = self.get_param('请输入登录信息, e.g: john@163.com 123456') + info = self.get_param('请输入登录信息,手机号登陆请以@打头 e.g: john@163.com 123456 或者 @18600000000 123456') account = info.split(' ') if len(account) != 2: return self.build_login()