-
Notifications
You must be signed in to change notification settings - Fork 3
Re-organize #17
Re-organize #17
Conversation
fuocore/app.py
Outdated
self.gateway.publish(sentence + '\n', self.topic) | ||
|
||
|
||
class CliMixin(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个其实不应该叫做 Mixin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一般来说,Mixin 自身应该没有构造函数,如果有构造函数的话,那子类初始化会特别复杂(这个结论也不是特别确定)。
(看了下 cpython 中 ThreadingMixin 和 ConvertingMixin,他们都没有构造函数)
fuocore/app.py
Outdated
self._live_lyric = live_lyric | ||
self._live_lyric_publisher = live_lyric_publisher | ||
|
||
def list_providers(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个接口不应该有,让调用方直接调用 app.library.list()
fuocore/app.py
Outdated
def list_providers(self): | ||
return self.library.list() | ||
|
||
def get_provider(self, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
fuocore/library.py
Outdated
.format(len(songs), keyword)) | ||
return songs | ||
|
||
def get_song(self, furi_str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该放到 protocol 中去实现,它和 f-url 相关
没有 protocol,理论上也就没有 uri 的概念?
这里的 uri 泛指类似这样的: fuo://netease/songs/1234
fuo://netease/artists/1234
fuo://netease/users/1234
fuocore/library.py
Outdated
identifier = result.path.split('/')[-1] | ||
return provider.Song.get(identifier) | ||
|
||
def list_songs(self, furi_str_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
pass | ||
finally: | ||
pubsub_server.close() | ||
event_loop.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一个文件 和 app.py 最好能再组织一下,现在看起来还挺复杂的样子
@@ -138,7 +139,13 @@ def handle(self, cmd): | |||
self.app.player.toggle() | |||
|
|||
def play_song(self, song_furi): | |||
self.app.play(song_furi) | |||
result = urlparse(song_furi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个逻辑好像和 furi 逻辑重复了 -> 在 protocol 模块中应该要有个函数统一做这个(之前好像确实有个 furi.py)。
- 添加 `allow_get` 和 `allow_batch` 给 CLI 模式 - 计算文字宽度,让输出排列更整齐
区分 None 与空列表/空字符串的区别:None 代表该字段没有 被初始化,空列表或者空字符串表示初始化了,但是数据内容为空。
重新组织代码结构
feeluown 有个 PR 依赖这个:https://github.com/cosven/FeelUOwn/pull/231