feat: 新增最近新增歌单 close #273
This commit is contained in:
parent
8c92afd09b
commit
733c44d12f
@ -186,6 +186,9 @@ class Config:
|
|||||||
play_type_seq_tts_msg: str = os.getenv(
|
play_type_seq_tts_msg: str = os.getenv(
|
||||||
"XIAOMUSIC_PLAY_TYPE_SEQ_TTS_MSG", "已经设置为顺序播放"
|
"XIAOMUSIC_PLAY_TYPE_SEQ_TTS_MSG", "已经设置为顺序播放"
|
||||||
)
|
)
|
||||||
|
recently_added_playlist_len: int = int(
|
||||||
|
os.getenv("XIAOMUSIC_RECENTLY_ADDED_PLAYLIST_LEN", "50")
|
||||||
|
)
|
||||||
|
|
||||||
def append_keyword(self, keys, action):
|
def append_keyword(self, keys, action):
|
||||||
for key in keys.split(","):
|
for key in keys.split(","):
|
||||||
|
@ -204,6 +204,9 @@ var vConsole = new window.VConsole();
|
|||||||
<option value="false" selected>false</option>
|
<option value="false" selected>false</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<label for="recently_added_playlist_len">最近新增的歌曲数量:</label>
|
||||||
|
<input id="recently_added_playlist_len" type="number" value="50" />
|
||||||
|
|
||||||
<label for="music_list_url">歌单地址:</label>
|
<label for="music_list_url">歌单地址:</label>
|
||||||
<input id="music_list_url" type="text" value="https://gist.githubusercontent.com/hanxi/dda82d964a28f8110f8fba81c3ff8314/raw/example.json" />
|
<input id="music_list_url" type="text" value="https://gist.githubusercontent.com/hanxi/dda82d964a28f8110f8fba81c3ff8314/raw/example.json" />
|
||||||
|
|
||||||
|
@ -641,13 +641,15 @@ class XiaoMusic:
|
|||||||
"全部": [], # 包含所有歌曲和所有电台
|
"全部": [], # 包含所有歌曲和所有电台
|
||||||
"下载": [], # 下载目录下的
|
"下载": [], # 下载目录下的
|
||||||
"其他": [], # 主目录下的
|
"其他": [], # 主目录下的
|
||||||
|
"最近新增": [], # 按文件时间排序
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# 全部,所有,自定义歌单(收藏)
|
# 最近新增(不包含网络歌单)
|
||||||
self.music_list["全部"] = list(self.all_music.keys())
|
self.music_list["最近新增"] = sorted(
|
||||||
self.music_list["所有歌曲"] = [
|
self.all_music.keys(),
|
||||||
name for name in self.all_music.keys() if name not in self._all_radio
|
key=lambda x: os.path.getctime(self.all_music[x]),
|
||||||
]
|
reverse=True,
|
||||||
|
)[: self.config.recently_added_playlist_len]
|
||||||
|
|
||||||
# 网络歌单
|
# 网络歌单
|
||||||
try:
|
try:
|
||||||
@ -656,6 +658,12 @@ class XiaoMusic:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.exception(f"Execption {e}")
|
self.log.exception(f"Execption {e}")
|
||||||
|
|
||||||
|
# 全部,所有,自定义歌单(收藏)
|
||||||
|
self.music_list["全部"] = list(self.all_music.keys())
|
||||||
|
self.music_list["所有歌曲"] = [
|
||||||
|
name for name in self.all_music.keys() if name not in self._all_radio
|
||||||
|
]
|
||||||
|
|
||||||
# 文件夹歌单
|
# 文件夹歌单
|
||||||
for dir_name, musics in all_music_by_dir.items():
|
for dir_name, musics in all_music_by_dir.items():
|
||||||
self.music_list[dir_name] = list(musics.keys())
|
self.music_list[dir_name] = list(musics.keys())
|
||||||
|
Loading…
Reference in New Issue
Block a user