youtube下载
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

9 months ago
import json
from Orm import Video
from playhouse.shortcuts import model_to_dict, dict_to_model
class VideoService:
def getOneByVideoId(videoId):
return Video.get_or_none(Video.videoId == videoId)
def createOne(videoId, channelId, videoTitle, videoLen, videoType, videoPublishTime, videoLanguage, isDownload):
Video.create(videoId=videoId,
channelId=channelId,
videoTitle=videoTitle,
videoLen=videoLen,
videoType=videoType,
videoPublishTime=videoPublishTime,
videoLanguage=videoLanguage,
isDownload=isDownload)
def updateLenByVideoId(videoId, len):
Video.update(videoLen=len).where(Video.videoId == videoId).execute()
def getLastVideoByChannelId(channelId):
return Video.select().where(Video.channelId == channelId).order_by(Video.videoPublishTime.desc()).get()
def getFirstVideoByChannelId(channelId):
return Video.select().where(Video.channelId == channelId).order_by(Video.videoPublishTime).get()
def checkExist(channelId):
query = Video.select().where(Video.channelId == channelId)
return query.exists()
def getVideosByTime(startTime,endTime):
return Video.select().where(Video.videoPublishTime >= startTime,Video.videoPublishTime <= endTime).execute()