#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
Netease Music MellController

Created on 2017-02-21
@author: Mellcap
'''

import getch
import ui

CONFIG = {
    'q': 'quit',
    'j': 'next_line',
    'k': 'prev_line',
    ' ': 'play',
    
}


mell_ui = ui.UI()

def watch_key():
    while 1:
        key = getch.getch()
        action = CONFIG.get(key, None)
        if action == 'quit':
            break
        elif action:
            try:
                func = 'handler_%s' % action
                eval(func)()
            except Exception:
                pass

def handler_next_line():
    mell_ui.next_line()

def handler_prev_line():
    mell_ui.prev_line()

def handler_play():
    print('Start Playing...')

if __name__ == '__main__':
    mell_ui.display()
    watch_key()


@@ -153,16 +153,25 @@
 FIG = %7B%0A
+    # %E4%B8%BB%E9%A1%B5%0A
     'q':
@@ -219,24 +219,33 @@
 prev_line',%0A
+    # %E9%9F%B3%E4%B9%90%0A
     ' ': 'pl
@@ -253,16 +253,159 @@
 y',%0A    
+'n': 'next_song',%0A    'p': 'prev_song',%0A    'f': 'next_playlist',%0A    'b': 'prev_playlist',%0A    # %E6%AD%8C%E8%AF%8D%0A    'l': 'lyric',%0A    # %E5%B8%AE%E7%BB%84%0A    'h': 'help'
 %0A%7D%0A%0A%0Amel
@@ -879,16 +879,51 @@
 g...')%0A%0A
+def handler_next_song():%0A    pass%0A%0A
 if __nam

add config at mell_controller