Skip to content

Commit

Permalink
Add 22 top list
Browse files Browse the repository at this point in the history
  • Loading branch information
darknessomi committed Mar 30, 2015
1 parent 7dea16f commit c08297f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
40 changes: 36 additions & 4 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-25 17:32:54
# @Last Modified time: 2015-03-30 23:36:21


'''
Expand All @@ -18,6 +18,32 @@
import hashlib
import random

# 歌曲榜单地址
top_list_all={
0:['云音乐新歌榜','/discover/toplist?id=3779629'],
1:['云音乐热歌榜','/discover/toplist?id=3778678'],
2:['网易原创歌曲榜','/discover/toplist?id=2884035'],
3:['云音乐飙升榜','/discover/toplist?id=19723756'],
4:['云音乐电音榜','/discover/toplist?id=10520166'],
5:['UK排行榜周榜','/discover/toplist?id=180106'],
6:['美国Billboard周榜','/discover/toplist?id=60198'],
7:['KTV嗨榜','/discover/toplist?id=21845217'],
8:['iTunes榜','/discover/toplist?id=11641012'],
9:['Hit FM Top榜','/discover/toplist?id=120001'],
10:['日本Oricon周榜','/discover/toplist?id=60131'],
11:['韩国Melon排行榜周榜','/discover/toplist?id=3733003'],
12:['韩国Mnet排行榜周榜','/discover/toplist?id=60255'],
13:['韩国Melon原声周榜','/discover/toplist?id=46772709'],
14:['中国TOP排行榜(港台榜)','/discover/toplist?id=112504'],
15:['中国TOP排行榜(内地榜)','/discover/toplist?id=64016'],
16:['香港电台中文歌曲龙虎榜','/discover/toplist?id=10169002'],
17:['华语金曲榜','/discover/toplist?id=4395559'],
18:['中国嘻哈榜','/discover/toplist?id=1899724'],
19:['法国 NRJ EuroHot 30周榜','/discover/toplist?id=27135204'],
20:['台湾Hito排行榜','/discover/toplist?id=112463'],
21:['Beatport全球电子舞曲榜','/discover/toplist?id=3812895']
}

default_timeout = 10

log = logger.getLogger(__name__)
Expand Down Expand Up @@ -79,6 +105,12 @@ def __init__(self):
}
self.playlist_class_dict = {}

def return_toplists(self):
temp=[]
for i in range(len(top_list_all)):
temp.append(top_list_all[i][0])
return temp

def httpRequest(self, method, action, query=None, urlencoded=None, callback=None, timeout=None):
connection = json.loads(self.rawHttpRequest(method, action, query, urlencoded, callback, timeout))
return connection
Expand Down Expand Up @@ -198,9 +230,9 @@ def top_artists(self, offset=0, limit=100):
except:
return []

# 热门单曲 http://music.163.com/#/discover/toplist 50
def top_songlist(self, offset=0, limit=100):
action = 'http://music.163.com/discover/toplist'
# 热门单曲 http://music.163.com/discover/toplist?id=
def top_songlist(self,idx=0, offset=0, limit=100):
action = 'http://music.163.com' + top_list_all[idx][1]
try:
connection = requests.get(action, headers=self.header, timeout=default_timeout)
connection.encoding = 'UTF-8'
Expand Down
14 changes: 10 additions & 4 deletions NEMbox/menu.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-01-30 18:06:12
# @Last Modified time: 2015-03-30 23:36:21


'''
Expand Down Expand Up @@ -412,6 +412,13 @@ def dispatch_enter(self, idx):
log.debug(self.datalist)
self.title += ' > ' + data

# 歌曲榜单
elif datatype == 'toplists':
songs = netease.top_songlist(idx)
self.title += ' > ' + self.datalist[idx]
self.datalist = netease.dig_info(songs, 'songs')
self.datatype = 'songs'

# 搜索菜单
elif datatype == 'search':
ui = self.ui
Expand Down Expand Up @@ -446,10 +453,9 @@ def choice_channel(self, idx):
# 排行榜
netease = self.netease
if idx == 0:
songs = netease.top_songlist()
self.datalist = netease.dig_info(songs, 'songs')
self.datalist=netease.return_toplists()
self.title += ' > 排行榜'
self.datatype = 'songs'
self.datatype = 'toplists'

# 艺术家
elif idx == 1:
Expand Down
11 changes: 10 additions & 1 deletion NEMbox/ui.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-01-30 18:02:34
# @Last Modified time: 2015-03-30 23:36:21


'''
Expand Down Expand Up @@ -133,6 +133,15 @@ def build_menu(self, datatype, title, datalist, offset, index, step):
str(i) + '. ' + datalist[i]['playlists_name'] + self.space + datalist[i][
'creator_name'])


elif datatype == 'toplists':
for i in range(offset, min(len(datalist), offset + step)):
if i == index:
self.screen.addstr(i - offset + 8, self.indented_startcol, '-> ' + str(i) + '. ' + datalist[i], curses.color_pair(2))
else:
self.screen.addstr(i - offset + 8, self.startcol, str(i) + '. ' + datalist[i])


elif datatype == 'playlist_classes' or datatype == 'playlist_class_detail':
for i in range(offset, min(len(datalist), offset + step)):
if i == index:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NetEase-MusicBox

[![](https://img.shields.io/travis/joyent/node/v0.6.svg)]()
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.txt)
[![versions](https://img.shields.io/badge/versions%20-%20%200.1.5.1-blue.svg)]()
[![versions](https://img.shields.io/badge/versions%20-%20%200.1.5.2-blue.svg)]()
[![platform](https://img.shields.io/badge/python-2.7-green.svg)]()

![NetEase-MusicBox](http://sdut-zrt.qiniudn.com/687474703a2f2f692e696d6775722e636f6d2f4a35333533764b2e676966.gif)
Expand All @@ -17,7 +17,7 @@ NetEase-MusicBox

1. 320kbps的高品质音乐(播放时显示HD标记)
2. 歌曲,艺术家,专辑检索
3. 网易热门歌曲排行榜
3. 网易22个歌曲排行榜
4. 网易新碟推荐
5. 网易精选歌单
6. 网易DJ节目
Expand Down Expand Up @@ -118,6 +118,8 @@ Enjoy it !

### 更新日志

2015-03-31 版本 0.1.5.2 新增22个歌曲排行榜

2015-03-30 版本 0.1.5.1 新增一键 P 回到历史播放列表功能 (感谢Catofes提交)

2015-03-27 版本 0.1.5.0 使用全新动态UI绘制方法,提高稳定性 (感谢Will Jiang提交)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @Author: omi
# @Date: 2014-08-24 22:08:33
# @Last Modified by: omi
# @Last Modified time: 2014-08-25 18:02:34
# @Last Modified time: 2015-03-30 23:36:21

'''
__ ___________________________________________
Expand Down Expand Up @@ -39,7 +39,7 @@

setup(
name='NetEase-MusicBox',
version='0.1.5.1',
version='0.1.5.2',
packages=find_packages(),

include_package_data=True,
Expand Down

0 comments on commit c08297f

Please sign in to comment.