import { inject , injectable } from 'inversify' ; import * as apid from '../../../../api' ; import IRecordedDB , { FindAllOption } from '../../db/IRecordedDB' ; import IIPCClient from '../../ipc/IIPCClient' ; import { UploadedVideoFileOption } from '../../operator/recorded/IRecordedManageModel' ; import IEncodeManageModel from '../../service/encode/IEncodeManageModel' ; import IRecordedItemUtil from '../IRecordedItemUtil' ; import IRecordedApiModel from './IRecordedApiModel' ; @ injectable ( ) export default class RecordedApiModel implements IRecordedApiModel { private ipc : IIPCClient ; private recordedDB : IRecordedDB ; private encodeManage : IEncodeManageModel ; private recordedItemUtil : IRecordedItemUtil ; constructor ( @ inject ( 'IIPCClient' ) ipc , @ inject ( 'IRecordedDB' ) recordedDB , @ inject ( 'IEncodeManageModel' ) encodeManage , @ inject ( 'IRecordedItemUtil' ) recordedItemUtil ) { this . recordedDB = recordedDB ; this . ipc = ipc ; this . encodeManage = encodeManage ; this . recordedItemUtil = recordedItemUtil ; } param option return public async gets ( option ) { ( < FindAllOption > option ) . isRecording = false ; const [ records , total ] = await this . recordedDB . findAll ( option , { isNeedVideoFiles : true , isNeedThumbnails : true , isNeedsDropLog : true , isNeedTags : false , } ) ; const encodeIndex = this . encodeManage . getRecordedIndex ( ) ; return { records : records . map ( r => { return this . recordedItemUtil . convertRecordedToRecordedItem ( r , option . isHalfWidth , encodeIndex ) ; } ) , total , } ; } param recordedId param isHalfWidth return public async get ( recordedId , isHalfWidth ) { const item = await this . recordedDB . findId ( recordedId ) ; const encodeIndex = this . encodeManage . getRecordedIndex ( ) ; return item === null ? null : this . recordedItemUtil . convertRecordedToRecordedItem ( item , isHalfWidth , encodeIndex ) ; } return public async getSearchOptionList ( ) { const channels = await this . recordedDB . findChannelList ( ) ; const genres = await this . recordedDB . findGenreList ( ) ; return { channels : channels , genres : genres , } ; } param recordedId return public async delete ( recordedId ) { await this . encodeManage . cancelEncodeByRecordedId ( recordedId ) ; return this . ipc . recorded . delete ( recordedId ) ; } param recordedId return public stopEncode ( recordedId ) { return this . encodeManage . cancelEncodeByRecordedId ( recordedId ) ; } param recordedId param isProtect return public changeProtect ( recordedId , isProtect ) { return this . ipc . recorded . changeProtect ( recordedId , isProtect ) ; } /**
     * ファイルのクリーンアップ
     */ public async fileCleanup ( ) { await this . ipc . recorded . videoFileCleanup ( ) ; await this . ipc . recorded . dropLogFileCleanup ( ) ; } param option return public async addUploadedVideoFile ( option ) { await this . ipc . recorded . addUploadedVideoFile ( option ) ; } param option return public async createNewRecorded ( option ) { return await this . ipc . recorded . createNewRecorded ( option ) ; } }