Skip to content

Commit

Permalink
[Add] future requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas committed Sep 11, 2016
1 parent 3c7e2cc commit 6031310
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 28 deletions.
1 change: 1 addition & 0 deletions NEMbox/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def geturl_new_api(song):


class NetEase(object):

def __init__(self):
self.header = {
'Accept': '*/*',
Expand Down
4 changes: 3 additions & 1 deletion NEMbox/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


class Cache(Singleton):

def __init__(self):
if hasattr(self, '_init'):
return
Expand All @@ -43,7 +44,8 @@ def __init__(self):
self.aria2c_parameters = self.config.get_item('aria2c_parameters')

def _is_cache_successful(self):
succ = lambda x: x and x.returncode == 0
def succ(x):
return x and x.returncode == 0
return succ(self.aria2c) or succ(self.wget)

def _kill_all(self):
Expand Down
1 change: 1 addition & 0 deletions NEMbox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


class Config(Singleton):

def __init__(self):
if hasattr(self, '_init'):
return
Expand Down
1 change: 1 addition & 0 deletions NEMbox/osdlyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
if pyqt_activity:

class Lyrics(QtGui.QWidget):

def __init__(self):
super(Lyrics, self).__init__()
self.__dbusAdaptor = LyricsAdapter(self)
Expand Down
1 change: 1 addition & 0 deletions NEMbox/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@


class Player(object):

def __init__(self):
self.config = Config()
self.ui = Ui()
Expand Down
1 change: 1 addition & 0 deletions NEMbox/scrollstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


class scrollstring(object):

def __init__(self, content, START):
self.content = content # the true content of the string
self.display = content # the displayed string
Expand Down
2 changes: 2 additions & 0 deletions NEMbox/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from builtins import super
from future import standard_library
standard_library.install_aliases()


class Singleton(object):
"""Singleton Class
This is a class to make some class being a Singleton class.
Expand Down
1 change: 1 addition & 0 deletions NEMbox/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


class Storage(Singleton):

def __init__(self):
'''
Database stores every info.
Expand Down
54 changes: 27 additions & 27 deletions NEMbox/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def build_playinfo(self,
self.screen.clrtoeol()
if pause:
self.addstr(1, self.indented_startcol,
'_ _ z Z Z ' + quality, curses.color_pair(3))
'_ _ z Z Z ' + quality, curses.color_pair(3))
else:
self.addstr(1, self.indented_startcol,
'♫ ♪ ♫ ♪ ' + quality, curses.color_pair(3))
'♫ ♪ ♫ ♪ ' + quality, curses.color_pair(3))

self.addstr(
1, min(self.indented_startcol + 18, self.x - 1),
Expand Down Expand Up @@ -206,12 +206,12 @@ def build_process_bar(self, now_playing, total_length, playing_flag,
log.error(e)
pass
self.addstr(4, self.startcol - 2, str(self.now_lyric),
curses.color_pair(3))
curses.color_pair(3))
self.screen.refresh()

def build_loading(self):
self.addstr(7, self.startcol, '享受高品质音乐,loading...',
curses.color_pair(1))
curses.color_pair(1))
self.screen.refresh()

# start is the timestamp of this function being called
Expand All @@ -231,24 +231,24 @@ def build_menu(self, datatype, title, datalist, offset, index, step,
for i in range(offset, min(len(datalist), offset + step)):
if i == index:
self.addstr(i - offset + 9,
self.indented_startcol,
'-> ' + str(i) + '. ' + datalist[i],
curses.color_pair(2))
self.indented_startcol,
'-> ' + str(i) + '. ' + datalist[i],
curses.color_pair(2))
else:
self.addstr(i - offset + 9, self.startcol,
str(i) + '. ' + datalist[i])
str(i) + '. ' + datalist[i])

elif datatype == 'songs' or datatype == 'fmsongs':
iter_range = min(len(datalist), offset + step)
for i in range(offset, iter_range):
# this item is focus
if i == index:
self.addstr(i - offset + 8, 0,
' ' * self.startcol)
' ' * self.startcol)
lead = '-> ' + str(i) + '. '
self.addstr(i - offset + 8,
self.indented_startcol, lead,
curses.color_pair(2))
self.indented_startcol, lead,
curses.color_pair(2))
name = '{}{}{} < {} >'.format(
datalist[i]['song_name'], self.space,
datalist[i]['artist'], datalist[i]['album_name'])
Expand All @@ -267,7 +267,7 @@ def build_menu(self, datatype, title, datalist, offset, index, step,
curses.color_pair(2))
else:
self.addstr(i - offset + 8, 0,
' ' * self.startcol)
' ' * self.startcol)
self.addstr(
i - offset + 8, self.startcol,
'{}. {}{}{} < {} >'.format(
Expand Down Expand Up @@ -337,23 +337,23 @@ def build_menu(self, datatype, title, datalist, offset, index, step,
for i in range(offset, min(len(datalist), offset + step)):
if i == index:
self.addstr(i - offset + 9,
self.indented_startcol,
'-> ' + str(i) + '. ' + datalist[i],
curses.color_pair(2))
self.indented_startcol,
'-> ' + str(i) + '. ' + datalist[i],
curses.color_pair(2))
else:
self.addstr(i - offset + 9, self.startcol,
str(i) + '. ' + datalist[i])
str(i) + '. ' + datalist[i])

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

elif datatype == 'djchannels':
for i in range(offset, min(len(datalist), offset + step)):
Expand All @@ -372,7 +372,7 @@ def build_menu(self, datatype, title, datalist, offset, index, step,
self.screen.clrtobot()
self.screen.timeout(-1)
self.addstr(8, self.startcol, '选择搜索类型:',
curses.color_pair(1))
curses.color_pair(1))
for i in range(offset, min(len(datalist), offset + step)):
if i == index:
self.addstr(
Expand All @@ -381,7 +381,7 @@ def build_menu(self, datatype, title, datalist, offset, index, step,
curses.color_pair(2))
else:
self.addstr(i - offset + 10, self.startcol,
str(i) + '.' + datalist[i - 1])
str(i) + '.' + datalist[i - 1])
self.screen.timeout(100)

elif datatype == 'help':
Expand All @@ -403,9 +403,9 @@ def build_menu(self, datatype, title, datalist, offset, index, step,
self.addstr(
20, 6, 'NetEase-MusicBox 基于Python,所有版权音乐来源于网易,本地不做任何保存')
self.addstr(21, 10,
'按 [G] 到 Github 了解更多信息,帮助改进,或者Star表示支持~~')
'按 [G] 到 Github 了解更多信息,帮助改进,或者Star表示支持~~')
self.addstr(22, self.startcol,
'Build with love to music by omi')
'Build with love to music by omi')

self.screen.refresh()

Expand Down Expand Up @@ -500,7 +500,7 @@ def build_login_bar(self):
self.screen.move(4, 1)
self.screen.clrtobot()
self.addstr(5, self.startcol, '请输入登录信息(支持手机登陆)',
curses.color_pair(1))
curses.color_pair(1))
self.addstr(8, self.startcol, '账号:', curses.color_pair(1))
self.addstr(9, self.startcol, '密码:', curses.color_pair(1))
self.screen.move(8, 24)
Expand All @@ -511,7 +511,7 @@ def build_login_error(self):
self.screen.timeout(-1) # disable the screen timeout
self.screen.clrtobot()
self.addstr(8, self.startcol, '艾玛,登录信息好像不对呢 (O_O)#',
curses.color_pair(1))
curses.color_pair(1))
self.addstr(10, self.startcol, '[1] 再试一次')
self.addstr(11, self.startcol, '[2] 稍后再试')
self.addstr(14, self.startcol, '请键入对应数字:', curses.color_pair(2))
Expand Down Expand Up @@ -540,7 +540,7 @@ def get_param(self, prompt_string):
self.screen.move(4, 1)
self.screen.clrtobot()
self.addstr(5, self.startcol, prompt_string,
curses.color_pair(1))
curses.color_pair(1))
self.screen.refresh()
info = self.screen.getstr(10, self.startcol, 60)
if info == '':
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'requests',
'BeautifulSoup4',
'pycrypto',
'future'
],

entry_points={
Expand Down

0 comments on commit 6031310

Please sign in to comment.