|
|
|
from peewee import *
|
|
|
|
import Contant
|
|
|
|
import argparse
|
|
|
|
from LoggerUtils import Logger
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='')
|
|
|
|
parser.add_argument('--db', type=str, default='')
|
|
|
|
parser.add_argument('--logDir', type=str, default='')
|
|
|
|
args = parser.parse_args()
|
|
|
|
Contant.db = args.db
|
|
|
|
db = SqliteDatabase(Contant.db)
|
|
|
|
|
|
|
|
|
|
|
|
def ormInit():
|
|
|
|
Channel.create_table()
|
|
|
|
Video.create_table()
|
|
|
|
DownloadInfo.create_table()
|
|
|
|
SrtFile.create_table()
|
|
|
|
|
|
|
|
|
|
|
|
class BaseModel(Model):
|
|
|
|
class Meta:
|
|
|
|
database = db
|
|
|
|
|
|
|
|
# 频道信息
|
|
|
|
|
|
|
|
|
|
|
|
class Channel(BaseModel):
|
|
|
|
id = PrimaryKeyField()
|
|
|
|
channelId = CharField(null=False)
|
|
|
|
channelTitle = CharField(null=False)
|
|
|
|
channelLanguage = CharField()
|
|
|
|
channelReptileTime = CharField(null=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
db_table = 'Channel'
|
|
|
|
|
|
|
|
# 视频信息
|
|
|
|
|
|
|
|
|
|
|
|
class Video(BaseModel):
|
|
|
|
id = PrimaryKeyField()
|
|
|
|
videoId = CharField(null=False)
|
|
|
|
channelId = CharField(null=False)
|
|
|
|
videoTitle = CharField()
|
|
|
|
videoLen = IntegerField()
|
|
|
|
videoType = CharField()
|
|
|
|
videoPublishTime = CharField()
|
|
|
|
videoLanguage = CharField()
|
|
|
|
isDownload = IntegerField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
db_table = 'Vidoes'
|
|
|
|
|
|
|
|
# 下载信息
|
|
|
|
class DownloadInfo(BaseModel):
|
|
|
|
id = PrimaryKeyField()
|
|
|
|
videoId = CharField()
|
|
|
|
downloadType = IntegerField()
|
|
|
|
tryTime = IntegerField()
|
|
|
|
isFinished = IntegerField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
db_table = 'Download_info'
|
|
|
|
|
|
|
|
# 字幕文件信息
|
|
|
|
class SrtFile(BaseModel):
|
|
|
|
id = PrimaryKeyField()
|
|
|
|
videoId = CharField(null=False)
|
|
|
|
channelId = CharField(null=False)
|
|
|
|
ordinal = IntegerField()
|
|
|
|
srtStartTime = CharField()
|
|
|
|
srtEndTime = CharField()
|
|
|
|
srtText = CharField()
|
|
|
|
isScan = IntegerField()
|