提交 3526172d 编写于 作者: ZainCheung's avatar ZainCheung

修复云函数

上级 19eecf44
#coding:utf-8
'''
@author: ZainCheung
@LastEditors: ZainCheung
@description:网易云音乐全自动每日打卡云函数版
@Date: 2020-06-25 14:28:48
@LastEditTime: 2020-09-01 18:20:00
'''
from configparser import ConfigParser
from threading import Timer
import requests
import random
import hashlib
import datetime
import time
import json
import logging
import math
#coding:utf-8
'''
@author: ZainCheung
@LastEditors: ZainCheung
@description:网易云音乐全自动每日打卡云函数版
@Date: 2020-06-25 14:28:48
@LastEditTime: 2020-09-01 18:20:00
'''
from configparser import ConfigParser
from threading import Timer
import requests
import random
import hashlib
import datetime
import time
import json
import logging
import math
logger = logging.getLogger()
grade = [10,40,70,130,200,400,1000,3000,8000,20000]
api = ''
logger = logging.getLogger()
grade = [10,40,70,130,200,400,1000,3000,8000,20000]
api = ''
class Task(object):
class Task(object):
'''
对象的构造函数
......@@ -196,11 +196,11 @@
self.log('用户:' + self.name + ' 今日任务已完成')
'''
初始化:读取配置,配置文件为init.config
返回字典类型的配置对象
'''
def init():
'''
初始化:读取配置,配置文件为init.config
返回字典类型的配置对象
'''
def init():
global api # 初始化时设置api
config = ConfigParser()
config.read('init.config', encoding='UTF-8-sig')
......@@ -223,29 +223,29 @@
}
return conf
'''
MD5加密
str:待加密字符
返回加密后的字符
'''
def md5(str):
'''
MD5加密
str:待加密字符
返回加密后的字符
'''
def md5(str):
hl = hashlib.md5()
hl.update(str.encode(encoding='utf-8'))
return hl.hexdigest()
'''
加载Json文件
jsonPath:json文件的名字,例如account.json
'''
def loadJson(jsonPath):
'''
加载Json文件
jsonPath:json文件的名字,例如account.json
'''
def loadJson(jsonPath):
with open(jsonPath,encoding='utf-8') as f:
account = json.load(f)
return account
'''
检查api
'''
def check():
'''
检查api
'''
def check():
url = api + '?do=check'
respones = requests.get(url)
if respones.status_code == 200:
......@@ -253,10 +253,10 @@
else:
logger.error('api测试异常')
'''
任务池
'''
def taskPool():
'''
任务池
'''
def taskPool():
config = init()
check() # 每天对api做一次检查
......@@ -277,8 +277,8 @@
task = Task(config['uin'], config['pwd'], config['sckey'], config['countrycode'])
task.start()
'''
程序的入口
'''
def main(event,content):
'''
程序的入口
'''
def main(event,content):
taskPool()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册