Subsonic + Google Drive 스캔 문제 해결하기

category 서버/리눅스 서버 2019.02.03 20:16

이전 글에 이어서 작성되고 있습니다.


이전글 : https://blog.djjproject.com/511





1. 서브소닉 뮤직 스캔 알고리즘


경로 및 폴더의 시간이 전의 스캔 시간과 비교하여 최신일 경우 해당 폴더의 파일들을 점검합니다.


그럼.. 


Music/Artist/더크로스 이런식으로 2차 하위 폴더의 경우에도 시간 비교?? 이때는 시간비교가 일어나지 않습니다. 그냥 최상위에 존재하는 폴더들만 시간 체크를 하더군요.


이렇게 프로그램 작성이 되어 있는 것을 보니.. 아무래도 서브소닉의 뮤직 라이브러리 지정 경로에 그냥 앨범폴더들을 때려 넣어서 라이브러리를 구축하는 개념인것 같습니다.


root/

더크로스1집

소녀시대1집

소녀시대2집

트와이스1집

아이유미니앨범

.......



저는 아래와 같이 구성되어 있는데 서브소닉이 추구하는 라이브러리 느낌과는 조금 다른것 같네요. (파일 목록을 모두 보여주고 있습니다.)


root@debian-4350:/srv/rclone/100.djjproject/music# tree -L 1

.

├── Album

├── Artist

├── Favorite

├── Favorite2

├── Favorite3

├── Favorite4

├── Favorite5

├── Favorite6

├── Favorite7

├── Favorite8

├── Hi-Res Audio

├── Instrument

├── Night

├── OST

├── Others

├── Others2

├── Pop

├── temp

├── temp2

└── TOP100


20 directories, 0 files


이전 중고등학교 시절 MP3 의 폴더구조를 그대로 취하고 있어서 그렇습니다 ㅎㅎ.. 정리가 뒤죽박죽으로 되어 있는것은 어쩔 수 없네요.





2. 구글 드라이브 폴더 변경시각 조정하기


구글 드라이브의 폴더 마지막 수정시각을 변경하기 위해서는.. 폴더 이름의 변동이 있으면 반영이 됩니다.


즉.. 이렇게 하면 됩니다. 


1. rclone mount 를 통해 특정 폴더에 구글 드라이브를 마운트 해 둠.

2. bash 스크립트를 통해 특정 폴더를 이름을 바꿈

3. 다시 원복함


그럼 스크립트를 아주 간단하게 짜보겠습니다. 폴더 앞에 _ 를 붙였다가 뗏다가 하는 스크립트 입니다.


# 원본 : https://github.com/djjproject/scripts/blob/master/rclone/refresh_folder.sh


#!/bin/sh


# refresh music folder

cd /srv/rclone/100.djjproject/music

rename 's/^/_/' *

rename 's/_//' *


굉장히 간단하지 않습니까? 그냥 앞에 _ 붙였다가 지워주는 스크립트입니다. for 문 이나 아니면 rclone 내장 명령을 통해 마운트 없이 해결이 가능하지만, 쉘스크립트의 이런 정규식 문자에 거부감이 있는 관계로 쉽게 가기로 했습니다.


# 앞에 _이 다 붙은 작업 결과입니다.

root@debian-4350:/srv/rclone/100.djjproject/music# ls -li

total 1

 1608181092825948395 drwxr-xr-x 1 root root  0 Feb  3 04:25 _Album

18208484758366667343 drwxr-xr-x 1 root root  0 Feb  3 04:25 _Artist

 5228765231249168032 drwxr-xr-x 1 root root  0 Feb  3 04:25 _Favorite

15153367512342944278 drwxr-xr-x 1 root root  0 Feb  3 04:25 _Favorite2

15153368611854572489 drwxr-xr-x 1 root root  0 Feb  3 04:25 _Favorite3

15153369711366200700 drwxr-xr-x 1 root root  0 Feb  3 04:26 _Favorite4

15153370810877828911 drwxr-xr-x 1 root root  0 Feb  3 04:26 _Favorite5

15153371910389457122 drwxr-xr-x 1 root root  0 Feb  3 04:26 _Favorite6

15153373009901085333 drwxr-xr-x 1 root root  0 Feb  3 04:26 _Favorite7

15153374109412713544 drwxr-xr-x 1 root root  0 Feb  3 04:26 _Favorite8

16095734716962624866 drwxr-xr-x 1 root root  0 Feb  3 04:26 _Hi-Res Audio

 2218042089671094949 drwxr-xr-x 1 root root  0 Feb  3 04:27 _Instrument

12141081842044062866 drwxr-xr-x 1 root root  0 Feb  3 04:27 _Night

 8305595705514480043 -rw-r--r-- 1 root root 59 Jan 11 07:14 nohup.out

11066684412370487166 drwxr-xr-x 1 root root  0 Feb  3 04:27 _OST

10450806982829754391 drwxr-xr-x 1 root root  0 Feb  3 04:27 _Others

 3394443478105691871 drwxr-xr-x 1 root root  0 Feb  3 04:27 _Others2

 8214510570045246819 drwxr-xr-x 1 root root  0 Feb  3 04:27 _Pop

10112765581686583482 drwxr-xr-x 1 root root  0 Feb  3 04:27 _temp

12884910480434853656 drwxr-xr-x 1 root root  0 Feb  3 04:28 _temp2

15042338710566225162 drwxr-xr-x 1 root root  0 Feb  3 04:27 _TOP100


# 다시 _를 지우는 롤백 과정입니다.

root@debian-4350:/srv/rclone/100.djjproject/music# ls -li

total 1

 7475047031194035618 drwxr-xr-x 1 root root  0 Feb  3 20:09 Album

# 동시에 폴더 마지막 수정 시각이 현 시각으로 바뀜을 보실 수 있습니다.


    1647356844825076 drwxr-xr-x 1 root root  0 Feb  3 20:09 Artist

 9682295339621799267 drwxr-xr-x 1 root root  0 Feb  3 20:09 Favorite

16593333483761531043 drwxr-xr-x 1 root root  0 Feb  3 20:09 Favorite2

16593332384249902832 drwxr-xr-x 1 root root  0 Feb  3 20:09 Favorite3

16593340080831300309 drwxr-xr-x 1 root root  0 Feb  3 20:10 Favorite4

16593338981319672098 drwxr-xr-x 1 root root  0 Feb  3 20:10 Favorite5

16593337881808043887 drwxr-xr-x 1 root root  0 Feb  3 20:10 Favorite6

16593336782296415676 drwxr-xr-x 1 root root  0 Feb  3 04:26 Favorite7

16593344478877813153 drwxr-xr-x 1 root root  0 Feb  3 20:08 Favorite8

 3686060090997042489 drwxr-xr-x 1 root root  0 Feb  3 20:08 Hi-Res Audio

 8836302685661217622 drwxr-xr-x 1 root root  0 Feb  3 20:09 Instrument

 9740760370423683523 drwxr-xr-x 1 root root  0 Feb  3 20:09 Night

 8305595705514480043 -rw-r--r-- 1 root root 59 Feb  3 20:08 nohup.out

 1396140479092929387 drwxr-xr-x 1 root root  0 Feb  3 20:09 OST

 6467646489111146140 drwxr-xr-x 1 root root  0 Feb  3 20:09 Others

14542265509084647850 drwxr-xr-x 1 root root  0 Feb  3 20:09 Others2

14158335769167398366 drwxr-xr-x 1 root root  0 Feb  3 20:09 Pop

16033340419091382429 drwxr-xr-x 1 root root  0 Feb  3 20:09 temp

17396613552872450397 drwxr-xr-x 1 root root  0 Feb  3 20:09 temp2

 7349914195327842273 drwxr-xr-x 1 root root  0 Feb  3 20:09 TOP100


네트워크 속도에 따라 1분 내외로 걸리는 것 같습니다. rclone mv 를 이용했으면 조금 빨리도 가능했지 않았을까 합니다.





3. 서브소닉 스캔하기


1. 상기 리네임 스크립트를 12시쯤에 돌리고


2. 새벽 4시에 음악을 새로 스캔합니다. 


3. 어제의 경우 노래를 100곡 정도 추가한 상태에서 스캔을 돌린 결과입니다.


[2019-02-03 04:28:53,488] INFO MediaScannerService - Starting to scan media library.

[2019-02-03 04:30:47,371] INFO MediaScannerService - Scanned media library with 250 entries.

[2019-02-03 04:31:11,316] INFO MediaScannerService - Scanned media library with 500 entries.

[2019-02-03 04:31:11,754] INFO MediaScannerService - Scanned media library with 750 entries.

[2019-02-03 04:31:12,165] INFO MediaScannerService - Scanned media library with 1000 entries.

[2019-02-03 04:31:22,076] INFO MediaScannerService - Scanned media library with 1250 entries.

[2019-02-03 04:31:22,826] INFO MediaScannerService - Scanned media library with 1500 entries.

[2019-02-03 04:31:27,116] INFO MediaScannerService - Scanned media library with 1750 entries.

[2019-02-03 04:31:43,379] INFO MediaScannerService - Scanned media library with 2000 entries.

[2019-02-03 04:31:59,960] INFO MediaScannerService - Scanned media library with 2250 entries.

[2019-02-03 04:33:06,601] INFO MediaScannerService - Scanned media library with 2500 entries.

[2019-02-03 04:33:23,399] INFO MediaScannerService - Scanned media library with 2750 entries.

[2019-02-03 04:33:42,935] INFO MediaScannerService - Scanned media library with 3000 entries.

[2019-02-03 04:34:08,481] INFO MediaScannerService - Scanned media library with 3250 entries.

[2019-02-03 04:34:27,294] INFO MediaScannerService - Scanned media library with 3500 entries.

[2019-02-03 04:34:40,717] INFO MediaScannerService - Scanned media library with 3750 entries.

[2019-02-03 04:34:54,188] INFO MediaScannerService - Scanned media library with 4000 entries.

[2019-02-03 04:35:15,296] INFO MediaScannerService - Scanned media library with 4250 entries.

[2019-02-03 04:35:42,299] INFO MediaScannerService - Scanned media library with 4500 entries.

[2019-02-03 04:35:58,416] INFO MediaScannerService - Scanned media library with 4750 entries.

[2019-02-03 04:36:16,107] INFO MediaScannerService - Scanned media library with 5000 entries.

[2019-02-03 04:36:51,085] INFO MediaScannerService - Scanned media library with 5250 entries.

[2019-02-03 04:37:27,386] INFO MediaScannerService - Scanned media library with 5500 entries.

[2019-02-03 04:37:49,908] INFO MediaScannerService - Scanned media library with 5750 entries.

[2019-02-03 04:38:16,217] INFO MediaScannerService - Scanned media library with 6000 entries.

[2019-02-03 04:38:35,981] INFO MediaScannerService - Scanned media library with 6250 entries.

[2019-02-03 04:38:55,246] INFO MediaScannerService - Scanned media library with 6500 entries.

[2019-02-03 04:39:20,368] INFO MediaScannerService - Scanned media library with 6750 entries.

[2019-02-03 04:39:38,607] INFO MediaScannerService - Scanned media library with 7000 entries.

[2019-02-03 04:40:00,275] INFO MediaScannerService - Scanned media library with 7250 entries.

[2019-02-03 04:40:21,604] INFO MediaScannerService - Scanned media library with 7500 entries.

[2019-02-03 04:40:43,559] INFO MediaScannerService - Scanned media library with 7750 entries.

[2019-02-03 04:40:59,433] INFO MediaScannerService - Scanned media library with 8000 entries.

[2019-02-03 04:41:09,774] INFO MediaScannerService - Scanned media library with 8250 entries.

[2019-02-03 04:41:30,481] INFO MediaScannerService - Scanned media library with 8500 entries.

[2019-02-03 04:41:40,866] INFO MediaScannerService - Scanned media library with 8750 entries.

[2019-02-03 04:41:59,593] INFO MediaScannerService - Scanned media library with 9000 entries.

[2019-02-03 04:42:08,710] INFO MediaScannerService - Scanned media library with 9250 entries.

[2019-02-03 04:42:16,162] INFO MediaScannerService - Scanned media library with 9500 entries.

[2019-02-03 04:42:25,374] INFO MediaScannerService - Scanned media library with 9750 entries.

[2019-02-03 04:42:33,563] INFO MediaScannerService - Scanned media library with 10000 entries.

[2019-02-03 04:42:44,137] INFO MediaScannerService - Scanned media library with 10250 entries.

[2019-02-03 04:42:53,771] INFO MediaScannerService - Scanned media library with 10500 entries.

[2019-02-03 04:43:00,271] INFO MediaScannerService - Scanned media library with 10750 entries.

[2019-02-03 04:43:08,047] INFO MediaScannerService - Scanned media library with 11000 entries.

[2019-02-03 04:43:14,166] INFO MediaScannerService - Scanned media library with 11250 entries.

[2019-02-03 04:43:20,037] INFO MediaScannerService - Scanned media library with 11500 entries.

[2019-02-03 04:43:27,663] INFO MediaScannerService - Scanned media library with 11750 entries.

[2019-02-03 04:43:28,632] INFO MediaScannerService - Scanned media library with 12000 entries.

[2019-02-03 04:43:29,273] INFO MediaScannerService - Scanned media library with 12250 entries.

[2019-02-03 04:43:29,960] INFO MediaScannerService - Scanned media library with 12500 entries.

[2019-02-03 04:43:30,623] INFO MediaScannerService - Scanned media library with 12750 entries.

[2019-02-03 04:43:38,043] INFO MediaScannerService - Scanned media library with 13000 entries.

[2019-02-03 04:43:44,126] INFO MediaScannerService - Scanned media library with 13250 entries.

[2019-02-03 04:43:52,813] INFO MediaScannerService - Scanned media library with 13500 entries.

[2019-02-03 04:44:01,082] INFO MediaScannerService - Scanned media library with 13750 entries.

[2019-02-03 04:44:05,064] INFO MediaScannerService - Scanned media library with 14000 entries.

[2019-02-03 04:44:17,873] INFO MediaScannerService - Scanned media library with 14250 entries.

[2019-02-03 04:44:21,243] INFO MediaScannerService - Scanned media library with 14500 entries.

[2019-02-03 04:44:25,275] INFO MediaScannerService - Scanned media library with 14750 entries.

[2019-02-03 04:44:28,379] INFO MediaScannerService - Scanned media library with 15000 entries.

[2019-02-03 04:44:32,874] INFO MediaScannerService - Scanned media library with 15250 entries.

[2019-02-03 04:44:36,453] INFO MediaScannerService - Scanned media library with 15500 entries.

[2019-02-03 04:44:40,878] INFO MediaScannerService - Scanned media library with 15750 entries.

[2019-02-03 04:44:43,409] INFO MediaScannerService - Scanned media library with 16000 entries.

[2019-02-03 04:44:47,023] INFO MediaScannerService - Scanned media library with 16250 entries.

[2019-02-03 04:44:48,586] INFO MediaScannerService - Scanned media library with 16500 entries.

[2019-02-03 04:44:52,232] INFO MediaScannerService - Scanned media library with 16750 entries.

[2019-02-03 04:44:55,756] INFO MediaScannerService - Scanned media library with 17000 entries.

[2019-02-03 04:44:58,756] INFO MediaScannerService - Scanned media library with 17250 entries.

[2019-02-03 04:45:04,734] INFO MediaScannerService - Scanned media library with 17500 entries.

[2019-02-03 04:45:07,862] INFO MediaScannerService - Scanned media library with 17750 entries.

[2019-02-03 04:45:14,618] INFO MediaScannerService - Scanned media library with 18000 entries.

[2019-02-03 04:45:16,932] INFO MediaScannerService - Scanned media library with 18250 entries.

[2019-02-03 04:45:22,433] INFO MediaScannerService - Scanned media library with 18500 entries.

[2019-02-03 04:45:25,765] INFO MediaScannerService - Scanned media library with 18750 entries.

[2019-02-03 04:45:31,470] INFO MediaScannerService - Scanned media library with 19000 entries.

[2019-02-03 04:45:34,456] INFO MediaScannerService - Scanned media library with 19250 entries.

[2019-02-03 04:45:39,224] INFO MediaScannerService - Scanned media library with 19500 entries.

[2019-02-03 04:45:41,568] INFO MediaScannerService - Scanned media library with 19750 entries.

[2019-02-03 04:45:47,781] INFO MediaScannerService - Scanned media library with 20000 entries.

[2019-02-03 04:45:51,064] INFO MediaScannerService - Scanned media library with 20250 entries.

[2019-02-03 04:46:00,277] INFO MediaScannerService - Scanned media library with 20500 entries.

[2019-02-03 04:46:11,185] INFO MediaScannerService - Scanned media library with 20750 entries.

[2019-02-03 04:46:19,155] INFO MediaScannerService - Scanned media library with 21000 entries.

[2019-02-03 04:46:22,615] INFO MediaScannerService - Scanned media library with 21250 entries.

[2019-02-03 04:54:09,993] INFO MediaScannerService - Scanned media library with 21500 entries.

[2019-02-03 04:54:10,978] INFO MediaScannerService - Scanned media library with 21750 entries.

[2019-02-03 04:54:11,951] INFO MediaScannerService - Scanned media library with 21981 entries.

[2019-02-03 04:54:11,951] INFO MediaScannerService - Marking non-present files.

[2019-02-03 04:54:14,652] INFO MediaScannerService - Marking non-present artists.

[2019-02-03 04:54:14,714] INFO MediaScannerService - Marking non-present albums.

[2019-02-03 04:54:14,917] INFO MediaScannerService - Completed media library scan.

[2019-02-03 04:54:15,073] INFO PlaylistService - Starting playlist import.

[2019-02-03 04:54:15,073] INFO PlaylistService - Completed playlist import.


스캔시간이 26분 정도 걸렸습니다. 이전에는 100곡 추가했다고 처음부터 스캔을 했었어야 됬는데 빠르게 추가분에 대해서 대응을 할 수 있게 되었습니다.


음악 라이브러리는 항상 늘고 있습니다.


20000만 곡 정도 넘어가면 문제가 있을 수 있다고 하는데 아직 문제가 발생하지 않았습니다.



감사합니다.


댓글을 달아 주세요