python音樂管理命令行工具beets的使用(音頻轉(zhuǎn)碼,標(biāo)簽管理,web音樂播放器,音樂數(shù)據(jù)庫)

音樂管理命令行工具beets的使用(音頻轉(zhuǎn)碼,標(biāo)簽管理,web音樂播放器,音樂數(shù)據(jù)庫)

01.功能介紹

github上有的功能介紹,谷歌翻譯一下貼過來

  • 提取或計算您可能需要的所有元數(shù)據(jù):專輯封面,歌詞,流派,節(jié)奏,ReplayGain級別或聲學(xué)指紋。
  • 從MusicBrainz,Discogs和Beatport獲取元數(shù)據(jù)。 或者使用歌曲的文件名或其聲學(xué)指紋來猜測元數(shù)據(jù)。
  • 將音頻轉(zhuǎn)碼為您喜歡的任何格式。
  • 檢查您的音樂庫中是否有重復(fù)的曲目和專輯,或者缺少曲目的專輯。
  • 清理其他不那么出色的工具留下的粗糙標(biāo)簽。
  • 從文件的元數(shù)據(jù)嵌入和提取專輯封面。
  • 通過Web瀏覽器以圖形方式瀏覽音樂庫,并在任何支持HTML5音頻的瀏覽器中播放。
  • 從命令行分析音樂文件的元數(shù)據(jù)。
  • 使用會說MPD協(xié)議并具有多種驚人接口的音樂播放器來聆聽您的音樂庫。

02.安裝

這是基于python開發(fā)的軟件,可以使用pip包管理器來安裝。

pip install beets

然后可以查看幫助文檔
beet -h

beet.exe
Usage:
  beet COMMAND [ARGS...]
  beet help COMMAND

Options:
  --format-item=FORMAT_ITEM
                        print with custom format
  --format-album=FORMAT_ALBUM
                        print with custom format
  -l LIBRARY, --library=LIBRARY
                        library database file to use
  -d DIRECTORY, --directory=DIRECTORY
                        destination music directory
  -v, --verbose         log more details (use twice for even more)
  -c CONFIG, --config=CONFIG
                        path to configuration file
  -h, --help            show this help message and exit

Commands:
  config            show or edit the user configuration
  fields            show fields available for queries and format strings
  help (?)          give detailed help on a specific sub-command
  import (imp, im)  import new music
  list (ls)         query the library
  modify (mod)      change metadata fields
  move (mv)         move or copy items
  remove (rm)       remove matching items from the library
  stats             show statistics about the library or a query
  update (upd, up)  update the library
  version           output version information
  write             write tag information to files

可以去看官方的幫助文檔 https://beets.readthedocs.io/en/stable/index.html

官網(wǎng) https://beets.io/

03.快速上手

001.首先進行一些基礎(chǔ)的配置

輸入下面的命令找到配置文件的位置

beet config -p

我是win10系統(tǒng),顯示的地址是這樣的C:\Users\yonghuming\AppData\Roaming\beets\config.yaml

輸入下面的命令會打開默認編輯器編輯配置文件,會根據(jù)$editor變量確定你的默認編輯器

beet config -e

我這邊沒有設(shè)置默認編輯器,所以直接用notepad打開那個文件。

一開始配置文件是空的,需要你加上一點東西。

首先是指定你的音樂文件夾的目錄

directory: C:/MySQMusic
library: C:/MySQMusic/musiclibrary.db

這個軟件的默認設(shè)定會假定你要創(chuàng)建一個新的有組織的音樂庫,當(dāng)你使用import命令時會把對象清理干凈(加標(biāo)簽,標(biāo)簽糾錯之類)后復(fù)制到你的音樂庫文件夾里面。

如果你不要復(fù)制,而是移動文件,加入下面的一條

import:
    move: yes

如果你想保持現(xiàn)在的目錄結(jié)構(gòu)(這個應(yīng)該是最常用的,這樣就能兼容我原來按歌單建的文件夾了),只糾正標(biāo)簽,那么在import下面加上copy: no

ps:它默認的目錄結(jié)構(gòu)是歌手》專輯》歌這樣子,對于我這種聽歌從來不按專輯,哪首好聽就把哪首加歌單的人來說沒什么意義

如果你想保持原來的標(biāo)簽不修改,文件名也不重命名,那么在import后面加上write:no

這樣就是既不拷貝,也不修改,只是把歌曲信息錄入數(shù)據(jù)庫而已。

然后這個軟件自動修改標(biāo)簽后,修改之前的標(biāo)簽也會留在數(shù)據(jù)庫里,你還可以把他們變回來。

使用命令beet config -d,查看默認配置,看看總共有哪些配置,然后我們照著這個配置文件修改就可以了

library: library.db
directory: ~/Music
import:
    write: yes
    copy: yes
    move: no
    link: no
    hardlink: no
    delete: no
    resume: ask
    incremental: no
    incremental_skip_later: no
    from_scratch: no
    quiet_fallback: skip
    none_rec_action: ask
    timid: no
    log:
    autotag: yes
    quiet: no
    singletons: no
    default_action: apply
    languages: []
    detail: no
    flat: no
    group_albums: no
    pretend: no
    search_ids: []
    duplicate_action: ask
    bell: no
    set_fields: {}

clutter: [Thumbs.DB, .DS_Store]
ignore:
- .*
- '*~'
- System Volume Information
- lost+found
ignore_hidden: yes

replace:
    '[\\/]': _
    ^\.: _
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    \.$: _
    \s+$: ''
    ^\s+: ''
    ^-: _
path_sep_replace: _
asciify_paths: no
art_filename: cover
max_filename_length: 0

aunique:
    keys: albumartist album
    disambiguators: albumtype year label catalognum albumdisambig releasegroupdisambig
    bracket: '[]'

overwrite_null:
    album: []
    track: []

plugins: []
pluginpath: []
threaded: yes
timeout: 5.0
per_disc_numbering: no
verbose: 0
terminal_encoding:
original_date: no
artist_credit: no
id3v23: no
va_name: Various Artists

ui:
    terminal_width: 80
    length_diff_thresh: 10.0
    color: yes
    colors:
        text_success: green
        text_warning: yellow
        text_error: red
        text_highlight: red
        text_highlight_minor: lightgray
        action_default: turquoise
        action: blue

format_item: $artist - $album - $title
format_album: $albumartist - $album
time_format: '%Y-%m-%d %H:%M:%S'
format_raw_length: no

sort_album: albumartist+ album+
sort_item: artist+ album+ disc+ track+
sort_case_insensitive: yes

paths:
    default: $albumartist/$album%aunique{}/$track $title
    singleton: Non-Album/$artist/$title
    comp: Compilations/$album%aunique{}/$track $title

statefile: state.pickle

musicbrainz:
    host: musicbrainz.org
    ratelimit: 1
    ratelimit_interval: 1.0
    searchlimit: 5

match:
    strong_rec_thresh: 0.04
    medium_rec_thresh: 0.25
    rec_gap_thresh: 0.25
    max_rec:
        missing_tracks: medium
        unmatched_tracks: medium
    distance_weights:
        source: 2.0
        artist: 3.0
        album: 3.0
        media: 1.0
        mediums: 1.0
        year: 1.0
        country: 0.5
        label: 0.5
        catalognum: 0.5
        albumdisambig: 0.5
        album_id: 5.0
        tracks: 2.0
        missing_tracks: 0.9
        unmatched_tracks: 0.6
        track_title: 3.0
        track_artist: 2.0
        track_index: 1.0
        track_length: 2.0
        track_id: 5.0
    preferred:
        countries: []
        media: []
        original_year: no
    ignor: []
    required: []
    ignored_media: []
    ignore_data_tracks: yes
    ignore_video_tracks: yes
    track_length_grace: 10
    track_length_max: 30

具體參數(shù)的解釋,看這篇幫助文檔 https://beets.readthedocs.io/en/stable/reference/config.html

002.導(dǎo)入音樂庫

導(dǎo)入音樂庫之前注意要做好備份,因為這個操作設(shè)計到修改文件和移動文件相關(guān)的操作。

有兩種把你的音樂庫加入數(shù)據(jù)庫的方式

a)使用現(xiàn)存的元數(shù)據(jù),不進行改動

b) 讓beet自動查詢數(shù)據(jù)來修改你的音樂的元數(shù)據(jù),添加標(biāo)簽之類的。

如果是方式b的話,可能消耗很長時間,并且有些修改操作會詢問你。

執(zhí)行下面的命令。import你想導(dǎo)入的目錄即可,這樣就會自動修改標(biāo)簽了

$ beet import /path/to/my/music

如果你不想自動修改標(biāo)簽,使用-A選項,表示don’t autotag

$ beet import -A /my/huge/mp3/library

除了導(dǎo)入音樂庫,添加新音樂的時候也是用import命令

03.自動標(biāo)簽機制

001.機制解釋

beet import 命令在一個文件夾中執(zhí)行后會自動把音樂文件加入到你的音樂庫,并且給他們完善標(biāo)簽。(除非你傳遞-noautotag選項) import默認設(shè)定在導(dǎo)入音樂的過程中有一些假定的限制,

  • 音樂必須按照專輯分目錄,每個專輯都是一個目錄。這個設(shè)定也有一些例外,
    • 一、比如看起來像是多碟專輯的目錄,比如兩個目錄名字都含有disk,或者都含有cd加上數(shù)字,這些會進入一個專輯里
    • 二、如果你把一個目錄中不小心混了多個目錄,可以用beet把他們根據(jù)元數(shù)據(jù)(metadata)重新分好目錄,用--group-albums選項
  • 音樂標(biāo)簽可能很不完善,默認會根據(jù)存在的元數(shù)據(jù)來查找tag,但是還有其他的一些解決方案,
    • 使用E和I選項描述如何從MusicBrainz查找專輯或者歌曲
    • 使用聽歌識曲插件Acoustid plugin
    • 使用FromFilename plugin 插件,可以從文件名幫助猜測tag。比如 ’03 Call Me Maybe.mp3‘這樣的文件名包含歌名的。
  • 目前支持的格式有 MP3, AAC, FLAC, ALAC, Ogg Vorbis, Monkey’s Audio, WavPack, Musepack, Windows Media, Opus, and AIFF

002.選項

To import music, just say beet import MUSICDIR. There are, of course, a few command-line options you should know:

  • beet import -A: don’t try to autotag anything; just import files (this goes much faster than with autotagging enabled)
  • beet import -W: when autotagging, don’t write new tags to the files themselves (just keep the new metadata in beets’ database)
  • beet import -C: don’t copy imported files to your music directory; leave them where they are
  • beet import -m: move imported files to your music directory (overrides the -c option)
  • beet import -l LOGFILE: write a message to LOGFILE every time you skip an album or choose to take its tags “as-is” (see below) or the album is skipped as a duplicate; this lets you come back later and reexamine albums that weren’t tagged successfully
  • beet import -q: quiet mode. Never prompt for input and, instead, conservatively skip any albums that need your opinion. The -ql combination is recommended.
  • beet import -t: timid mode, which is sort of the opposite of “quiet.” The importer will ask your permission for everything it does, confirming even very good matches with a prompt.
  • beet import -p: automatically resume an interrupted import. The importer keeps track of imports that don’t finish completely (either due to a crash or because you stop them halfway through) and, by default, prompts you to decide whether to resume them. The -p flag automatically says “yes” to this question. Relatedly, -P flag automatically says “no.”
  • beet import -s: run in singleton mode, tagging individual tracks instead of whole albums at a time. See the “as Tracks” choice below. This means you can use beet import -AC to quickly add a bunch of files to your library without doing anything to them.
  • beet import -g: assume there are multiple albums contained in each directory. The tracks contained a directory are grouped by album artist and album name and you will be asked to import each of these groups separately. See the “Group albums” choice below.

003.相似度

當(dāng)導(dǎo)入音樂庫時,相似度低的匹配會向你詢問。

$ beet imp witchinghour
Tagging:
    Ladytron - Witching Hour
(Similarity: 98.4%)
* Last One Standing      -> The Last One Standing
* Beauty                 -> Beauty*2
* White Light Generation -> Whitelightgenerator
* All the Way            -> All the Way...

004.選擇

When beets needs your input about a match, it says something like this:

Tagging:
    Beirut - Lon Gisland
(Similarity: 94.4%)
* Scenic World (Second Version) -> Scenic World
[A]pply, More candidates, Skip, Use as-is, as Tracks, Enter search, enter Id, or aBort?

When beets asks you this question, it wants you to enter one of the capital letters: A, M, S, U, T, G, E, I or B. That is, you can choose one of the following:

  • A: Apply the suggested changes shown and move on.
  • M: Show more options. (See the Candidates section, below.)
  • S: Skip this album entirely and move on to the next one.
  • U: Import the album without changing any tags. This is a good option for albums that aren’t in the MusicBrainz database, like your friend’s operatic faux-goth solo record that’s only on two CD-Rs in the universe.
  • T: Import the directory as singleton tracks, not as an album. Choose this if the tracks don’t form a real release—you just have one or more loner tracks that aren’t a full album. This will temporarily flip the tagger into singleton mode, which attempts to match each track individually.
  • G: Group tracks in this directory by album artist and album and import groups as albums. If the album artist for a track is not set then the artist is used to group that track. For each group importing proceeds as for directories. This is helpful if a directory contains multiple albums.
  • E: Enter an artist and album to use as a search in the database. Use this option if beets hasn’t found any good options because the album is mistagged or untagged.
  • I: Enter a metadata backend ID to use as search in the database. Use this option to specify a backend entity (for example, a MusicBrainz release or recording) directly, by pasting its ID or the full URL. You can also specify several IDs by separating them by a space.
  • B: Cancel this import task altogether. No further albums will be tagged; beets shuts down immediately. The next time you attempt to import the same directory, though, beets will ask you if you want to resume tagging where you left off.

005.候選選項

If you choose the M option, or if beets isn’t very confident about any of the choices it found, it will present you with a list of choices (called candidates), like so:

Finding tags for "Panther - Panther".
Candidates:
1. Panther - Yourself (66.8%)
2. Tav Falco's Panther Burns - Return of the Blue Panther (30.4%)
# selection (default 1), Skip, Use as-is, or Enter search, or aBort?

Here, you have many of the same options as before, but you can also enter a number to choose one of the options that beets has found. Don’t worry about guessing—beets will show you the proposed changes and ask you to confirm them, just like the earlier example. As the prompt suggests, you can just hit return to select the first candidate.

04.高級使用

這里主要是關(guān)于配置文件和各種插件的。

001.獲取封面,專輯類別和歌詞

配置中加入這三個插件即可

plugins: fetchart lyrics lastgenre

注意,有些插件有自己特殊依賴需要單獨安裝,使用pip安裝即可

pip install beets[fetchart,lyrics,lastgenre]

002.自定義文件和文件夾名

關(guān)于路徑名配置有一個文檔 可以看 https://beets.readthedocs.io/en/stable/reference/config.html#path-format-config

為了靈活設(shè)置文件夾名和文件名有兩點需要知道:

  • 模板函數(shù),可以用來給你的路徑名加上一點邏輯操作,比如,找到一個藝術(shù)家的首字母 %upper{%left{$albumartist,1}}
  • 如果需要更加靈活, Inline Plugin 這個插件可以支持使用python代碼生成文件名,還是獲取藝術(shù)家首字母的例子initial: albumartist[0].upper()

003.使你的音樂能通過網(wǎng)絡(luò)訪問

安裝 Web Plugin插件,beet web 運行服務(wù)器后,你可以通過地址用瀏覽器訪問。

004.格式轉(zhuǎn)換

安裝 Convert Plugin插件,需要安裝ffmpeg,查看它的幫助文檔https://beets.readthedocs.io/en/stable/plugins/convert.html

005.存儲自定義字段

beets數(shù)據(jù)庫有很多內(nèi)置字段,你也可以自己設(shè)置一些新字段

比如說你想決定音樂什么時候播放,比如說某音樂家的音樂適合派對的時候播放

你需要創(chuàng)造一個context屬性在記錄這個值,使用modify命令

beet modify context=party artist:'beastie boys'

執(zhí)行這個命令后,beets會詢問你讓你做出選擇

你也可以用自己定義的字段來查詢

beet ls context:mope

自定義字段甚至可以用在文件名定義中

刪除操作,執(zhí)行下面的代碼

beet modify context! artist:'beastie boys

006.手動設(shè)置路徑樣式

之前有講過整體的路徑樣式的配置。但是有時候,你想要對某些音樂進行獨立配置。

比如說有些你不怎么喜歡的音樂,但是為了播放給朋友和家人聽需要保存。

我們就可以像上面005一樣用一個靈活的屬性來存儲一個標(biāo)記用于分類

比如

beet modify bad=1 christmas

然后你就可以查詢這個字段了??梢杂貌煌呐判蚍绞?,也可以在配置文件中進行配置

paths:
    bad:1: Bad/$artist/$title
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容