-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: [Server][metadata] 録画ファイルからメタデータを取得するクラス群を移動/追加
かなり量が多くなる予定なので新しくフォルダを作成してまとめた
- Loading branch information
1 parent
66f7762
commit 647107d
Showing
7 changed files
with
181 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
from pathlib import Path | ||
|
||
from app.models import RecordedVideo | ||
|
||
|
||
class CMSectionsDetector: | ||
""" 録画 TS ファイルに含まれる CM 区間を検出するクラス """ | ||
|
||
def __init__(self, recorded_ts_path: Path) -> None: | ||
""" | ||
録画 TS ファイルに含まれる CM 区間を検出するクラスを初期化する | ||
Args: | ||
recorded_ts_path (Path): 録画 TS ファイルのパス | ||
""" | ||
|
||
self.recorded_ts_path = recorded_ts_path | ||
|
||
|
||
def detect(self, recorded_video: RecordedVideo) -> list[tuple[float, float]]: | ||
""" | ||
CM 区間を検出する | ||
Args: | ||
recorded_video (RecordedVideo): 録画ファイル情報を表すモデル | ||
Returns: | ||
list[tuple[float, float]]: CM 区間 (開始時刻, 終了時刻) のリスト | ||
""" | ||
|
||
# TODO: CM 区間を検出する処理を実装する | ||
cm_sections = [] | ||
return cm_sections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
import ariblib | ||
from pathlib import Path | ||
|
||
from app.models import Channel | ||
from app.models import RecordedProgram | ||
from app.models import RecordedVideo | ||
|
||
|
||
class TSInfoAnalyzer: | ||
""" 録画 TS ファイル内に含まれる番組情報を解析するクラス """ | ||
|
||
def __init__(self, recorded_ts_path: Path) -> None: | ||
""" | ||
録画 TS ファイル内に含まれる番組情報を解析するクラスを初期化する | ||
Args: | ||
recorded_ts_path (Path): 録画 TS ファイルのパス | ||
""" | ||
|
||
# TS ファイルを開く | ||
# チャンクは 1000(だいたい 0.1 ~ 0.2 秒間隔)に設定 | ||
self.ts = ariblib.tsopen(recorded_ts_path, chunk=1000) | ||
|
||
|
||
def analyze(self, recorded_video: RecordedVideo) -> tuple[RecordedProgram, Channel | None]: | ||
""" | ||
録画 TS ファイル内に含まれる番組情報を解析し、データベースに格納するモデルを作成する | ||
Args: | ||
recorded_video (RecordedVideo): 録画ファイル情報を表すモデル | ||
Returns: | ||
tuple[RecordedProgram, Channel | None]: 録画番組情報とチャンネル情報を表すモデルのタプル | ||
""" | ||
|
||
# TODO!!!!! | ||
|
||
# 録画番組情報のモデルを作成 | ||
recorded_program = RecordedProgram() | ||
|
||
# チャンネル情報のモデルを作成 | ||
channel = Channel() | ||
|
||
return recorded_program, channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
# モデルをモジュールとして登録 | ||
from .CMSectionsDetector import CMSectionsDetector # type: ignore | ||
from .MetadataAnalyzer import MetadataAnalyzer # type: ignore | ||
from .TSInfoAnalyzer import TSInfoAnalyzer # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters