Skip to content

Instantly share code, notes, and snippets.

@kamikat
Last active April 18, 2017 11:05
Show Gist options
  • Select an option

  • Save kamikat/e1560e936da1a4294afd7c5678ed5ebc to your computer and use it in GitHub Desktop.

Select an option

Save kamikat/e1560e936da1a4294afd7c5678ed5ebc to your computer and use it in GitHub Desktop.
从 fid 计算网易云音乐文件的 CDN 地址
#!/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