CentOS8で構築する自宅サーバ:StreamRipperコマンド追加

今回は、趣向を変えて、コマンドのインストールです。

昔からshoutcastを使ったインターネットラジオを聞いています。このコマンドはインターネットラジオで流れている音楽を、mp3ファイルとして録音してくれるコマンドです。

今どきはストリーミングで聴くのでしょうが、自分の場合、特にこだわりがないので、「手間がかからず」「飽きないように音楽を入れ替えて」「音楽だけを聞いていたい」ので、インターネットラジオのほうが好みです。

サーバで録りためた音楽ファイルをスマホに持ち出して聞いていれば、ストリーミングよりバッテリーもギガも減らないというのもあります。

公式サイトからソースをダウンロード

公式サイトはこちら

ここからソースをダウンロードし、展開します。

[root@ace zeke]# cd /usr/local/src/
[root@ace src]# wget https://sourceforge.net/projects/streamripper/files/streamripper%20%28current%29/1.64.6/streamripper-1.64.6.tar.gz/download
--2020-02-27 22:00:25--  https://sourceforge.net/projects/streamripper/files/streamripper%20%28current%29/1.64.6/streamripper-1.64.6.tar.gz/download
:
省略
:
jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)|2001:df0:2ed:feed::feed|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 900205 (879K) [application/x-gzip]
`download' に保存中

download            100%[===================>] 879.11K  2.94MB/s 時間 0.3s

2020-02-27 22:00:28 (2.94 MB/s) - `download' へ保存完了 [900205/900205]

[root@ace src]# ls download
download
[root@ace src]# mv download streamripper-1.64.6.tar.gz
[root@ace src]# tar xfz streamripper-1.64.6.tar.gz
[root@ace src]#

コンパイルとインストール

展開したソースに降りて

[root@ace src]# cd streamripper-1.64.6
[root@ace streamripper-1.64.6]# ./configure --help
`configure' configures streamripper 1.64.6 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/streamripper]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-dependency-tracking  speeds up one-time build
  --enable-dependency-tracking   do not reject slow dependency extractors
  --disable-glibtest      do not try to compile and run a test GLIB program
  --disable-rpath         do not hardcode runtime library paths
  --disable-oggtest       Do not try to compile and run a test Ogg program
  --disable-vorbistest       Do not try to compile and run a test Vorbis program

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-included-libmad use the libmad library included with streamripper
  --with-included-argv use argv.c included with streamripper
  --with-curses(=XXX) compile curses front-end (XXX is curses (default), ncurses, ncursesw, pdcurses or slang)
  --with-gnu-ld           assume the C compiler uses GNU ld default=no
  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib
  --without-libiconv-prefix     don't search for libiconv in includedir and libdir
  --with-curses-dir=DIR   directory in which (n)curses is installed
  --with-ogg=PFX   Prefix where libogg is installed (optional)
  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)
  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)
  --with-vorbis=PFX   Prefix where libvorbis is installed (optional)
  --with-vorbis-libraries=DIR   Directory where libvorbis library is installed (optional)
  --with-vorbis-includes=DIR   Directory where libvorbis header files are installed (optional)

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  PKG_CONFIG  path to pkg-config utility

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

[root@ace streamripper-1.64.6]#

./configureのオプションをチェックです。デフォルトで/usr/localにインストールするみたいですね。このままで良いでしょう。「Optional Features」をチェックしても、変更が必要なところはなさそうです。

[root@ace streamripper-1.64.6]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
:
省略
:
checking pkg-config is at least version 0.7... yes
checking for GLIB - version >= 2.16.0... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error: Glib 2.16 or greater required
[root@ace streamripper-1.64.6]#

./configureでエラーになってしまいました。「GLIB」がないっ!って言っているようです。

[root@ace streamripper-1.64.6]# rpm -qa| grep ^glib
glibc-langpack-ja-2.28-72.el8_1.1.x86_64
glibc-devel-2.28-72.el8_1.1.x86_64
glib2-2.56.4-7.el8.x86_64
glibc-common-2.28-72.el8_1.1.x86_64
glibc-2.28-72.el8_1.1.x86_64
glibc-headers-2.28-72.el8_1.1.x86_64
[root@ace streamripper-1.64.6]#

パッケージをチェックすると、glib2はありますが、開発用(コンパイルするときに必要な)glib2-develがないみたいですね。これを入れてみましょう。

[root@ace streamripper-1.64.6]# dnf install glib2-devel
:
省略
:
インストール済み:
  glib2-devel-2.56.4-7.el8.x86_64          pcre-cpp-8.42-4.el8.x86_64
  pcre-devel-8.42-4.el8.x86_64             pcre-utf16-8.42-4.el8.x86_64
  pcre-utf32-8.42-4.el8.x86_64

完了しました!
[root@ace streamripper-1.64.6]#

もう一度./configureです。

[root@ace streamripper-1.64.6]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
:
省略
:
config.status: executing depfiles commands
* Streamripper configuration
    Using included MAD library?      yes
    Ogg/vorbis support?              no
[root@ace streamripper-1.64.6]#

今度はエラーなく終了しました。バッチリです。

[root@ace streamripper-1.64.6]# make
Making all in libmad-0.15.1b
make[1]: ディレクトリ '/usr/local/src/streamripper-1.64.6/libmad-0.15.1b' に入ります
(sed -e '1s|.*|/*|' -e '1b' -e '$s|.*| */|' -e '$b'  \
        -e 's/^.*/ *&/' ./COPYRIGHT; echo;  \
echo "# ifdef __cplusplus";  \
:
省略
:
gcc  -g -O2 -Wall   -o streamripper streamripper.o argv.o lib/libstreamripper.a libmad-0.15.1b/.libs/libmad.a -lpthread -lglib-2.0  -lm
make[1]: ディレクトリ '/usr/local/src/streamripper-1.64.6' から出ます
[root@ace streamripper-1.64.6]#

問題なくコンパイル完了です。

[root@ace streamripper-1.64.6]# make install
Making install in libmad-0.15.1b
:
省略
:
make[2]: ディレクトリ '/usr/local/src/streamripper-1.64.6' から出ます
make[1]: ディレクトリ '/usr/local/src/streamripper-1.64.6' から出ます
[root@ace streamripper-1.64.6]#

[root@ace streamripper-1.64.6]# ls /usr/local/bin/
streamripper
[root@ace streamripper-1.64.6]# ls /usr/local/share/man/man1
streamripper.1
[root@ace streamripper-1.64.6]#

インストールも完了。/usr/local/binにコマンドが、/usr/local/share/man/man1にマニュアルがインストールされました。

動作確認!

[root@ace streamripper-1.64.6]# streamripper --help
Can't parse command option: --help
[root@ace streamripper-1.64.6]# streamripper -h
Usage: streamripper URL [OPTIONS]
Opts: -h             - Print this listing
      -v             - Print version info and quit
      -a [file]      - Rip to single file, default name is timestamped
      -A             - Don't write individual tracks
      -d dir         - The destination directory
      -D pattern     - Write files using specified pattern
      -s             - Don't create a directory for each stream
      -r [[ip:]port] - Create relay server on base ip:port, default port 8000
      -R #connect    - Max connections to relay, default 1, -R 0 is no limit
      -L file        - Create a relay playlist file
      -z             - Don't scan for free ports if base port is not avail
      -p url         - Use HTTP proxy server at <url>
      -o (always|never|larger|version)    - When to write tracks in complete
      -t             - Don't overwrite tracks in incomplete
      -c             - Don't auto-reconnect
      -l seconds     - Number of seconds to run, otherwise runs forever
      -M megabytes   - Stop ripping after this many megabytes
      -q [start]     - Add sequence number to output file
      -u useragent   - Use a different UserAgent than "Streamripper"
      -w rulefile    - Parse metadata using rules in file.
      -m timeout     - Number of seconds before force-closing stalled conn
      -k count       - Leave <count> tracks in incomplete
      -I interface   - Rip from specified interface (e.g. eth0)
      -T             - Truncate duplicated tracks in incomplete
      -E command     - Run external command to fetch metadata
      --quiet        - Don't print ripping status to console
      --stderr       - Print ripping status to stderr (old behavior)
      --debug        - Save debugging trace
ID3 opts (mp3/aac/nsv):  [The default behavior is adding ID3V2.3 only]
      -i                           - Don't add any ID3 tags to output file
      --with-id3v1                 - Add ID3V1 tags to output file
      --without-id3v2              - Don't add ID3V2 tags to output file
Splitpoint opts (mp3 only):
      --xs-none                    - Don't search for silence
      --xs-offset=num              - Shift relative to metadata (msec)
      --xs-padding=num:num         - Add extra to prev:next track (msec)
      --xs-search-window=num:num   - Search window relative to metadata (msec)
      --xs-silence-length=num      - Expected length of silence (msec)
      --xs2                        - Use new algorithm for silence detection
Codeset opts:
      --codeset-filesys=codeset    - Specify codeset for the file system
      --codeset-id3=codeset        - Specify codeset for id3 tags
      --codeset-metadata=codeset   - Specify codeset for metadata
      --codeset-relay=codeset      - Specify codeset for the relay stream
[root@ace streamripper-1.64.6]#

ヘルプをチェックして、どんなオプションがあるのかを確認します。

[root@ace streamripper-1.64.6]# exit
[zeke@ace ~]$ cd
[zeke@ace ~]$ mkdir StreamRipper
[zeke@ace ~]$ cd StreamRipper/
[zeke@ace StreamRipper]$ mkdir Radio
[zeke@ace StreamRipper]$ cd Radio/
[zeke@ace Radio]$ /usr/local/bin/streamripper http://animeradio.su:8000/ -d /home/zeke/StreamRipper/ -l 9000 -c -q -u "VLC/2.2.6 LibVLC/2.2.6"
Connecting...
stream: AnimeRadio.SU
server name: SHOUTcast/Linux v1.9.8
declared bitrate: 128
meta interval: 32768

[skipping...   ] Shade IM - Iineaaiee iieao [  737kb]
[ripping...    ] ChouCho - Ano Sora ni Kaeru Mirai de [  4.41M]
[ripping...    ] Koike Joanna - RunOver [  3.40M]
[ripping...    ] surface - -Monochro Caspsule- [  4.20M]
[ripping...    ] Daisuke - Itsudatte. [  4.56M]
[ripping...    ] B'z - Everlasting [  3.35M]
[ripping...    ] Hirano Aya - God Knows [  4.27M]
[ripping...    ] Slayers Perfect - Midnight Blue [  5.07M]
[ripping...    ] Mike Wyzgowski - Nothing Can Be Explained [  3.18M]
[ripping...    ] Taniuchi Hideki - Shinigami Kai B [  2.26M]
[ripping...    ] Mimori Suzuko & Tokui Sora & S - Seikai wa Hitotsu [  3.69M]
[ripping...    ] Hayashibara Megumi - Touch Yourself [  4.72M]
[ripping...    ] Choucho - Niji no Asa ni [  3.76M]
[ripping...    ] Ichiko - RISE [  3.90M]

なんとなく、ちゃんと動きました!mp3ファイルをパソコンに転送して再生もできます!

StreamRipperの良いところは、1曲づつ1ファイルに分けてくれるところです。タイトルとアーティスト名をID3タグに入れてくれるので、どの曲かもわかりやすいです。

eyed3ツールを追加

ついでに、ID3タグを編集するツールを追加です。

[root@ace ~]#
[root@ace ~]# pip3 install eyed3
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting eyed3
  Downloading https://files.pythonhosted.org/packages/93/7a/275442cfdcc87407d8f9cc683208ab80c85157bc9e8ecfbfd54b6e61aef2/eyeD3-0.9.2-py2.py3-none-any.whl (141kB)
    100% |????????????????????????????????| 143kB 5.9MB/s
Collecting dataclasses; python_version < "3.7" (from eyed3)
  Downloading https://files.pythonhosted.org/packages/e1/d2/6f02df2616fd4016075f60157c7a0452b38d8f7938ae94343911e0fb0b09/dataclasses-0.7-py3-none-any.whl
Collecting filetype (from eyed3)
  Downloading https://files.pythonhosted.org/packages/1c/78/047cf0f371f8faafab05b5062f902d4bedd945d436544b30db692622ab84/filetype-1.0.5-py2.py3-none-any.whl
Collecting deprecation (from eyed3)
  Downloading https://files.pythonhosted.org/packages/b9/2a/d5084a8781398cea745c01237b95d9762c382697c63760a95cc6a814ad3a/deprecation-2.0.7-py2.py3-none-any.whl
Collecting packaging (from deprecation->eyed3)
  Downloading https://files.pythonhosted.org/packages/98/42/87c585dd3b113c775e65fd6b8d9d0a43abe1819c471d7af702d4e01e9b20/packaging-20.1-py2.py3-none-any.whl
Collecting pyparsing>=2.0.2 (from packaging->deprecation->eyed3)
  Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
    100% |????????????????????????????????| 71kB 8.6MB/s
Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from packaging->deprecation->eyed3)
Installing collected packages: dataclasses, filetype, pyparsing, packaging, deprecation, eyed3
Successfully installed dataclasses-0.7 deprecation-2.0.7 eyed3-0.9.2 filetype-1.0.5 packaging-20.1 pyparsing-2.4.6
[root@ace ~]#

こんな風にmp3ファイルのID3タグを編集します。

[zeke@ace StreamRipper]$ eyeD3 -A AnimeRadio.SU -G 145 --add-image gar.png:OTHER AnimeRadio.SU/0028_Kae\ Hanazawa\ -\ Sailor\ Star\ Song.mp3
...amRipper/AnimeRadio.SU/0028_Kae Hanazawa - Sailor Star Song.mp3  [ 3.54 MB ]
--------------------------------------------------------------------------------
Setting album: AnimeRadio.SU
Setting genre: 145
Adding image gar.png
Time: 03:52     MPEG1, Layer III        [ 128 kb/s @ 44100 Hz - Joint stereo ]
--------------------------------------------------------------------------------
ID3 v2.3:
title: Sailor Star Song
artist: Kae Hanazawa
album: AnimeRadio.SU
track: 29               genre: Anime (id 145)
OTHER Image: [Size: 93635 bytes] [Type: image/png]
Description:

Writing ID3 version v2.3
--------------------------------------------------------------------------------
[zeke@ace StreamRipper]$

アルバムとジャンル、イメージを追加しました。こちらもパソコン上で確認してOKです!

Kindle Unlimited入会で無料で読めます!

コメント