Skip to content

Commit

Permalink
Update: チューナーコマンドに recpt1 を使用して出力する機能を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Sep 9, 2023
1 parent f4bd9f3 commit 2a8f410
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 19 deletions.
51 changes: 38 additions & 13 deletions isdb_scanner/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,27 +295,52 @@ def main(
available_multi_tuners = ISDBTuner.getAvailableMultiTuners()

# チャンネルスキャン結果 (&一部のフォーマットでは利用可能なチューナー情報も) を様々なフォーマットで保存
JSONFormatter(output / 'Channels.json', tr_ts_infos, bs_ts_infos, cs_ts_infos, exclude_pay_tv=False).save() # JSON のみ常に取得した全チャンネルを出力
EDCBChSet4TxtFormatter(output / 'EDCB-Wine/BonDriver_mirakc(BonDriver_mirakc).ChSet4.txt', tr_ts_infos, bs_ts_infos, cs_ts_infos, exclude_pay_tv).save()
EDCBChSet4TxtFormatter(output / 'EDCB-Wine/BonDriver_mirakc_T(BonDriver_mirakc).ChSet4.txt', tr_ts_infos, [], [], exclude_pay_tv).save()
EDCBChSet4TxtFormatter(output / 'EDCB-Wine/BonDriver_mirakc_S(BonDriver_mirakc).ChSet4.txt', [], bs_ts_infos, cs_ts_infos, exclude_pay_tv).save()
EDCBChSet5TxtFormatter(output / 'EDCB-Wine/ChSet5.txt', tr_ts_infos, bs_ts_infos, cs_ts_infos, exclude_pay_tv).save()
MirakurunChannelsYmlFormatter(output / 'Mirakurun/channels.yml', tr_ts_infos, bs_ts_infos, cs_ts_infos, exclude_pay_tv).save()
MirakurunChannelsYmlFormatter(output / 'Mirakurun/channels_recpt1.yml', tr_ts_infos, bs_ts_infos, cs_ts_infos, exclude_pay_tv, recpt1_compatible=True).save()
MirakurunTunersYmlFormatter(output / 'Mirakurun/tuners.yml', available_isdbt_tuners, available_isdbs_tuners, available_multi_tuners).save()
## JSON のみ常に取得した全チャンネルを出力
JSONFormatter(
output / 'Channels.json',
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv = False).save()
EDCBChSet4TxtFormatter(
output / 'EDCB-Wine/BonDriver_mirakc(BonDriver_mirakc).ChSet4.txt',
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv).save()
EDCBChSet4TxtFormatter(
output / 'EDCB-Wine/BonDriver_mirakc_T(BonDriver_mirakc).ChSet4.txt',
tr_ts_infos, [], [],
exclude_pay_tv).save()
EDCBChSet4TxtFormatter(
output / 'EDCB-Wine/BonDriver_mirakc_S(BonDriver_mirakc).ChSet4.txt',
[], bs_ts_infos, cs_ts_infos,
exclude_pay_tv).save()
EDCBChSet5TxtFormatter(
output / 'EDCB-Wine/ChSet5.txt',
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv).save()
MirakurunChannelsYmlFormatter(
output / 'Mirakurun/channels.yml',
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv).save()
MirakurunChannelsYmlFormatter(
output / 'Mirakurun/channels_recpt1.yml',
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv, recpt1_compatible = True).save()
MirakurunTunersYmlFormatter(
output / 'Mirakurun/tuners.yml',
available_isdbt_tuners, available_isdbs_tuners, available_multi_tuners).save()
MirakurunTunersYmlFormatter(
output / 'Mirakurun/tuners_recpt1.yml',
available_isdbt_tuners, available_isdbs_tuners, available_multi_tuners,
recpt1_compatible = True).save()
MirakcConfigYmlFormatter(
output / 'mirakc/config.yml',
available_isdbt_tuners, available_isdbs_tuners, available_multi_tuners,
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv,
).save()
exclude_pay_tv).save()
MirakcConfigYmlFormatter(
output / 'mirakc/config_recpt1.yml',
available_isdbt_tuners, available_isdbs_tuners, available_multi_tuners,
tr_ts_infos, bs_ts_infos, cs_ts_infos,
exclude_pay_tv,
recpt1_compatible=True,
).save()
exclude_pay_tv, recpt1_compatible = True).save()

print(Rule(characters='=', style=Style(color='#E33157')))
print(f'Finished in {time.time() - scan_start_time:.2f} seconds.')
Expand Down
27 changes: 21 additions & 6 deletions isdb_scanner/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,19 +376,22 @@ def __init__(self,
isdbt_tuners: list[ISDBTuner],
isdbs_tuners: list[ISDBTuner],
multi_tuners: list[ISDBTuner],
recpt1_compatible: bool = False,
) -> None:
"""
Args:
save_file_path (Path): 保存先のファイルパス
isdbt_tuners (list[ISDBTuner]): ISDB-T 専用チューナーのリスト
isdbs_tuners (list[ISDBTuner]): ISDB-S 専用チューナーのリスト
multi_tuners (list[ISDBTuner]): ISDB-T/S 共用チューナーのリスト
recpt1_compatible (bool): recpt1 と互換性のある物理チャンネル指定フォーマットで保存するか
"""

self._save_file_path = save_file_path
self._isdbt_tuners = isdbt_tuners
self._isdbs_tuners = isdbs_tuners
self._multi_tuners = multi_tuners
self._recpt1_compatible = recpt1_compatible


def format(self) -> str:
Expand All @@ -399,29 +402,35 @@ def format(self) -> str:
str: フォーマットされた文字列
"""

def get_tuner_command(device_path: Path) -> str:
if self._recpt1_compatible is True:
return f'recpt1 --device {device_path} <channel> - -'
else:
return f'recisdb tune --device {device_path} --channel <channel> -'

# Mirakurun のチューナー設定ファイル用のデータ構造に変換
mirakurun_tuners: list[MirakurunTuner] = []
for isdbt_tuner in self._isdbt_tuners:
tuner: MirakurunTuner = {
'name': isdbt_tuner.name,
'types': ['GR'],
'command': f'recisdb tune --device {isdbt_tuner.device_path} --channel <channel> -',
'command': get_tuner_command(isdbt_tuner.device_path),
'isDisabled': False,
}
mirakurun_tuners.append(tuner)
for isdbs_tuner in self._isdbs_tuners:
tuner: MirakurunTuner = {
'name': isdbs_tuner.name,
'types': ['BS', 'CS'],
'command': f'recisdb tune --device {isdbs_tuner.device_path} --channel <channel> -',
'command': get_tuner_command(isdbs_tuner.device_path),
'isDisabled': False,
}
mirakurun_tuners.append(tuner)
for multi_tuner in self._multi_tuners:
tuner: MirakurunTuner = {
'name': multi_tuner.name,
'types': ['GR', 'BS', 'CS'],
'command': f'recisdb tune --device {multi_tuner.device_path} --channel <channel> -',
'command': get_tuner_command(multi_tuner.device_path),
'isDisabled': False,
}
mirakurun_tuners.append(tuner)
Expand Down Expand Up @@ -552,28 +561,34 @@ def format(self) -> str:
}
cast(list[MirakcChannel], mirakc_config['channels']).append(channel)

def get_tuner_command(device_path: Path) -> str:
if self._recpt1_compatible is True:
return f'recpt1 --device {device_path} ' + '{{{channel}}} - -'
else:
return f'recisdb tune --device {device_path} --channel ' + '{{{channel}}} -'

# mirakc のチューナー設定ファイル用のデータ構造に変換
for isdbt_tuner in self._isdbt_tuners:
tuner: MirakcTuner = {
'name': isdbt_tuner.name,
'types': ['GR'],
'command': f'recisdb tune --device {isdbt_tuner.device_path} --channel ' + '{{{channel}}} -',
'command': get_tuner_command(isdbt_tuner.device_path),
'disabled': False,
}
cast(list[MirakcTuner], mirakc_config['tuners']).append(tuner)
for isdbs_tuner in self._isdbs_tuners:
tuner: MirakcTuner = {
'name': isdbs_tuner.name,
'types': ['BS', 'CS'],
'command': f'recisdb tune --device {isdbs_tuner.device_path} --channel ' + '{{{channel}}} -',
'command': get_tuner_command(isdbs_tuner.device_path),
'disabled': False,
}
cast(list[MirakcTuner], mirakc_config['tuners']).append(tuner)
for multi_tuner in self._multi_tuners:
tuner: MirakcTuner = {
'name': multi_tuner.name,
'types': ['GR', 'BS', 'CS'],
'command': f'recisdb tune --device {multi_tuner.device_path} --channel ' + '{{{channel}}} -',
'command': get_tuner_command(multi_tuner.device_path),
'disabled': False,
}
cast(list[MirakcTuner], mirakc_config['tuners']).append(tuner)
Expand Down

0 comments on commit 2a8f410

Please sign in to comment.