音楽ファイルのジャケット画像とかほしいので。
対象環境
- Raspberry Pi 3 Model B+
- Raspbian stretch 2018-06-27
前提
参考
- http://reppets.hatenablog.com/entry/2015/04/20/010630
- https://eyed3.readthedocs.io/en/latest/
- https://github.com/nicfit/eyeD3/releases
2018-09-24時点での最新は0.87
方法
eyeD3
をインストールする- タグ情報を取得する
1. eyeD3
をインストールする
A. apt, apt-get
インストールできなかった。
$ sudo apt install eyeD3 パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 E: パッケージ eyeD3 が見つかりません
$ sudo apt-get install eyeD3 パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 E: パッケージ eyeD3 が見つかりません
検索してみると見つかった。小文字のd
違い。だが、バージョンが古い。
$ sudo apt search eyeD3 ソート中... 完了 全文検索... 完了 eyed3/stable,stable,stable 0.7.10-1 all Display and manipulate id3-tags on the command-line python-eyed3/stable,stable,stable 0.7.10-1 all Python module for id3-tags manipulation
B. pip, pip3
eyeD3はPython製らしいのでpipでインストールする。python2系ならpip, python3系ならpip3。今回は2系にする。念の為バージョン確認。
$ python -V Python 2.7.13 $ pip -V pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7) $ pip3 -V pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5) $ python3 -V Python 3.5.3
2系
$ pip search eyeD3 eyeD3 (0.8.7) - Python audio data toolkit (ID3 and MP3)
検索するとバージョンは0.8.7
。現時点での最新だった。
$ pip install eyeD3
なんかエラー出た。
Collecting eyeD3 Downloading https://files.pythonhosted.org/packages/57/42/e6b868b2afb38ff51f23edff0f884c68a746cc1ba25e0b3696f64ca33b75/eyeD3-0.8.7-py2.py3-none-any.whl (147kB) 100% |████████████████████████████████| 153kB 855kB/s Collecting six (from eyeD3) Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl Collecting pathlib (from eyeD3) Downloading https://files.pythonhosted.org/packages/ac/aa/9b065a76b9af472437a0059f77e8f962fe350438b927cb80184c32f075eb/pathlib-1.0.1.tar.gz (49kB) 100% |████████████████████████████████| 51kB 1.8MB/s Collecting python-magic (from eyeD3) Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_file require_hashes File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_link self.link = finder.find_requirement(self, upgrade) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirement all_candidates = self.find_all_candidates(req.name) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages page = self._get_page(location) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page return HTMLPage.get_page(link, session=self.session) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 792, in get_page "Cache-Control": "max-age=600", File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get return self.request('GET', url, **kwargs) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request resp = self.send(prep, **send_kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send r = adapter.send(request, **kwargs) File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send timeout=timeout File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment total -= 1 TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
「-=
演算子をサポートしていない」というエラーに見える。Pythonのバージョンが古いせい?
3系
$ pip3 search eyeD3 eyeD3 (0.8.7) - Python audio data toolkit (ID3 and MP3)
$ pip3 install eyeD3
成功!
Collecting eyeD3 Using cached https://files.pythonhosted.org/packages/57/42/e6b868b2afb38ff51f23edff0f884c68a746cc1ba25e0b3696f64ca33b75/eyeD3-0.8.7-py2.py3-none-any.whl Collecting python-magic (from eyeD3) Downloading https://files.pythonhosted.org/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl Collecting pathlib (from eyeD3) Downloading https://www.piwheels.org/simple/pathlib/pathlib-1.0.1-py3-none-any.whl Collecting six (from eyeD3) Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl Installing collected packages: python-magic, pathlib, six, eyeD3 Successfully installed eyeD3-0.8.7 pathlib-1.0.1 python-magic-0.4.15 six-1.11.0
インストール確認。
$ pip3 list | grep eyeD3 eyeD3 (0.8.7)
えっ……。コマンドない。
$ eyeD3 bash: eyeD3: コマンドが見つかりません $ eyed3 bash: eyed3: コマンドが見つかりません
そもそも、どこにインストールされた?
$ pip3 show eyeD3 Name: eyeD3 Version: 0.8.7 Summary: Python audio data toolkit (ID3 and MP3) Home-page: http://eyed3.nicfit.net/ Author: Travis Shirk Author-email: travis@pobox.com License: GNU GPL v3.0 Location: /home/pi/.local/lib/python3.5/site-packages Requires: python-magic, six, pathlib
/home/pi/.local/lib/python3.5/site-packages/eyed3
を見てみたが実行ファイルがない……。もしやPython3ライブラリだけ? バイナリないの? なんかネットで見つけた情報と違う。
C. apt, apt-get
もう古くてもいいや……。
$ sudo apt install eyed3
パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下の追加パッケージがインストールされます: python-eyed3 以下のパッケージが新たにインストールされます: eyed3 python-eyed3 アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。 112 kB のアーカイブを取得する必要があります。 この操作後に追加で 524 kB のディスク容量が消費されます。 続行しますか? [Y/n] y
やっとインストールできた……。
$ eyeD3 --version eyeD3 0.7.10-final (C) Copyright 2002-2014 Travis Shirk This program comes with ABSOLUTELY NO WARRANTY! See COPYING for details. Run with --help/-h for usage information or read the docs at http://eyeD3.nicfit.net/
$ eyeD3 --help usage: eyeD3 [-h] [--version] [-l LEVEL[:LOGGER]] [--exclude PATTERN] [-L] [-P NAME] [-C FILE] [--backup] [-Q] [--fs-encoding ENCODING] [--no-config] [--no-color] [--profile] [--pdb] [-a STRING] [-A STRING] [-b STRING] [-t STRING] [-n NUM] [-N NUM] [--track-offset N] [-d NUM] [-D NUM] [-G GENRE] [-Y YEAR] [-c STRING] [--rename PATTERN] [-1] [-2] [--to-v1.1] [--to-v2.3] [--to-v2.4] [--release-date DATE] [--orig-release-date DATE] [--recording-date DATE] [--encoding-date DATE] [--tagging-date DATE] [--publisher STRING] [--play-count <+>N] [--bpm N] [--unique-file-id OWNER_ID:ID] [--add-comment COMMENT[:DESCRIPTION[:LANG]] [--remove-comment DESCRIPTION[:LANG]] [--remove-all-comments] [--add-lyrics LYRICS_FILE[:DESCRIPTION[:LANG]]] [--remove-lyrics DESCRIPTION[:LANG]] [--remove-all-lyrics] [--text-frame FID:TEXT] [--user-text-frame DESC:TEXT] [--url-frame FID:URL] [--user-url-frame DESCRIPTION:URL] [--add-image IMG_PATH:TYPE[:DESCRIPTION]] [--remove-image DESCRIPTION] [--remove-all-images] [--write-images DIR] [--add-object OBJ_PATH:MIME-TYPE[:DESCRIPTION[:FILENAME]]] [--remove-object DESCRIPTION] [--write-objects DIR] [--remove-all-objects] [--add-popularity EMAIL:RATING[:PLAY_COUNT]] [--remove-popularity EMAIL] [--remove-v1] [--remove-v2] [--remove-all] [--remove-frame FID] [--max-padding NUM_BYTES] [--no-max-padding] [--encoding latin1|utf8|utf16|utf16-be] [--force-update] [-v] [--preserve-file-times] [PATH [PATH ...]] positional arguments: PATH Files or directory paths optional arguments: -h, --help show this help message and exit --version Display version information and exit --exclude PATTERN A regular expression for path exclusion. May be specified multiple times. -L, --plugins List all available plugins -P NAME, --plugin NAME Specify which plugin to use. The default is 'classic' -C FILE, --config FILE Supply a configuration file. The default is '/home/pi/.eyeD3/config.ini', although even that is optional. --backup Plugins should honor this option such that a backup is made of any file modified. The backup is made in same directory with a '.orig' extension added. -Q, --quiet A hint to plugins to output less. --fs-encoding ENCODING Use the specified file system encoding for filenames. Default as it was detected is 'UTF-8' but this option is still useful when reading from mounted file systems. --no-config Do not load the default user config '/home/pi/.eyeD3/config.ini'. The -c/--config options are still honored if present. --no-color Suppress color codes in console output. This will happen automatically if the output is not a TTY (e.g. when redirecting to a file) Debugging: -l LEVEL[:LOGGER], --log-level LEVEL[:LOGGER] Set a log level. This option may be specified multiple times. If a logger name is specified than the level applies only to that logger, otherwise the level is set on the top-level logger. Acceptable levels are 'debug', 'verbose', 'info', 'warning', 'error', 'critical'. --profile Run using python profiler. --pdb Drop into 'pdb' when errors occur. Plugin options: Classic eyeD3 interface for viewing and editing tags. All PATH arguments are parsed and displayed. Directory paths are searched recursively. Any editing options (--artist, --title) are applied to each file read. All date options (-Y, --release-year excepted) follow ISO 8601 format. This is ``yyyy-mm-ddThh:mm:ss``. The year is required, and each component thereafter is optional. For example, 2012-03 is valid, 2012--12 is not. -a STRING, --artist STRING Set the artist name. -A STRING, --album STRING Set the album name. -b STRING, --album-artist STRING Set the album artist name. 'Various Artists', for example. Another example is collaborations when the track artist might be 'Eminem featuring Proof' the album artist would be 'Eminem'. -t STRING, --title STRING Set the track title. -n NUM, --track NUM Set the track number. Use 0 to clear. -N NUM, --track-total NUM Set total number of tracks. Use 0 to clear. --track-offset N Increment/decrement the track number by [-]N. This option is applied after --track=N is set. -d NUM, --disc-num NUM Set the disc number. Use 0 to clear. -D NUM, --disc-total NUM Set total number of discs in set. Use 0 to clear. -G GENRE, --genre GENRE Set the genre. If the argument is a standard ID3 genre name or number both will be set. Otherwise, any string can be used. Run 'eyeD3 --plugin=genres' for a list of standard ID3 genre names/ids. -Y YEAR, --release-year YEAR Set the year the track was released. Use the date options for more precise values or dates other than release. -c STRING, --comment STRING Set a comment. In ID3 tags this is the comment with an empty description. See --add-comment to add multiple comment frames. --rename PATTERN Rename file (the extension is not affected) based on data in the tag using substitution variables: $album, $album_artist, $artist, $best_date, $best_date:prefer_recording, $best_date:prefer_recording:year, $best_date:prefer_release, $best_date:prefer_release:year, $best_date:year, $disc:num, $disc:total, $file, $file:ext, $original_release_date, $original_release_date:year, $recording_date, $recording_date:year, $release_date, $release_date:year, $title, $track:num, $track:total ID3 options: -1, --v1 Only read and write ID3 v1.x tags. By default, v1.x tags are only read or written if there is not a v2 tag in the file. -2, --v2 Only read/write ID3 v2.x tags. This is the default unless the file only contains a v1 tag. --to-v1.1 Convert the file's tag to ID3 v1.1 (Or 1.0 if there is no track number) --to-v2.3 Convert the file's tag to ID3 v2.3 --to-v2.4 Convert the file's tag to ID3 v2.4 --release-date DATE Set the date the track/album was released --orig-release-date DATE Set the original date the track/album was released --recording-date DATE Set the date the track/album was recorded --encoding-date DATE Set the date the file was encoded --tagging-date DATE Set the date the file was tagged --publisher STRING Set the publisher/label name --play-count <+>N Set the number of times played counter. If the argument value begins with '+' the tag's play count is incremented by N, otherwise the value is set to exactly N. --bpm N Set the beats per minute value. --unique-file-id OWNER_ID:ID Add a unique file ID frame. If the ID arg is empty the frame is removed. An OWNER_ID is required. The ID may be no more than 64 bytes. --add-comment COMMENT[:DESCRIPTION[:LANG] Add or replace a comment. There may be more than one comment in a tag, as long as the DESCRIPTION and LANG values are unique. The default DESCRIPTION is '' and the default language code is 'eng'. --remove-comment DESCRIPTION[:LANG] Remove comment matching DESCRIPTION and LANG. The default language code is 'eng'. --remove-all-comments Remove all comments from the tag. --add-lyrics LYRICS_FILE[:DESCRIPTION[:LANG]] Add or replace a lyrics. There may be more than one set of lyrics in a tag, as long as the DESCRIPTION and LANG values are unique. The default DESCRIPTION is '' and the default language code is 'eng'. --remove-lyrics DESCRIPTION[:LANG] Remove lyrics matching DESCRIPTION and LANG. The default language code is 'eng'. --remove-all-lyrics Remove all lyrics from the tag. --text-frame FID:TEXT Set the value of a text frame. To remove the frame, specify an empty value. For example, --text- frame='TDRC:' --user-text-frame DESC:TEXT Set the value of a user text frame (i.e., TXXX). To remove the frame, specify an empty value. e.g., --user-text-frame='SomeDesc:' --url-frame FID:URL Set the value of a URL frame. To remove the frame, specify an empty value. e.g., --url-frame='WCOM:' --user-url-frame DESCRIPTION:URL Set the value of a user URL frame (i.e., WXXX). To remove the frame, specify an empty value. e.g., --user-url-frame='SomeDesc:' --add-image IMG_PATH:TYPE[:DESCRIPTION] Add or replace an image. There may be more than one image in a tag, as long as the DESCRIPTION values are unique. The default DESCRIPTION is ''. If PATH begins with 'http[s]://' then it is interpreted as a URL instead of a file containing image data. The TYPE must be one of the following: OTHER, ICON, OTHER_ICON, FRONT_COVER, BACK_COVER, LEAFLET, MEDIA, LEAD_ARTIST, ARTIST, CONDUCTOR, BAND, COMPOSER, LYRICIST, RECORDING_LOCATION, DURING_RECORDING, DURING_PERFORMANCE, VIDEO, BRIGHT_COLORED_FISH, ILLUSTRATION, BAND_LOGO, PUBLISHER_LOGO. --remove-image DESCRIPTION Remove image matching DESCRIPTION. --remove-all-images Remove all images from the tag --write-images DIR Causes all attached images (APIC frames) to be written to the specified directory. --add-object OBJ_PATH:MIME-TYPE[:DESCRIPTION[:FILENAME]] Add or replace an object. There may be more than one object in a tag, as long as the DESCRIPTION values are unique. The default DESCRIPTION is ''. --remove-object DESCRIPTION Remove object matching DESCRIPTION. --write-objects DIR Causes all attached objects (GEOB frames) to be written to the specified directory. --remove-all-objects Remove all objects from the tag --add-popularity EMAIL:RATING[:PLAY_COUNT] Adds a pupularity metric. There may be multiples popularity values, but each must have a unique email address component. The rating is a number between 0 (worst) and 255 (best). The play count is optional, and defaults to 0, since there is already a dedicated play count frame. --remove-popularity EMAIL Removes the popularity frame with the specified email key. --remove-v1 Remove ID3 v1.x tag. --remove-v2 Remove ID3 v2.x tag. --remove-all Remove ID3 v1.x and v2.x tags. --remove-frame FID Remove all frames with the given ID. This option may be specified multiple times. --max-padding NUM_BYTES Shrink file if tag padding (unused space) exceeds the given number of bytes. (Useful e.g. after removal of large cover art.) Default is 64 KiB, file will be rewritten with default padding (1 KiB) or max padding, whichever is smaller. --no-max-padding Disable --max-padding altogether. --encoding latin1|utf8|utf16|utf16-be Set the encoding that is used for all text frames. This option is only applied if the tag is updated as the result of an edit option (e.g. --artist, --title, etc.) or --force-update is specified. Misc options: --force-update Rewrite the tag despite there being no edit options. -v, --verbose Show all available tag data --preserve-file-times When writing, do not update file modification times.
使ってみる
$ eyeD3 音楽ファイルパス
え……。できてないじゃん。
$ eyeD3 /tmp/音楽ファイル.wav Nothing to do
ネットで見たのと違う……。
ググってみると、MP3でないと使えないとか……。
MP3は音質が劣化するから嫌。wavでタグ情報つけたいのに。
ググってみると、FLACでないと無劣化&タグ付け仕様でないという。
- http://blog-sk.com/gadgets/instruments/audiofile_tag/
- https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q13140101678
そういうことは先に言ってくれ……。