introduction
In my love forum, some big guys made a windows interface software that can swipe the number of songs to achieve the purpose of rapid upgrade. It is very cool to use, even if you only need to open the software every day to log in and check in, but I always forget, In order to achieve the goal of being fully automatic, I made a python script that can be run on the server. From now on, I don’t have to worry about it. It will automatically check in and listen to 300 songs every day, and it can be used by multiple accounts (theoretically Up to several hundred), every day will send messages to WeChat to report the progress of the task.
1. General introduction (must see)
Two, three methods of deploying Python projects (must see)
① Cloud function (recommended)
② Local use
③ Server deployment
Three, three methods of deploying API interface (don’t see)
① Fork the project and import from GitHub
② Copy the project directly (recommended)
③ Server deployment
Four, configure account (must see)
5. Demonstration of effects (not to watch)
6. Download URL (must see)
Seven, view the log (may not read)
8. Other matters (must see)
9. Frequently Asked Questions (optional)
10. Project structure (you don't need to look at it)
11. Statement (must see)
1. General introduction
The functions that this project can do are:
- Log in automatically every day and listen to 300 songs
- Automatically push the progress of listening tasks to your WeChat every day
This project is divided into Python client and API interface (server). There are two projects, each with three deployment methods. The simplest way to deploy a Python project is the cloud function method , and the simplest way to deploy an API project is to directly copy the project method.
Building an API by yourself and applying for server sauce are not necessary . If you don’t have it, the project can work. It’s just that the developer feels that it’s safer to build the API by yourself. You don’t know if you use someone else’s API to add a backdoor. Of course, the developer’s API is already public. And all the code is open source, there must be no backdoor, everyone can use it. As for the server sauce, it is to let you know the progress and whether the project has any problems every day, and it is not necessary to add it.
So if you want to use it quickly, you can directly look at the cloud function method of deploying Python projects and the following part, but you don't need to look at deploying API projects.
After you successfully run the project, if you want to learn to build an API interface by yourself, then come back to the API part.
No matter which method is used for deployment, it depends on the part of configuring accounts , which is simple but also very important! ! !
For more information, please see other matters
Two, three ways to deploy Python projects
① Cloud function
The era of national upgrading is here! The project supports cloud functions! ! !
What is a cloud function ? It is that it allows you no server, local computer without downloading Python can also use this program, but also white whore !
It not only solved the deployment troubles of many people, but also gave those friends who had been dismissed the courage to come back, and it could be done in ten minutes .
1. Enter the cloud function
Here is a case of Tencent Cloud's cloud function. If you don’t have one, you can open it for free. Address: https://console.cloud.tencent.com/scf/list-create?rid=1&ns=default
2. New function
The function name is arbitrary, the running environment is Python 3.6 , create a blank function, and then the next step
3. Upload code
Make sure that the environment is python 3.6, and the execution method is changed to:, the index.main
submission method must select the local folder, then clone the Zip package from the GitHub project, unzip it into a folder, and then click this upload to upload the folder, and then click below advanced settings.
4. Advanced Settings
The memory can't be used too much, 64MB is enough, the timeout time is changed to the maximum 900 seconds , and then click Finish at the bottom.
5. Configure Account
Change init.config
the account password and the server sauce key in your own account. If you use multiple accounts, you should also configure it account.json
. After you finish, click Save and Test. If your configuration is correct, wait a few minutes to see the results, and do not refresh the page during this time. The result will be in the self log.
6. Set the timing
Click on the trigger management on the left, and then create a new trigger. The trigger cycle is customized. The expression is when the task is to be done every day. I chose 8:30 in the morning and I can modify it by myself. After filling it out, click Submit. Your daily listening project has been deployed, thank you for using it! !
② Local use
Local deployment requires a computer to download and install and configure Python
1. Download the project
Clone the project to local
git clone https://github.com/ZainCheung/netease-cloud.git
Or fork this project to your warehouse to clone
Or download the ZIP package directly in the project warehouse, these are all possible
2. Installation dependencies
Currently only need to install a dependent
request
, if given the lack of any module running module added to give whatrequirements.txt
in
pip install -r requirements.txt
3. See below for account configuration
4. Start the program
python3
The operating environment required by the program , if not, please download and install the configuration yourself. Before starting the program, you must configure the account first, and then start the program
python main.py
③ Server deployment
It is recommended to use the pagoda panel. There is a Python project manager in the pagoda app store, download and install, and select version 3.0 or higher, and version 3.7.2 is recommended.
1. Download and install the Python project manager
2. New project
The netease-cloud here is the folder of this project. I put it in the /www/wwwroot/ path. It can be seen that I downloaded and installed the 3.7.2 version of the python framework. Select Python, and the startup method is also Python. Start The file selection
main.py
port does not need to be filled, check the installation module dependency, whether you want to boot up and start yourself at will, and then confirm.
3. Determine the operating status
At this time, the project is running, you can go to the path of the project in the folder, find and run.log
view the running log
Remember to configure before deployment, and then deploy
Three, three methods to deploy API interface
It is recommended that novices use automatic hosting, which can build an api interface without programming foundation at all. It is recommended to use the website: https://glitch.com/
This website is foreign and has a great reputation. There are millions of websites hosted on it. It is free to use. The disadvantage is that the speed is not as fast as domestic servers. If there is no access, it will go to sleep after a certain period of time. After a request comes, you need to wait for a few seconds to unfreeze. However, these have no effect on this project, so you can deploy with confidence.
API project address: https://github.com/ZainCheung/netease-cloud-api
The following three methods, the first and the second are the simplest but slow, and require you to have a website account, and the third is fast but requires you to have a server, everyone chooses, but basically if you have a server, you want to build it yourself Yeah, feel free
① Fork the project and import from GitHub
-
Fork this API project to your warehouse
-
Open the website to register and log in, create a new project, choose to import from GitHub, the address is the git address of the project
-
Modify the name of your glitch project, for example: netease-test
-
Then your interface name is "project name.glitch.com": https://netease-test.glitch.me/
-
Visit your interface to see the welcome page and the deployment is successful
Using this method to deploy the website interface has zero cost and is quickly available, and there is no need to worry about environment deployment, operation and maintenance. Of course, it is possible to build it with your own server if you have the conditions.
1. Fork the project
Thanks Star
2. Import the project
2-1. Fill in your git address, the address is in the clone button of your Github project, use https
2-2. Change your project name
2-3. Get API address
or
② Copy project directly
Or you can directly copy this API project to become your project and enter the developer's api server: https://glitch.com/edit/#!/netease-cloud-api Select the one in the upper right corner Remix to Exit
to become your own Project, you can modify the code and customize your domain name.
Get API address
or
③ Server deployment
Deploying to the server, for novices, it is recommended to install the pagoda panel, and then you can perform interface operations in the browser, so that some people do not know the Linux command line.
1. Download PHP
Make sure to download PHP, and the version is not too old.
2. Add a website
Fill in the domain name that you resolved in your domain name operator in advance, it can be a subdomain such as api.xxxxxx.com, write a website remark, and then select the root directory to the downloaded project path, FTP is not created, and the database is not created by default utf -8 is fine, the program type is PHP, the version chooses the downloaded version, and you submit it to run your website.
Run the website
The demo domain name here is test.com, and then enter your website address in the browser, and see the welcome page that means the deployment is successful
Four, configure account
In order to protect account information, all account keys are marked with *, please change to your own account when using
Open the init.config
file and configure
# setting.config(UTF-8)
The first comment is to declare the encoding format, please do not delete the comment
1. Account
[token]
# 网易云音乐账号(手机号/网易邮箱)
account = 150********
# 密码,明文/MD5,建议自己去MD5在线加密网站给密码加密,然后填到下面
# 明文例如:123456abcd
# MD5例如:efa224f8de55cb668cd01edbccdfc8a9
password = bfa834f7de58cb650ca01edb********
token
Store personal account information under the area, account stores NetEase cloud account, password stores password
Note that the type of password input here is related to the md5 switch later, see the introduction later for details
2. Settings
[setting]
# 开关的选项只有 True 和 False
# 打卡网站的网址,如果失效请提issue:https://github.com/ZainCheung/netease-cloud-api/issues/new
api = https://netease-cloud-api.glitch.me/
api refers to the server address that provides the interface. Here is a demo. The source code is also open source. If you have any questions about the project, please check the source code. Project address: ZainCheung/netease-cloud-api
In addition, if you want to quickly have an identical api service and use your own defined domain name, then you can quickly build it yourself according to the above project tutorial
1-2. MD5
# 密码是否需要MD5加密,如果是明文密码一定要打开
# true 需要, 则直接将你的密码(明文)填入password,程序会替你进行加密
# false 不需要, 那就自己计算出密码的MD5,然后填入上面的password内
md5Switch = false
md5 switch, if you will not encrypt md5, then set this switch to true, and fill in your password (plain text) in password, the program will encrypt it for you. If you already know the md5 of the password, set this switch to false and fill md5 in the above password
When making MD5 yourself, it must be 32-bit lowercase! ! !
2-2. Multiple accounts
# 是否开启多账号功能,如果打开将会忽视配置文件里的账号而从account.json中寻找账号信息
# 如果选择使用多账号,请配置好account里的账号和密码,即account和password,而sckey不是必需的,如果为空则不会进行微信推送
# 介于账号安全着想,account.json中的密码必须填写md5加密过的,请不要向他人透露自己的明文密码
peopleSwitch = false
This switch is for those who have multiple accounts or are planning to bring friends to use it. As the note says, if you have multiple accounts and want to use this service, you can turn it on and peopleSwitch
set it to true, then the account in the configuration file It will be ignored by the program, account.json
and the account information in the process will be read directly , and account.json
the configuration will be later.
2-3. WeChat reminder
# Server酱的密匙,不需要推送就留空,密匙的免费申请参考:http://sc.ftqq.com/
sckey = SCU97783T70c13167b4daa422f4d419a765eb4ebb5ebc9********
Server sauce is a service that can push messages to your WeChat, and the content of the message is completely customized. Before using it, you only need to go to the official website, log in with GitHub, scan the code to bind WeChat, and you will get the key. From then on, use Server sauce for free
3. Configure multiple accounts
Open for the first time account.json
, the content will look like this
[
{
"account": "[email protected]",
"password": "10ca5e4c316f81c5d9b56702********",
"sckey": "SCU97783T70c13167b4daa422f4d419a765eb4ebb5ebc9********"
},
{
"account": "150********",
"password": "bfa834f7de58cb650ca01edb********",
"sckey": "SCU97783T70c13167b4daa422f4d419a765eb4ebb5ebc9********"
},
{
"account": "132********",
"password": "f391235b15781c95384cd5bb********",
"sckey": "SCU97783T70c13167b4daa422f4d419a765eb4ebb5ebc9********"
}
]
It can be seen that there is an array file, the members are account objects, and the objects have three attributes, namely account, password, and server key.
Different accounts correspond to different keys. After completing the task of this account, a message reminder will be sent to the WeChat bound to this key. If you leave it blank, you will not be reminded. Please also pay attention to the grammar when you leave it blank. Remember to add double quotes and enumerate A correct case
[
{
"account": "[email protected]",
"password": "10ca5e4c316f81c5d9b56702********",
"sckey": ""
},
]
It can be seen that this sckey
is empty, then no message reminder will be sent after the task is completed, if you are not sure whether it is successful, you can check the log
Five, effect demonstration
You can see 9027 songs before use
After use, it was 9327 songs, which just increased by 300 songs
WeChat reminder
WeChat reminder relies on Server sauce, this is a very nice tool, a personally developed project that is free and open to everyone, you need to log in with GitHub, then bind to WeChat, get your key, and fill in the configuration file of sckey
, or in multiple accounts file account.json
in
The content of the prompt can also be modified main.py
by diyText
yourself. The content in the function around line 143 of the file is the content of the prompt. You can customize the content of the prompt. For example, if you are not a postgraduate party, delete the line for postgraduate entrance examination, and the daily sentence, etc. Wait, if necessary, change as much as you want.
Take a look at the effect:
Six, download address
Python project address: https://github.com/ZainCheung/netease-cloud
api interface project address: https://github.com/ZainCheung/netease-cloud-api
Demo address of api: https://netease-cloud-api.glitch.me/
api online server: https://glitch.com/edit/#!/netease-cloud-api
Seven, view the log
Only local deployment and server deployment will generate log files, and cloud functions will not have this run.log
file. If you need to view logs, you can view the built-in logs of cloud functions.
The log file records the running status of the program. All the records generated during the running of the program will be saved in the log file. When you clone the project for the first time, you will not see the run.log
log file, but will be generated when the program runs for the first time. Take a look at my log on the server:
You can see that I punched in more than one account, as well as my friend’s account. This uses a multi-account configuration. If you have a little girl, you can help her to use it together, or you want to put it like me Use it on the server, then configure it
8. Other matters
1. Server sauce
You must bind WeChat to be effective
Server sauce's official website address: http://sc.ftqq.com/
2. MD5
Choose 32-bit lowercase when making! ! !
"Making" MD5 online: https://tool.chinaz.com/tools/md5.aspx
It is more recommended that you use MD5, because even if others know your MD5, it is difficult to restore your password. Relatively speaking, it is much safer. The original password is hidden when you make MD5. Only you know the password.
3. Modify the number of listening songs
If your level is relatively high, and use this to find that you have not listened to 300 songs every time, then you can modify the number of punches in the program main.py
's start
function (about 165 lines), change 3 to a larger value, for example, change to 6 to punch 6 Times
for i in range(1,3):
If you think the clocking speed is slow, you can modify the sleep time, 30 seconds to 10 seconds, etc., please debug by yourself
time.sleep(30)
4. Availability
Some people may say that it is not enough to directly use web pages or computer programs to check in every day, so why bother with scripts? Yes, the same effect can be achieved by using websites and programs, but I am lazy and always forget things, so I let it be completely automated. Maybe many people are willing to toss like me, and then they can Sit back and enjoy it once and for all, just wait for WeChat reminders every day.
5. Original intention
I have been using NetEase Cloud for a long time and I have listened to a lot of songs, but I always listen to repeated songs, and the repeated songs are not included in the level, so I still want to upgrade.
Nine, common problems
1. Make sure that there is no problem with your account and password, but you are always prompted to check your account and password.
Answer: It is very likely that the current API is not available. The default API is used by many people, and most of them are used in a period of time, which causes the platform to fail to respond. It is a foreign station and the speed is relatively slow. You can do tasks separately. In the afternoon and evening, it is okay, otherwise the API will be squeezed out. It is recommended that you build your own API, so that your own access speed will be much faster.
After deploying the API, remember to change the api address to the address you deployed in the init.config file , for example, your domain name is api.test.com or api.glitch.me, etc.
2. The API has been changed, or an error is reported to check the account password?
Answer: If you are sure that the API can be used, but there is still a problem with the account and password, please check whether the account and password of the configuration file and md5Switch are correct . The MD5 of the password must be 32-bit lowercase . Someone has made a mistake because of not paying attention to this. Up.
And in the init.config file, you need to change the api address to the address you deployed.
3. After the check-in is completed, why does the cumulative play of songs not increase or the increase is small?
Answer: The number of songs you listened to will not be updated immediately after the check-in is completed. It is recommended to wait for half an hour or more. Due to official counting rules, only songs that have never been heard are counted in the total. So if your playback volume is originally It is very high. It is recommended to increase the number of clock-in cycles. For the tutorial, see the third item of other matters.
4. The home page of the API built by the server can be opened, but there is no response when I click to check?
Answer: The API must be deployed with PHP. If it is purely static, it has no effect. It is recommended that novices or novices use the first two deployment methods, and those who have the ability to use the third.
5. What should I do if I report an error using multiple accounts?
Answer: After making sure that there is no problem with other configurations, check whether account.json
the format inside is correct, there must be a comma between the account number and the account number. Refer to the case in the project for the specific format.
6. Will using this affect my listening style?
Answer: The songs you play come from your daily recommended playlist, which does not affect.
7. Is it safe to use this my account?
Answer: Technically speaking, whether the account password filled in the configuration file is encrypted by itself or the program is encrypted (MD5 is not actually encrypted, but a digest algorithm to prevent file information from being tampered with), the API interface finally receives All of them are MD5. Assuming that you are using an API that you can find on the Internet, even if someone else changes the code and saves your account information, and you want to brute force through the rainbow table, it will take a lot of effort and you can only get a simple password. Hacks of the great god level may have no pressure, but it is not rare for other great gods to do this, so there is basically no problem with safety.
8. Other errors
{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“module ‘index’ has no attribute ‘main_handler’”}
Answer: This is an error reported through cloud function deployment. The reason is that the execution method has not been changed. Please see the picture content in the section on cloud function deployment.
The netease-cloud-master/index.py file cannot be found in the folder you selected
Answer: Go to GitHub again to download the latest project.
There are other questions that can be raised on GitHub or in the My Love post. You can take a screenshot or copy the error message when you encounter a program error.
10. Project structure
|-- 项目文件夹
|-- LICENSE
|-- README.md
|-- account.json
|-- init.config
|-- main.py
|-- requirements.txt
|-- run.log
LICENSE
: Open source license
README.md
: Project Readme
account.json
: Account to store files
init.config
: Configuration file
main.py
: Main program
requirements.txt
: Dependency list
run.log
: Run log
11. Statement
Please do not ask me to hang up an account. If you use my api, please use the md5 digest password. All scripts and software in this project are only used for personal learning, development and testing. The 网易云
copyright of all related words belongs to NetEase, and should not be used for commercial or illegal purposes. If a legal dispute arises, it has nothing to do with me.
The code word is not easy, please encourage me (hint)! ! !
GitHub is also very grateful to your little star. Your affirmation is your greatest encouragement, and then you will be motivated to make more works!