カットの下には、
ソースデータ
つまり、Ubuntu Server 12.04LTS、Deluge 1.3.5、およびWebインターフェイスを備えたPlex Media Server 0.9.7.28を備えたヘッドレスマシンです。 まず、ミニTKを作成します
アクションのシーケンス:
- 新たにダウンロードされたトレントに関するデータを処理し、* .mkvファイルのリストを分離します。
- 字幕抽出;
- Plexのライブラリの更新。
私がしたい:
- 特定の言語の字幕のみを抽出できる;
- スクリプトを任意のファイルに手動でフィードできるようにします。
大洪水のフック
基本的なDelugeのインストールには、トレントを追加したりダウンロードを完了したりするときに任意のスクリプトを実行できるExecuteプラグインがあります(ドキュメントとサンプルはこちらで確認できます )。 渡される引数の正確な形式にのみ興味があり、その説明はmanではなく、テストスクリプトを使用して簡単に取得できる例です。
#!/bin/bash echo -e "$1\n$2\n$3" >> /specshare/sample.txt
testhook.shという名前でパブリックディレクトリ(このためにカスタムディレクトリ/ specshareを使用)にスクリプトを保存し、次を使用して必要な実行権限を付与します。
sudo chmod +x testhook.sh
次に、スクリプトを接続する必要があります。 Delugeへのリモートアクセスには、GTKクライアントを使用します。アクションのシーケンスは次のとおりです。
- Edit-Preferences-Pluginsを開き、Executeの前にチェックマークを付けます。その後、対応するアイテムがCategoriesパネルに表示されます。
- [実行]セクションの[イベント]コンボボックスで、Torrent Completeを設定し、[コマンド]フィールドでスクリプトへのパスを指定します。
- [追加]、[OK]の順にクリックして、デーモンを再起動します。
sudo service deluged restart
最後の手順が必要です。そうしないと、設定に正しく表示されている間、スクリプトは呼び出されません。 ダウンロードに小さなトレントを追加して、 sample.txtファイルのようなものを取得します。
1759d534dbe371565632ec0cccbb1579d344c5ca
Totally.Legal.Open.Source.Software.iso
/ストア/ distribs
最初のパラメーターは、デーモンから追加情報を要求できるようにするユニバーサルトレント識別子です。 2番目はトレントの名前です。 原則として、これはファイル名またはディレクトリ名のいずれかです(ディストリビューションに複数のファイルがある場合)。 3番目は、トレントの親フォルダーの名前です。
入力パラメータがどのように見えるかがわかったので、 testhook.shが存在していたのと同じディレクトリに2つのファイル、 extractor.shとdeluge-movie-callback.shを作成しましょう。 最初のスクリプトは字幕の直接抽出を担当します。少し後にスクリプトに戻り、2番目のファイルでは次を紹介します。
#!/bin/bash torrentname=$2; torrentpath=$(readlink -f "$3"); fullpath="$torrentpath/$torrentname"; echo "============================" >> /specshare/log.txt; echo "$(date +"%D %T"): $1 $2 $3" >> /specshare/log.txt; echo "$(date +"%D %T"): $fullpath" >> /specshare/log.txt; if [[ "$fullpath" != /store/films/* ]]; then echo "$(date +"%D %T"): Invalid path" >> /specshare/log.txt; exit 0; fi; echo "$(date +"%D %T"): path ok" >> /specshare/log.txt; mkvlist=$(find "$fullpath" -type f | grep .mkv); while read -r fname; do /specshare/extractor.sh "$fname" "eng,rus,unk"; done <<< "$mkvlist";
ここでは特に複雑なことは何も起こりません-引数$ 3と$ 2から完全なファイル名を接着し、シンボリックリンク(ある場合)を解決し、パスを検証します(映画と、 / store / filmsディレクトリにのみダウンロードされ、残りのビデオファイルには字幕は不要です)結果のパスについて、添付されているすべてのmkvファイルをリクエストします。 その後、各.mkvに対してextractor.shを実行し、必要な言語のパスとISO 639-1コードのリストをパラメーターとして渡します。 「Unk」は、字幕付きの一部のストリームで指定されていない場合に備えて、欠落している言語に対する独自の指定です。 スクリプトの実行が記録されます。
ログに関する小さなメモ
一般に、どこにでもログを書き込むことは良くありませんが、アクセスのしやすさと単純さのために正確さを犠牲にします(私の場合、specshareはsambaを介して共有され、Windowsデスクトップでは最小限の身体の動きで利用可能です)。
字幕抽出
字幕付きのトラックを抽出するには、 mkvtoolnixパッケージを使用します。 インストールは簡単です:
sudo apt-get install mkvtoolnix
mkvmergeとmkvextractの 2つのユーティリティに興味があります 。 最初の方法では、コンテナ内のスレッドのリストを取得できます。
mkvmerge -I <filename>
正式には、同じパッケージのmkvinfoユーティリティがこの目的を目的としていますが、 mkvmergeの出力はより簡潔で、解析がはるかに簡単です。 出力では、次のリストのようなものが得られます。
トラックID 1:ビデオ(V_MPEG4 / ISO / AVC)[言語:eng track_name:\ sMatrix \ s1999 \ s1080p \ sBluRay \ sDD5.1 \ sx264-CtrlHD display_dimensions:1280x532 default_track:0 forced_track:0 packetizer:mpeg4_p10_video default 32 ]
トラックID 2:オーディオ(A_AC3)[言語:rus track_name:DUB-Blu-ray default_track:1 forced_track:0 default_duration:32000000 audio_sampling_frequency:48000 audio_channels:6]
<多くの興味深いオーディオトラック...>
トラックID 9:オーディオ(A_DTS)[言語:eng track_name:元のdefault_track:0 forced_track:0 default_duration:10666666 audio_sampling_frequency:48000 audio_channels:6]
トラックID 10:字幕(S_TEXT / UTF8)[言語:rus track_name:Sub default_track:0 forced_track:0]
トラックID 11:字幕(S_TEXT / UTF8)[言語:rus track_name:サブ-(ゴブリンの\ s \ 2正しい\ 2 \ s翻訳\ sによる)default_track:0 forced_track:0]
トラックID 12:字幕(S_TEXT / UTF8)[言語:eng track_name:Sub default_track:0 forced_track:0]
トラックID 13:字幕(S_TEXT / UTF8)[言語:eng track_name:Sub-SDH default_track:0 forced_track:0]
タイプサブタイトルとコーデックS_TEXT / UTF8のストリームに興味があります。そのためには、TrackIDと言語コードが必要です。 S_TEXT / UTF8に加えて、S_HDMV / PGSでエンコードされた字幕を見ましたが、これはまれな鳥であり、srtへの変換が必要なので、このタイプの字幕は考慮しません。 興味のある方は、 BDSup2Subユーティリティに注意を払ってください 。
ストリームを直接抽出するには、次を使用します。
mkvextract tracks <filename> <trackId>:<subname>
最初の2つのパラメーター(TrackIDとコンテナーファイルの名前)は非常に明白ですが、3番目のパラメーター(字幕付きのファイルの名前)では、もう少し複雑です。 ここで、少しの間一時停止し、Plexで外部字幕の命名規則を理解する必要があります。
仕様によると、字幕名は次の形式である必要があります
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
-
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media ServerPlex Media Scanner
,/usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2sudoers
- sudo. ,LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , csudo su - .
-
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media ServerPlex Media Scanner
,/usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2sudoers
- sudo. ,LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , csudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media Server Plex Media Scanner
, /usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2 sudoers
- sudo. , LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL ?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , c sudo su - .
-
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media ServerPlex Media Scanner
,/usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2sudoers
- sudo. ,LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , csudo su - .
-
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media ServerPlex Media Scanner
,/usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2sudoers
- sudo. ,LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , csudo su - .
-
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media ServerPlex Media Scanner
,/usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2sudoers
- sudo. ,LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , csudo su - .
-
..srt,
. , . , - , , ( ). : , - . , , .
extractor.sh :
#!/bin/bash if [[ "$1" != *.mkv ]]; then exit 0; fi; FORMAT_FULL=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\).*language:([[:alpha:]]+)"; FORMAT_SHORT=".*ID[[:space:]]([[:digit:]]+):[[:space:]]([[:alpha:]]+)[[:space:]]\((.*)\)"; baseName=${1%.mkv}; requiredLangs=$(echo "$2" | tr "," "\n"); echo "$(date +"%D %T"): $baseName" >> /specshare/log.txt; counter=0; tracks=$(mkvmerge -I "$1"); while read -r track; do echo -e "$(date +"%D %T"): $track" >> /specshare/log.txt; if [[ $track =~ $FORMAT_FULL ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; lang=${BASH_REMATCH[4]}; codec=${BASH_REMATCH[3]}; else if [[ $track =~ $FORMAT_SHORT ]]; then id=${BASH_REMATCH[1]}; tType=${BASH_REMATCH[2]}; codec=${BASH_REMATCH[3]}; lang="unk"; else id=-1; fi fi; langMatch=false; idMatch=false; typeMatch=false; codecMatch=false; shouldExtract=false; for reqLang in $requiredLangs; do [ "$reqLang" == "$lang" ] && langMatch=true; done [ "$tType" == "subtitles" ] && typeMatch=true; [ "$codec" == "S_TEXT/UTF8" ] && codecMatch=true; [ $id -ne -1 ] && idMatch=true; $langMatch && $idMatch && $typeMatch && $codecMatch && shouldExtract=true; if $shouldExtract ; then subName="$baseName.$lang.srt" if [ -f "$subName" -o "$lang" == "unk" ]; then subName="$baseName.$lang$counter.srt"; (( counter++ )); fi mkvextract tracks "$1" $id:"$subName"; fi done <<< "$tracks"
: , , //, . , capturing groups POSIX- , , , . , .
, . - Plex.
Plex Media ServerPlex Media Scanner
,/usr/lib/plexmediaserver/
, . , :
; - , - PMS;
, . 2sudoers
- sudo. ,LD_LIBRARY_PATH
( 1) Deluge, , .
, , , ...
GET-
- PMS, UI , GET- URL . URL :
http://<serverIP>:32400/library/sections/<sectionId>/refresh
sectionId
- PMS. , -
- 3.
, , deluge-movie-callback.sh -
wget -qO - http://192.168.13.1:32400/library/sections/3/refresh >> /dev/null ;
URL?deep=1
?force=1
.
, deluge-movie-callback.sh Execute. , .
.
. , , , - , . - , . , . Deluge , , . Label. , , , , deluged , . , csudo su - .