無料のCDDB、FreeDBが閉鎖していたのでMusicRepairでSpotify APIを使いタグを自動取得していく。

こんにちは、無能です。

昔かなりお世話になっていたFreeDBが閉鎖してました。

ということで、Spotify APIを使って自動でタグを取得出来るMusicRepairを見つけたので使っていきます。


Github

https://github.com/kalbhor/MusicRepair

pipでインストールできます。

pip3 install musicrepair

musicrepair

と入力すると初回起動でAPIキーよこせよ!と怒られます。



Warning, you are missing the Spotify client ID. Add it using --config

Warning, you are missing the Spotify client secret. Add it using --config

Warning, you are missing the Genius key. Add it using --config

usage: musicrepair [-h] [-c] [-d REPAIR_DIRECTORY] [-R] [-r REVERT_DIRECTORY] [-n] [--format RENAME_FORMAT]

  __  __           _      _____                  _      
 |  \/  |         (_)    |  __ \                (_)     
 | \  / |_   _ ___ _  ___| |__) |___ _ __   __ _ _ _ __ 
 | |\/| | | | / __| |/ __|  _  // _ \ '_ \ / _` | | '__|
 | |  | | |_| \__ \ | (__| | \ \  __/ |_) | (_| | | |   
 |_|  |_|\__,_|___/_|\___|_|  \_\___| .__/ \__,_|_|_|   
                                    | |                 
                                    |_|                 

______________________________________________________________
|                                                            |
| Tries to find the metadata of songs based on the file name |
|                                                            |
| Update : pip install musicrepair -U                        |
|                                                            |            
| https://github.com/lakshaykalbhor/MusicRepair              |
|____________________________________________________________|

options:
  -h, --help            show this help message and exit
  -c, --config          Add API keys to config

  -d REPAIR_DIRECTORY, --dir REPAIR_DIRECTORY
                        Specifies the directory where the music files are located

  -R, --recursive       Specifies whether or not to run recursively 
                                                in the given music directory

  -r REVERT_DIRECTORY, --revert REVERT_DIRECTORY
                        Specifies the directory where music files 
                                                that need to be reverted are located

  -n, --norename        Does not rename files to song title

  --format RENAME_FORMAT
                        Specify the title format used in renaming, 
                                                these keywords will be replaced respectively: 
                                                {title}{artist}{album}
                        

という訳でSpotify APIをゲットしてきます。
昔からなのですが、私はSpotifyと相性が悪く人のプレイリスト開いただけでリダイレクトループなったり今回もこんな感じでサイト重くアクセス出来なかったりしたので多分これからも使うことは無いと思います。多分スマホ版APIに全力でリソース振っているとかなのだろうか。

Redirect URIは正直なんでもいいんですが必須項目だったので自分の別ドメインのサイト入力しておきました。API利用だけだったら正直架空のものでもいいと思います。
んで、WebAPIにチェックして発行されるのでそのままMusicRepairに貼り付けてください。

musicrepair –config

Enter Spotify client ID :ここに取得したクライアントキー
Enter Spotify client secret :~シークレットキー

で、今度は歌詞の取得にGenius APIキーよこせと言われるので取ってきます。

たまたま私は一年前にAI歌詞翻訳用にAPIキーゲットしていたのでこのまま使います。

APIにつけてる名前雑すぎて我ながら笑いました。

Enter Genius key :GeniusのCLIENT IDを入力

これで準備は完了です。

ディレクトリ内を再帰的に探してほしいので-Rオプションをつけてあげます。

musicrepair -d 音楽フォルダ -R

これで勝手に取得していってくれます。

SSHのセッション切ってもバックグラウンドで動いてほしいので
追加でリネームしようとするとおそらく特殊文字が入っているとエラーが起きる?ようなのでリネームをしないオプションを追加

nohup musicrepair -d 音楽フォルダ -R -n &

にしておきます。


それでは。

またよろしくお願い致します。

コメントを残す

管理人が承認後コメントが公開されます。
の項目は必須項目となります。