-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edit /pixiv and /miaow (Netease) bot_sendPhoto()
- Loading branch information
Showing
9 changed files
with
466,791 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import os | ||
import json | ||
import time | ||
import hashlib | ||
import random | ||
import base64 | ||
import binascii | ||
import requests | ||
from Crypto.Cipher import AES | ||
|
||
header = { | ||
'Accept': '*/*', | ||
'Accept-Encoding': 'gzip,deflate,sdch', | ||
'Accept-Language': 'zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4', | ||
'Connection': 'keep-alive', | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'Host': 'music.163.com', | ||
'Referer': 'http://music.163.com/search/', | ||
'User-Agent': | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' # NOQA | ||
} | ||
modulus = ('00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7' | ||
'b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280' | ||
'104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932' | ||
'575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b' | ||
'3ece0462db0a22b8e7') | ||
nonce = '0CoJUm6Qyw8W8jud' | ||
pubKey = '010001' | ||
proxies = { | ||
'http': 'socks5://127.0.0.1:1080', | ||
'https': 'socks5://127.0.0.1:1080' | ||
} | ||
def songs_detail_new_api(music_ids, bit_rate=320000): | ||
action = 'http://music.163.com/weapi/song/enhance/player/url?csrf_token=' # NOQA | ||
#self.session.cookies.load() | ||
#csrf = '' | ||
#for cookie in self.session.cookies: | ||
# if cookie.name == '__csrf': | ||
# csrf = cookie.value | ||
#if csrf == '': | ||
# notify('You Need Login', 1) | ||
#action += csrf | ||
data = {'ids': music_ids, 'br': bit_rate, 'csrf_token': ""} | ||
connection = requests.post(action, | ||
data = encrypted_request(data), | ||
headers = header, | ||
proxies = proxies) | ||
result = json.loads(connection.text) | ||
return result['data'] | ||
|
||
def encrypted_id(id): | ||
magic = bytearray('3go8&$8*3*3h0k(2)2', 'u8') | ||
song_id = bytearray(id, 'u8') | ||
magic_len = len(magic) | ||
for i, sid in enumerate(song_id): | ||
song_id[i] = sid ^ magic[i % magic_len] | ||
m = hashlib.md5(song_id) | ||
result = m.digest() | ||
result = base64.b64encode(result) | ||
result = result.replace(b'/', b'_') | ||
result = result.replace(b'+', b'-') | ||
return result.decode('utf-8') | ||
|
||
|
||
# 登录加密算法, 基于https://github.com/stkevintan/nw_musicbox脚本实现 | ||
def encrypted_request(text): | ||
text = json.dumps(text) | ||
secKey = createSecretKey(16) | ||
encText = aesEncrypt(aesEncrypt(text, nonce), secKey) | ||
encSecKey = rsaEncrypt(secKey, pubKey, modulus) | ||
data = {'params': encText, 'encSecKey': encSecKey} | ||
return data | ||
|
||
|
||
def aesEncrypt(text, secKey): | ||
pad = 16 - len(text) % 16 | ||
text = text + chr(pad) * pad | ||
encryptor = AES.new(secKey, 2, '0102030405060708') | ||
ciphertext = encryptor.encrypt(text) | ||
ciphertext = base64.b64encode(ciphertext).decode('utf-8') | ||
return ciphertext | ||
|
||
|
||
def rsaEncrypt(text, pubKey, modulus): | ||
text = text[::-1] | ||
rs = pow(int(binascii.hexlify(text), 16), int(pubKey, 16), int(modulus, 16)) | ||
return format(rs, 'x').zfill(256) | ||
|
||
|
||
def createSecretKey(size): | ||
return binascii.hexlify(os.urandom(size))[:16] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
import json,sys,time,requests,os | ||
|
||
api_addr="https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury" | ||
ua='User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36' | ||
|
||
header={ | ||
'Cookie':'BAIDUID=', | ||
'User-Agent':ua | ||
} | ||
def mstimestamp(): | ||
return int(round(time.time() * 1000)) | ||
|
||
def tracking(number,retry=0): | ||
try: | ||
payload = { | ||
'cb': '', | ||
'appid': 4001, | ||
'nu': number, | ||
'vcode' : '', | ||
'token' : '', | ||
'_' : mstimestamp() | ||
} | ||
raw_json = requests.get(api_addr,params=payload,headers=header) | ||
track=json.loads(raw_json.text) | ||
if(retry>=5): | ||
return "查询失败!错误:-5" | ||
elif(track['status']=='0'): | ||
lst = [] | ||
for i in range(len(track['data']['info']['context']) - 1): | ||
timeArray = time.localtime(int(track['data']['info']['context'][i]['time'])) | ||
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) | ||
lst.append(otherStyleTime + ', ' + track['data']['info']['context'][i]['desc']) | ||
return '\n'.join(lst) | ||
elif(track['status']=='-5'): | ||
if(len(raw_json.cookies)>=1): | ||
header['Cookie']="BAIDUID=%s"%(raw_json.cookies['BAIDUID']) | ||
return tracking(number,retry+1) | ||
else: | ||
return track['msg'] | ||
except ValueError: | ||
return "查询接口爆炸" | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.