-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/config/channels/scan
エンドポイントにBS/CSチャンネルスキャン機能を追加する
#79
/config/channels/scan
エンドポイントにBS/CSチャンネルスキャン機能を追加する
#79
Conversation
PR いただきましてありがとうございます! とても良いコミットだと思いますので、ぜひ取り込みたいと思います。
Lines 78 to 82 in 113a10d
Lines 352 to 355 in 113a10d
それは GR では Mirakurun/src/Mirakurun/api/config/channels/scan.ts Lines 95 to 100 in 113a10d
GR の場合は
どうぞよろしくお願いします。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented on: #79 (comment)
早速、確認ありがとうございます。修正については時間が取れたら考えてみます。 ちょっとレアな環境で使っています。Dockerは使っていません。 $ uname -a
FreeBSD mirakurun 12.2-RC3 FreeBSD 12.2-RC3 7c4ec6ff02c(HEAD) TRUENAS amd64
$ node -v
v14.13.0
$ npm -v
6.14.8 tuners.yml- name: PT1-S1
types:
- BS
- CS
command: recpt1 --device /dev/ptx0.s0 --lnb 15 <channel> - -
isDisabled: false
decoder: arib-b25-stream-test
- name: PT1-S2
types:
- BS
- CS
command: recpt1 --device /dev/ptx0.s1 --lnb 15 <channel> - -
isDisabled: false
decoder: arib-b25-stream-test
- name: PT1-T1
types:
- GR
command: recpt1 --device /dev/ptx0.t0 <channel> - -
isDisabled: false
decoder: arib-b25-stream-test
- name: PT1-T2
types:
- GR
command: recpt1 --device /dev/ptx0.t1 <channel> - -
isDisabled: false
decoder: arib-b25-stream-test |
これらのことを考えると、GRの場合に そのうえでデフォルトの動作を、GRならチャンネル単位、その他ではサービス単位で登録のようにするとか。個人的にはチャンネル単位に寄せてしまっても良いような気もしますが、BSやCSではサービスが多くなりがちなので避けたいということですかね? 試しに実装してみました。細かいテストはまだですが。 |
確かにそうですね。
あぁ、確かに便利そうですね。そのような処理を追加する方向で考えてみます。
これはどう思いますか?良ければ、これベースに無効化状態での登録オプションを追加する感じで進められたらと思っています。 |
ありがとうございます。
はい、オプションなら良いとおもいます。 |
→ subChMin とか
→ subChMax とか
→ subChType とか |
const channels = []; | ||
for (const ch of range(startCh, endCh)) { | ||
for (const sCh of range(startSubch, endSubch)) { | ||
channels.push(`BS${("00" + ch).slice(-2)}_${sCh}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ch.toString().padStart(2, "0")
が使えます
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: bc7dde5
case common.ChannelTypes.CS: | ||
startCh = startCh === undefined ? 2 : startCh; | ||
endCh = endCh === undefined ? 24 : endCh; | ||
return range(startCh, endCh).map((v) => `CS${v.toString(10)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この toString()
は省略可です
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: bc7dde5
私は日本語で「BSサブチャンネル様式」だとか「BSサブチャンネル形式」というような意味で Style としていました。この場合、 Type より Style のほうが適切のように感じるのですがどうなんでしょうか・・・。英語、あまり得意じゃないので自信を持って言えないのですが。。。 💭 言葉としての正しさは置いておくとしても、 Type という単語はプログラミング言語の中での違う意味に使われすぎているので避けたいかなぁという気持ちが少しあったり・・・。 Typeのほうがいいよって言われたらすぐなびく程度の心持です。 😅 |
startCh = startCh === undefined ? 13 : startCh; | ||
endCh = endCh === undefined ? 62 : endCh; | ||
return { | ||
channels: range(startCh, endCh).map<string>((ch) => ch.toString(10)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここで <string>
定義すると著しく可読性が落ちるので L42 の関数をまともにする方がオススメです。
※ L42 は function で定義するべきです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: c559cd1
startSubch = startSubch === undefined ? 0 : startSubch; | ||
endSubch = endSubch === undefined ? 2 : endSubch; | ||
|
||
const channels = new Array<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const channels: string[] = [];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: c559cd1
↓を見ても分かる通り ChannelType という名前で使っているので、全体の統一感を優先して書いてみました。 それか、たぶん なんとなく他のエンドポイントとか眺めてみて、違和感が無ければ何でも良いです。 ( |
私も丁度 _については別プロジェクトのスタイルを何も考えずに書いちゃいました。すみません。 |
ちょっと時間が空いてしまいましたが、指摘の修正と無効状態での登録など実装してみました。 テストコード追加のためにメソッド化などしているので元のコードからはかなり違っています。少し面倒かもしれませんが、コミットごとに見ていただいたほうがわかりやすいかもしれません。 各コミットと修正内容をリストにすると以下のような感じです。
テストコードについてですが、機能が増えてきたのでテストコードのほうが良いかと思い追加しています。異常ケース、特殊ケースなどはあまり書いていません。 とりあえず、以下のような感じで都度検証しています。CI連動などは別途考える感じでお願いします。 npm run build && npx mocha --exit test/scan.spec.js 以下はAPIのレスポンス結果です。細かな部分はテストコードで検証しているのでそちらを見ていただきたいです。
変更が肥大化してレビュー負荷を上げてしまい申し訳ないですが、よろしくお願いします。 |
予定が立て込んでおり、大変時間がかかっていますが今月中のマージに向けて調整する予定です。 |
このプルリクの目的は、
/config/channels/scan
エンドポイントでBS/CSのチャンネルをスキャンできるように機能を拡張することです。SKYは対象外です。仕様はおおむねapiDocに書けていると思うのでそちらを参照してください。BS/CSスキャンの追加以外に、GRスキャン時の動作が一部変わっています。
serviceId
を登録するように変更${type}${channel}:${service.serviceId}
で代替するように変更GRの動作を変えることが目的ではなく、コードをシンプルに保つためGR/BS/CSの処理をできる限り統一したことによる影響です。
影響が大きそうな1に関してですが、現行コードで1件目のサービスのみを登録している意図がいまいち理解できませんでした。GRでも1件目のサービスと異なる番組を放送するチャンネルをちらほら見かける(NHK総合2とか)ので、現在の動作はあまりよくないかなと思い変更しました。2, 3に関してはサービスを扱うようになったので必然的にという感じです。
気がかりなこととしては、recept1の仕様?に合わせるためにBSのチャンネル文字列(例: BS01_1)を生成する処理が必要になり、これに関連して無駄に複雑になっている感があること。問題なければこのままでいきたいと思っています。
本プロジェクトにコミットするのは初なので、初歩的なところやそもそもアプローチおかしいとかあっても優しく指摘してくれると嬉しいです。:wink: