本文整理汇总了Python中videos.models.Video.duration方法的典型用法代码示例。如果您正苦于以下问题:Python Video.duration方法的具体用法?Python Video.duration怎么用?Python Video.duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类videos.models.Video
的用法示例。
在下文中一共展示了Video.duration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _import_video
# 需要导入模块: from videos.models import Video [as 别名]
# 或者: from videos.models.Video import duration [as 别名]
def _import_video(self, video_url, videoid, title, description, thumbnail, videosrt):
videoid_match = VIDEOID_RE.search(videoid)
videoid = videoid_match.group(1)
video_type = YoutubeVideoType(
'http://www.youtube.com/watch?v={0}'.format(videoid))
try:
video_url_obj = VideoUrl.objects.get(
url=video_type.convert_to_video_url())
video = video_url_obj.video
except ObjectDoesNotExist:
video_url_obj = None
video = Video()
video.youtube_videoid = videoid
video.title = title
video.description = description
if video_type.entry.media.duration:
video.duration = int(video_type.entry.media.duration.seconds)
video.thumbnail = thumbnail
video.save()
Action.create_video_handler(video)
if videosrt:
self._import_srt(video, videosrt)
else:
SubtitleLanguage(video=video, language='en', is_original=True, is_forked=True).save()
if not video_url_obj:
video_url_obj = VideoUrl(
videoid=videoid,
url=video_type.convert_to_video_url(),
type=video_type.abbreviation,
original=True,
primary=True,
video=video)
video_url_obj.save()
self._save_alternate_url(video, video_url)