Somusic
Github項目地址:https://github.com/jaydenwen123/Somusic
碼雲項目地址:https://gitee.com/jaydenwen/Somusic
這是命令行音樂下載器,它包含許多功能,如來自kugou網站的搜索歌曲和mv,下載歌曲和單個或批量的mv,列表搜索歌曲或mvs,顯示下載歌曲或mv。以上功能有匹配的命令 你可以使用幫助或h來找到doc.最后遺留一個播放音樂和播放MV的功能。我將在后續完善這個功能。
誰應該看到這個項目?
- 如果你想通過實際項目快速學習golang;
- 如果您想更好地了解命令行軟件的運行方式;
- 如果您想快速進入網絡爬蟲世界;
- 如果您對音樂網站感興趣,並且想要自己構建音樂播放器;
- 這個項目對你來說絕對不錯。
你能得到什么?
1.用Golang語言爬取音樂網站數據。
2. 通過Golang goroutine和Channel並發下載文件(不僅包括mp3文件和mp4文件,還包括二進制文件和文本文件。)。
3.掌握JSON和Golang結構體,接口,http,正則以及Golang基礎知識的技能。
4.練習使用優秀的golang開源庫,例如:goquery,gjson ......
5.了解命令行工具的工作原理。 如windows cmd,Golang Web Framework beego的蜜蜂工具。
6.分析Http關於音樂網站的接口。
7.通過Golang熟悉網絡爬蟲的技能。
開啟旅程#
安裝##
1.創建一個用於存儲項目的目錄。例如:
cd d:\golang\workspac\.
2.你應該執行這個命令git clone https://github.com/jaydenwen123/Somusic.git
3.如果要將此項目移動到%gopath%,則可以將其移動到gopath的src目錄中。
現在將檢索項目到您的本地目錄,您可以開始您的旅行。
幫助文檔##
1.somusic支持許多功能,也可以匹配它的命令。 下表中列出了所有支持的功能。
命令 | 參數 | 功能 | 說明 |
---|---|---|---|
gboard | 無參數 | 下載排行榜歌曲 | 下載kugou排行榜的歌曲 |
lsong | [max songid] or
|
顯示搜索到的歌曲 | 按照升序的方式顯示音樂列表(注意:顯示的歌曲是搜索到但未下載) |
lmv | [max mvid] or
|
顯示搜索到的MV | 按照升序的方式顯示MV列表信息,這個命令和lsong比較相似 |
gsong | [songid] or <first1-end1,first2-end2...> or <songid1,...,first1-end1,songid2,songid3...> | 從遠程服務器下載指定的搜索到的歌曲 | 按照指定的范圍下載音樂。支持下載單曲,批量(第一段)歌曲,不連續(songid1,songid5,songid8,...)歌曲和混合以上所有方式進行並發下載 |
gmv | [mvid] or <first1-end1,first2-end2...> or <mvid1,...,first1-end1,mvid5,mvid7...> | 下載MV歌曲 | 這個命令和gsong命令比較像 |
psong | [songid] | 播放選擇的歌曲 | 這個功能還沒有完成。將在不久的將來填寫 |
pmv | [mvid] | 播放選擇的MV | 這個功能暫時還沒有實現。將在后續實現 |
qsong | [keyword] | 搜索歌曲 | 根據提供的關鍵詞信息搜索歌曲 |
qmv | [keyword] | 搜索MV | 格局提供的關鍵詞搜索MV |
ssong | 無參數 | 查看本地已經下載的歌曲 | 顯示下載的歌曲列表,您可以使用該歌曲在列表中播放歌曲 |
smv | 無參數 | 查看本地已經下載的MV | 顯示下載的MV列表,您可以使用該歌曲在列表中播放MV,這個命令和ssong命令相似 |
chstyle | [new style string] | 改變somusic命令行的風格 | 利用新的風格替換掉舊的風格。這個命令與style 命令相同。 |
style | [new style string] | 改變somusic命令行的風格 | 改變somusic命令行的風格 |
chdelimiter | [new delimiter chars] | 改變somusic命令行的分隔符 | 改變命令行的分隔符 |
delimiter | [new delimiter chars] | 改變somusic命令行的分隔符 | 它將替換掉舊的分隔符.這個命令功能與命令chdelimiter 相同 |
mvpath | 無參數 | 查看當前保存MV的路徑 | 查看當前保存MV的路徑 |
songpath | 無參數 | 查看當前保存歌曲的路徑 | 查看當前保存歌曲的路徑 |
chmvpath | [newmvpath] | 切換存放下載MV的路徑 | 更改保存下載mv路徑。 使用~ 恢復默認目錄 |
chsongpath | [newsongpath] | 切換存放下載歌曲的路徑 | 更改保存下載歌曲路徑。 使用~ 恢復默認目錄 |
help or h | 無參數 | 查看幫助文檔 | 查看幫助文檔 |
quit or CTRL+C | 無參數 | 退出程序 | 退出程序 |
exit or CTRL+C | 無參數 | 退出程序 | 退出程序 |
cls or clear | 無參數 | 清除日志信息 | 清除日志信息。在當前版本中,它只支持windows 清除日志信息.后續版本將添加linux清除日志功能 |
2.以下是幫助文檔的圖片,該文檔在goland ide中運行。
用法
在這個部分。 我將使用搜索歌曲關鍵字:bigbig
和天使的翅膀
,以及搜索MV關鍵字:'Falling Down和
小幸運`作為示例來說明如何使用somusic程序。
1.search song with keyword.
command:
qsong bigbig
(bigbig)
command:qsong 天使的翅膀
(天使的翅膀)
2.search mv with keyword.
command:
qmv falling down
(falling down)
command:qmv 小幸運
(小幸運)
3.list the searched song information.
command:
lsong
(小幸運)
command:lsong 11
(big big world)
command:lsong
(天使的翅膀)
4.list the searched mv informtion.
command:
lmv
(Falling Down)
command:lmv
(小幸運)
5.download the searched song.
command:
gsong 3,6
(big big world)
6.download the searched mv.
command:
gmv 1-10
(Falling Down)
command:gmv 1-5
(小幸運)
7.show the local downloaded songs.
command:
ssong
8.show the local donwloaded mvs.
command:
smv
9.show the current saved download songs' directory.
command:
songpath
10.show the current saved download mvs' directory.
command:
mvpath
11.change the saved download mvs' directory.
command:
chmvpath D:\歌曲
12.change the saved download mvs' directory.
command:
chsongpath D:\歌曲
13.change the program command line style.
command:
style mimusic
14.change the program command line delimiter.
command:
delimiter #
15.show or find the help document.
command:
help
16.quit or exit the program.
command:
exit
17.clear the log information.
command:
cls
參考資料
- gjson(https://github.com/tidwall/gjson)
- goquery(https://github.com/PuerkitoBio/goquery)
- gorm(https://github.com/jinzhu/gorm)
- beego orm(https://github.com/astaxie/beego/orm)
- beego logs(https://github.com/astaxie/beego/logs)
- regexp standard library(https://studygolang.com/pkgdoc)
- net/http standard library(https://studygolang.com/pkgdoc)
- channel&goroutine(https://gobyexample.com)
需要改進什么
- 1.播放歌曲或在現實中播放MV。
- 2.將變量配置到文件中。如保存下載歌曲目錄和mv目錄,軟件命令行樣式和分隔符。
- 3.添加緩存模塊。它可以提高somusic的性能。
Github項目地址: https://github.com/jaydenwen123/Somusic
碼雲項目地址:https://gitee.com/jaydenwen/Somusic