Last active
April 18, 2017 11:05
-
-
Save kamikat/e1560e936da1a4294afd7c5678ed5ebc to your computer and use it in GitHub Desktop.
从 fid 计算网易云音乐文件的 CDN 地址
This file contains hidden or 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
| #!/usr/bin/env python2 | |
| import argparse | |
| import md5 | |
| from base64 import urlsafe_b64encode as b64enc | |
| parser = argparse.ArgumentParser(description='convert fid to audio file url') | |
| parser.add_argument('fid', action='store', help='fid') | |
| args = parser.parse_args() | |
| def encrypt(data): | |
| return ''.join([ chr(ord(a) ^ ord(b)) for a, b in zip(data, "3go8&$8*3*3h0k(2)2" * (len(data) / 18 + 1)) ]) | |
| digest = md5.new(encrypt(args.fid)).digest() | |
| print "http://m%d.music.126.net/%s/%s.mp3" % (2, b64enc(digest), args.fid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment