Skip to content

Commit

Permalink
use highbit muisc
Browse files Browse the repository at this point in the history
  • Loading branch information
darknessomi committed Mar 25, 2015
1 parent 1768122 commit 6db5f98
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
33 changes: 28 additions & 5 deletions NEMbox/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @Author: omi
# @Date: 2014-08-24 21:51:57
# @Last Modified by: omi
# @Last Modified time: 2015-03-18 02:11:54
# @Last Modified time: 2015-03-25 16:20:11


'''
Expand All @@ -15,6 +15,10 @@
import requests
from bs4 import BeautifulSoup
import logger
import hashlib

default_timeout = 10
log = logger.getLogger(__name__)


# list去重
Expand All @@ -24,9 +28,27 @@ def uniq(arr):
return arr2


default_timeout = 10
def encrypted_id(id):
id = str(id)
byte1 = bytearray('3go8&$8*3*3h0k(2)2')
byte2 = bytearray(id)
byte1_len = len(byte1)
for i in xrange(len(byte2)):
byte2[i] = byte2[i]^byte1[i%byte1_len]
m = hashlib.md5()
m.update(byte2)
result = m.digest().encode('base64')[:-1]
result = result.replace('/', '_')
result = result.replace('+', '-')
return result

def dfsID_from_hml(data):
for i in ['hMusic', 'mMusic', 'lMusic']:
try:
return data[i]['dfsId']
except:
pass

log = logger.getLogger(__name__)


class NetEase:
Expand Down Expand Up @@ -256,8 +278,9 @@ def dig_info(self, data, dig_type):
'artist': [],
'song_name': data[i]['name'],
'album_name': data[i]['album']['name'],
'mp3_url': data[i]['mp3Url']
'mp3_url': 'http://m1.music.126.net/' + encrypted_id(dfsID_from_hml(data[i])) + '/' + str(dfsID_from_hml(data[i])) + '.mp3'
}

if 'artist' in data[i]:
song_info['artist'] = data[i]['artist']
elif 'artists' in data[i]:
Expand Down Expand Up @@ -306,7 +329,7 @@ def dig_info(self, data, dig_type):
'song_name': data['name'],
'artist': data['artists'][0]['name'],
'album_name': 'DJ节目',
'mp3_url': data['mp3Url']
'mp3_url': 'http://m1.music.126.net/' + encrypted_id(dfsID_from_hml(data)) + '/' + str(dfsID_from_hml(data)) + '.mp3'
}
temp = channel_info

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NetEase-MusicBox
高品质网易云音乐命令行版本,简洁优雅,丝般顺滑,基于Python编写。

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.txt)
[![versions](https://img.shields.io/badge/versions%20-%20%200.1.3.4-blue.svg)]() [![platform](http://sdut-zrt.qiniudn.com/ platform - osx | linux -lightgrey.svg)]()
[![versions](https://img.shields.io/badge/versions%20-%20%200.1.4.0-blue.svg)]() [![platform](http://sdut-zrt.qiniudn.com/ platform - osx | linux -lightgrey.svg)]()

![NetEase-MusicBox](http://sdut-zrt.qiniudn.com/687474703a2f2f692e696d6775722e636f6d2f4a35333533764b2e676966.gif)

Expand Down Expand Up @@ -115,6 +115,8 @@ Enjoy it !

### 更新日志

2015-03-25 版本 0.1.4.0 优先使用320kps音源 (感谢chaserhkj反馈)

2015-03-24 版本 0.1.3.4 增加向上/向下移动项目功能 (感谢chaserhkj提交)

2015-03-18 版本 0.1.3.3 修复Ubuntu等系统SSL登录报错问题
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

setup(
name='NetEase-MusicBox',
version='0.1.3.4',
version='0.1.4.0',
packages=find_packages(),

include_package_data=True,
Expand Down

0 comments on commit 6db5f98

Please sign in to comment.