Skip to content

Commit

Permalink
新增国际号码登陆
Browse files Browse the repository at this point in the history
  • Loading branch information
ZainCheung committed Sep 1, 2020
1 parent a079b56 commit b7410f7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
5 changes: 4 additions & 1 deletion docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ account = 150********
# 明文例如:123456abcd
# MD5例如:efa224f8de55cb668cd01edbccdfc8a9
password = bfa834f7de58cb650ca01edb********

# 国家码,用于国外手机号登陆,国内为86
countrycode = 86
```

`token`区域下存放个人账号信息,account存放网易云账号,password存放密码
`token`区域下存放个人账号信息,`account`存放网易云账号,`password`存放密码,`countrycode`为手机号的国家码

!> 注意,这里密码填写类型与后面的md5开关相关联,具体见后面介绍

Expand Down
6 changes: 5 additions & 1 deletion docs/document/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ MD5例如:efa224f8de55cb668cd01edbccdfc8a9

**接口地址 :** `/?do=login`

**可选参数 :** `r`: 0至1的随机数,例如`0.20246864764818318`
**可选参数 :**

`countrycode`: 国家码,用于国外手机号登陆,例如美国传入:`1`,默认国内为86

`r`: 0至1的随机数,例如`0.20246864764818318`

**调用例子 :** `/?do=login&uin=xxx&pwd=yyy`

Expand Down
21 changes: 11 additions & 10 deletions index.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#coding:utf-8
'''
@author: ZainCheung
@LastEditors: Daphel
@LastEditors: ZainCheung
@description:网易云音乐全自动每日打卡云函数版
@Date: 2020-06-25 14:28:48
@LastEditTime: 2020-08-20 10:16:15
@LastEditTime: 2020-09-01 18:20:00
'''
from configparser import ConfigParser
from threading import Timer
Expand All @@ -26,9 +26,10 @@ class Task(object):
'''
对象的构造函数
'''
def __init__(self, uin, pwd, sckey):
def __init__(self, uin, pwd, sckey, countrycode=86):
self.uin = uin
self.pwd = pwd
self.countrycode = countrycode
self.sckey = sckey

'''
Expand All @@ -45,7 +46,7 @@ def getResponse(self, url, postJson):
登录
'''
def login(self):
data = {"uin":self.uin,"pwd":self.pwd,"r":random.random()}
data = {"uin":self.uin,"pwd":self.pwd,"countrycode":self.countrycode,"r":random.random()}
if '@' in self.uin:
url = api + '?do=email'
else:
Expand Down Expand Up @@ -114,9 +115,9 @@ def server(self):
content:消息的内容,支持MarkDown格式
'''
def diyText(self):
today = datetime.date.today()
kaoyan_day = datetime.date(2020,12,21) #2021考研党的末日
date = (kaoyan_day - today).days
# today = datetime.date.today()
# kaoyan_day = datetime.date(2020,12,21) #2021考研党的末日
# date = (kaoyan_day - today).days
one = requests.get('https://api.qinor.cn/soup/').text # 每日一句的api
for count in grade:
if self.level < 10:
Expand Down Expand Up @@ -149,8 +150,6 @@ def diyText(self):
"------\n"
"#### 打卡日志\n" + self.dakaSongs_list + "\n\n"
"------\n"
"#### 考研倒计时\n- 距考研还有" + str(date) + "天,主人要加油学习啊!\n\n"
"------\n"
"#### 今日一句\n- " + one + "\n\n")

'''
Expand Down Expand Up @@ -207,6 +206,7 @@ def init():
config.read('init.config', encoding='UTF-8-sig')
uin = config['token']['account']
pwd = config['token']['password']
countrycode = config['token']['countrycode']
api = config['setting']['api']
md5Switch = config.getboolean('setting','md5Switch')
peopleSwitch = config.getboolean('setting','peopleSwitch')
Expand All @@ -215,6 +215,7 @@ def init():
conf = {
'uin': uin,
'pwd': pwd,
'countrycode': countrycode,
'api': api,
'md5Switch': md5Switch,
'peopleSwitch':peopleSwitch,
Expand Down Expand Up @@ -273,7 +274,7 @@ def taskPool():
if config['md5Switch'] is True:
logger.info('MD5开关已打开,即将开始为你加密,密码不会上传至服务器,请知悉')
config['pwd'] = md5(config['pwd'])
task = Task(config['uin'], config['pwd'], config['sckey'])
task = Task(config['uin'], config['pwd'], config['sckey'], config['countrycode'])
task.start()

'''
Expand Down
5 changes: 4 additions & 1 deletion init.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ account = 150********
# MD5例如:efa224f8de55cb668cd01edbccdfc8a9
password = bfa834f7de58cb650ca01edb********

# 国家码,用于国外手机号登陆,国内为86
countrycode = 86


[setting]
# 开关的选项只有 True 和 False
# 打卡网站的网址,如果失效请提issue:https://github.com/ZainCheung/netease-cloud-api/issues/new
# 接口API,如果失效请自行部署,地址:https://github.com/ZainCheung/netease-cloud-api
api = https://netease-cloud-api.glitch.me/

# 密码是否需要MD5加密,如果是明文密码一定要打开
Expand Down
23 changes: 12 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#coding:utf-8
'''
@author: ZainCheung
@LastEditors: Daphel
@LastEditors: ZainCheung
@description:网易云音乐全自动每日打卡300首歌升级账号等级,使用前请先到init.config文件配置
@Date: 2020-06-25 14:28:48
@LastEditTime: 2020-08-20 09:50:18
@LastEditTime: 2020-09-01 18:20:00
'''
from configparser import ConfigParser
from threading import Timer
Expand All @@ -23,7 +23,7 @@
'''
os.chdir(os.path.dirname(os.path.abspath(__file__)))
logFile = open("run.log", encoding="utf-8", mode="a")
logging.basicConfig(stream=logFile, format="%(asctime)s %(name)s:%(levelname)s:%(message)s", datefmt="%Y-%m-%d %H:%M:%S", level=logging.INFO)
logging.basicConfig(stream=logFile, format="%(asctime)s %(levelname)s:%(message)s", datefmt="%Y-%m-%d %H:%M:%S", level=logging.INFO)
grade = [10,40,70,130,200,400,1000,3000,8000,20000]
api = ''

Expand All @@ -32,9 +32,10 @@ class Task(object):
'''
对象的构造函数
'''
def __init__(self, uin, pwd, sckey):
def __init__(self, uin, pwd, sckey, countrycode=86):
self.uin = uin
self.pwd = pwd
self.countrycode = countrycode
self.sckey = sckey

'''
Expand All @@ -51,7 +52,7 @@ def getResponse(self, url, postJson):
登录
'''
def login(self):
data = {"uin":self.uin,"pwd":self.pwd,"r":random.random()}
data = {"uin":self.uin,"pwd":self.pwd,"countrycode":self.countrycode,"r":random.random()}
if '@' in self.uin:
url = api + '?do=email'
else:
Expand Down Expand Up @@ -126,9 +127,9 @@ def server(self):
content:消息的内容,支持MarkDown格式
'''
def diyText(self):
today = datetime.date.today()
kaoyan_day = datetime.date(2020,12,21) #2021考研党的末日
date = (kaoyan_day - today).days
# today = datetime.date.today()
# kaoyan_day = datetime.date(2020,12,21) #2021考研党的末日
# date = (kaoyan_day - today).days
one = requests.get('https://api.qinor.cn/soup/').text # 每日一句的api
for count in grade:
if self.level < 10:
Expand Down Expand Up @@ -163,8 +164,6 @@ def diyText(self):
"------\n"
"#### 打卡日志\n" + self.dakaSongs_list + "\n\n"
"------\n"
"#### 考研倒计时\n- 距考研还有" + str(date) + "天,主人要加油学习啊!\n\n"
"------\n"
"#### 今日一句\n- " + one + "\n\n")

'''
Expand Down Expand Up @@ -228,6 +227,7 @@ def init():
config.read('init.config', encoding='UTF-8-sig')
uin = config['token']['account']
pwd = config['token']['password']
countrycode = config['token']['countrycode']
api = config['setting']['api']
md5Switch = config.getboolean('setting','md5Switch')
peopleSwitch = config.getboolean('setting','peopleSwitch')
Expand All @@ -237,6 +237,7 @@ def init():
conf = {
'uin': uin,
'pwd': pwd,
'countrycode': countrycode,
'api': api,
'md5Switch': md5Switch,
'peopleSwitch':peopleSwitch,
Expand Down Expand Up @@ -302,7 +303,7 @@ def taskPool():
print('MD5开关已打开,即将开始为你加密,密码不会上传至服务器,请知悉')
logging.info('MD5开关已打开,即将开始为你加密,密码不会上传至服务器,请知悉')
config['pwd'] = md5(config['pwd'])
task = Task(config['uin'], config['pwd'], config['sckey'])
task = Task(config['uin'], config['pwd'], config['sckey'], config['countrycode'])
task.start()

'''
Expand Down
Empty file added run.log
Empty file.

0 comments on commit b7410f7

Please sign in to comment.