Giter Site home page Giter Site logo

adb-music-file-updater's Introduction

adb-music-file-updater

adbを使ってAndroid内の音楽ファイルを最新の状態に更新します。
adb push [PCディレクトリ] [Androidディレクトリ]やその前段階の確認を便利にやってくれるよというコマンド郡になっています。

Installation

adb

使うコマンドはadb pushadb shellくらいのものなので、
apt install android-tools-adb等のコマンドで導入しても動作するでしょう。

ただ、Android 11 以降はWi-Fi環境越しにadbを使用するadb pair -> adb connectが使えるようになって便利なので、
SDK Platform-Tools リリースノートからzipファイルをDLして、パスの通ったディレクトリに放り込む導入すると、最新版を扱えます。
ワイヤレス環境に対応すると幸せになれるかもしれません。

ワイヤレス環境の設定は下記の記事が参考になるでしょう。

babashka

Clojureをローカルで簡易的に動作させるスクリプト言語babashkaを利用しています。
下記のリンクからbabashkaをインストールしてください。

download

$ git clone [email protected]:miyabisun/adb-music-file-updater.git

$ cd adb-music-file-updater.git

Usage

settings.yml の修正

$ cp settings.sample.yml settings.yml

$ cat settings.yml
dir:
  source: /path/to/music
  dist: /storage/emulated/0/Music
  • source: PCのディレクトリを指します
    • iTunesのインストール場所を確認してそのPathを格納してください
  • dist: Android内のディレクトリを指します
    • 初期値はPixel 7の場合はこのディレクトリに入れてください的な場所です

音楽ファイル達のコピー

実行ファイルの bin/push を叩くとコピーを実行します。 でもその前に、bin/checkを実行して、コピーできそうなのか?を確認してみましょう。

$ bin/check
=== local ===

=> du -hs /path/to/music
39G     /path/to/music

=== android ===

=> df -h /storage/emulated/0/Music
Filesystem      Size Used Avail Use% Mounted on
/dev/fuse       229G  85G  144G  38% /storage/emulated

=> du -hs /storage/emulated/0/Music/aac
0G     /storage/emulated/0/Music

今回の例だとAndroid端末のAvail(空き容量)は144GBで、
ローカルマシンの音楽ディレクトリの必要量は39GBです。
これによりどうやら全部入れても余裕がありそうだという事がわかります。

それでは、今度こそ bin/push コマンドを使いAndroid端末に音楽ファイルを流し込んでいきましょう。

$ bin/push
/path/to/music/./: 6424 files pushed, 0 skipped. 55.4 MB/s (41166380114 bytes in 709.271s)
finished

その他の便利コマンド

has

現在所持しているアルバムの一覧をYAML形式で出力します。
iTunes は音楽ファイルをディレクトリ区切りで アーティスト名 / アルバム名 / 楽曲名 の階層構造で管理しています。

$ bin/has
- {artist: "artist A", album: "album A"}
- {artist: "artist B", album: "album B"}
...

$ bin/has > albums.yml

now

こちらはAndroid端末内のファイルを確認します。

$ bin/now
- {artist: "artist A", album: "album A"}
- {artist: "artist B", album: "album B"}
...

$ bin/now > pushed.yml

clean

⚠️ 最悪Android端末の重要ファイルを削除して動作しなくなる危険があります。 十分に設定を確認して実行してください。

adb shell rm -rf [対象のディレクトリ]/* コマンドを発行して、 中のファイル全てを掃除します。

check

dfduコマンドを利用して、現在の状態を確認します。

$ bin/check
=== local ===

=> du -hs /path/to/music
39G     /path/to/music

=== android ===

=> df -h /storage/emulated/0/Music
Filesystem      Size Used Avail Use% Mounted on
/dev/fuse       229G  85G  144G  38% /storage/emulated

=> du -hs /storage/emulated/0/Music/aac
0G     /storage/emulated/0/Music

adb-music-file-updater's People

Contributors

miyabisun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.