本文整理汇总了Python中mediacore.model.Media.duration方法的典型用法代码示例。如果您正苦于以下问题:Python Media.duration方法的具体用法?Python Media.duration怎么用?Python Media.duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediacore.model.Media
的用法示例。
在下文中一共展示了Media.duration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: media_from_entry
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import duration [as 别名]
def media_from_entry(e, tags=False, save_files=False):
# Get tags as a list of unicode objects.
tags = [t['term'] for t in e['tags']]
# Assume not explicit.
explicit = 0
if 'itunes_explicit' in e:
explicit = e['itunes_explicit']
# Find the duration, if it exists
duration = u''
if 'itunes_duration' in e:
try:
duration = e['itunes_duration']
duration = duration_to_seconds(duration)
except ValueError:
duration = None
# Find the first <img> tag in the summary, if there is one
image = None
m = img_regex.match(e['summary'])
if m is not None:
image = m.group(1)[1:-1]
title = e['title']
slug = slugify(title)
author_name = u"PLACEHOLDER NAME"
author_email = u"[email protected]"
if 'author_detail' in e:
if 'name' in e['author_detail']:
author_name = e['author_detail']['name']
if 'email' in e['author_detail']:
author_email = e['author_detail']['email']
year, month, day, hour, minute, second = e['updated_parsed'][:6]
updated = datetime(year, month, day, hour, minute, second)
media = Media()
media.slug = get_available_slug(Media, slug, media)
media.title = e['title']
media.author = Author(author_name, author_email)
media.description = e['summary']
media.notes = u''
if tags:
media.set_tags(tags)
else:
media.set_categories(tags)
media.publish_on = updated
media.created_on = updated
media.publishable = True
media.reviewed = True
media.duration = duration
DBSession.add(media)
DBSession.flush()
# Create thumbs from image, or default thumbs
created_images = False
if image:
temp_imagefile = tempfile.TemporaryFile()
imagefile = urllib2.urlopen(image)
temp_imagefile.write(imagefile.read())
temp_imagefile.seek(0)
filename = urlparse.urlparse(image)[2]
create_thumbs_for(media, temp_imagefile, filename)
created_images = True
if not created_images:
create_default_thumbs_for(media)
print "Loaded episode:", media
# now add all of the files.
for enc in e['enclosures']:
mf = media_file_from_enclosure(enc, media, save_files)
print "Loaded media file:", mf
media.update_status()
return media
示例2: add_default_data
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import duration [as 别名]
#.........这里部分代码省略.........
comment.author = AuthorWithIP(name=u'John Doe', ip=2130706433)
comment.body = u'<p>Hello to you too!</p>'
DBSession.add(comment)
media = Media()
media.type = None
media.slug = u'new-media'
media.reviewed = True
media.encoded = False
media.publishable = False
media.title = u'New Media'
media.subtitle = None
media.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
media.description_plain = u"""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
media.author = Author(admin_user.display_name, admin_user.email_address)
media.categories.append(category)
media.comments.append(comment)
DBSession.add(media)
#XXX The list of default players is actually defined in model.players
# and should at some point be moved here to avoid inconsistency
# between the default storage engines and default players.
remote_url_storage = RemoteURLStorage()
default_engines = [
LocalFileStorage(),
remote_url_storage,
YoutubeStorage(),
VimeoStorage(),
BlipTVStorage(),
DailyMotionStorage(),
GoogleVideoStorage(),
]
for engine in default_engines:
DBSession.add(engine)
import datetime
instructional_media = [
(u'workflow-in-mediacore',
u'Workflow in MediaCore',
u'<p>This sceencast explains the publish status feature in MediaCore.</p><p>Initially all videos uploaded through the front-end or admin panel are placed under "awaiting review" status. Once the administrator hits the "review complete" button, they can upload media. Videos can be added in any format, however, they can only be published if they are in a web-ready format such as FLV, M4V, MP3, or MP4. Alternatively, if they are published through Youtube or Vimeo the encoding step is skipped</p><p>Once uploaded and encoded the administrator can then publish the video.</p>',
u'This sceencast explains the publish status feature in MediaCore.\nInitially all videos uploaded through the front-end or admin panel are placed under \"awaiting review\" status. Once the administrator hits the \"review complete\" button, they can upload media. Videos can be added in any format, however, they can only be published if they are in a web-ready format such as FLV, M4V, MP3, or MP4. Alternatively, if they are published through Youtube or Vimeo the encoding step is skipped\nOnce uploaded and encoded the administrator can then publish the video.',
datetime.datetime(2010, 5, 13, 2, 29, 40),
218,
u'http://getmediacore.com/files/tutorial-workflow-in-mediacore.mp4',
u'video',
u'mp4',
),
(u'creating-a-podcast-in-mediacore',
u'Creating a Podcast in MediaCore',
u'<p>This describes the process an administrator goes through in creating a podcast in MediaCore. An administrator can enter information that will automatically generate the iTunes/RSS feed information. Any episodes published to a podcast will automatically publish to iTunes/RSS.</p>',
u'This describes the process an administrator goes through in creating a podcast in MediaCore. An administrator can enter information that will automatically generate the iTunes/RSS feed information. Any episodes published to a podcast will automatically publish to iTunes/RSS.',
datetime.datetime(2010, 5, 13, 2, 33, 44),
100,
u'http://getmediacore.com/files/tutorial-create-podcast-in-mediacore.mp4',
u'video',
u'mp4',
),
(u'adding-a-video-in-mediacore',
u'Adding a Video in MediaCore',
u'<p>This screencast shows how video or audio can be added in MediaCore.</p><p>MediaCore supports a wide range of formats including (but not limited to): YouTube, Vimeo, Google Video, Amazon S3, Bits on the Run, BrightCove, Kaltura, and either your own server or someone else\'s.</p><p>Videos can be uploaded in any format, but can only be published in web-ready formats such as FLV, MP3, M4V, MP4 etc.</p>',
u'This screencast shows how video or audio can be added in MediaCore.\nMediaCore supports a wide range of formats including (but not limited to): YouTube, Vimeo, Google Video, Amazon S3, Bits on the Run, BrightCove, Kaltura, and either your own server or someone else\'s.\nVideos can be uploaded in any format, but can only be published in web-ready formats such as FLV, MP3, M4V, MP4 etc.',
datetime.datetime(2010, 5, 13, 02, 37, 36),
169,
u'http://getmediacore.com/files/tutorial-add-video-in-mediacore.mp4',
u'video',
u'mp4',
),
]
name = u'MediaCore Team'
email = u'[email protected]'
for slug, title, desc, desc_plain, publish_on, duration, url, type_, container in instructional_media:
media = Media()
media.author = Author(name, email)
media.description = desc
media.description_plain = desc_plain
media.duration = duration
media.publish_on = publish_on
media.slug = slug
media.title = title
media.type = type_
media_file = MediaFile()
media_file.container = container
media_file.created_on = publish_on
media_file.display_name = os.path.basename(url)
media_file.duration = duration
media_file.type = type_
media_file.storage = remote_url_storage
media_file.unique_id = url
DBSession.add(media)
DBSession.add(media_file)
media.files.append(media_file)
media.categories.append(category2)
media.encoded = True
media.reviewed = True
media.publishable = True
示例3: add_default_data
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import duration [as 别名]
#.........这里部分代码省略.........
media = Media()
media.type = None
media.slug = u"new-media"
media.reviewed = True
media.encoded = False
media.publishable = False
media.title = u"New Media"
media.subtitle = None
media.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
media.description_plain = u"""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
media.author = Author(admin_user.display_name, admin_user.email_address)
media.categories.append(category)
media.comments.append(comment)
DBSession.add(media)
# XXX The list of default players is actually defined in model.players
# and should at some point be moved here to avoid inconsistency
# between the default storage engines and default players.
remote_url_storage = RemoteURLStorage()
default_engines = [
LocalFileStorage(),
remote_url_storage,
YoutubeStorage(),
VimeoStorage(),
BlipTVStorage(),
DailyMotionStorage(),
]
for engine in default_engines:
DBSession.add(engine)
import datetime
instructional_media = [
(
u"workflow-in-mediacore",
u"Workflow in MediaCore",
u"<p>This sceencast explains the publish status feature in MediaCore.</p><p>Initially all videos uploaded through the front-end or admin panel are placed under "awaiting review" status. Once the administrator hits the "review complete" button, they can upload media. Videos can be added in any format, however, they can only be published if they are in a web-ready format such as FLV, M4V, MP3, or MP4. Alternatively, if they are published through Youtube or Vimeo the encoding step is skipped</p><p>Once uploaded and encoded the administrator can then publish the video.</p>",
u'This sceencast explains the publish status feature in MediaCore.\nInitially all videos uploaded through the front-end or admin panel are placed under "awaiting review" status. Once the administrator hits the "review complete" button, they can upload media. Videos can be added in any format, however, they can only be published if they are in a web-ready format such as FLV, M4V, MP3, or MP4. Alternatively, if they are published through Youtube or Vimeo the encoding step is skipped\nOnce uploaded and encoded the administrator can then publish the video.',
datetime.datetime(2010, 5, 13, 2, 29, 40),
218,
u"http://mediacorecommunity.org/files/videos/tutorial-workflow-in-mediacore.mp4",
u"video",
u"mp4",
),
(
u"creating-a-podcast-in-mediacore",
u"Creating a Podcast in MediaCore",
u"<p>This describes the process an administrator goes through in creating a podcast in MediaCore. An administrator can enter information that will automatically generate the iTunes/RSS feed information. Any episodes published to a podcast will automatically publish to iTunes/RSS.</p>",
u"This describes the process an administrator goes through in creating a podcast in MediaCore. An administrator can enter information that will automatically generate the iTunes/RSS feed information. Any episodes published to a podcast will automatically publish to iTunes/RSS.",
datetime.datetime(2010, 5, 13, 2, 33, 44),
100,
u"http://mediacorecommunity.org/files/videos/tutorial-create-podcast-in-mediacore.mp4",
u"video",
u"mp4",
),
(
u"adding-a-video-in-mediacore",
u"Adding a Video in MediaCore",
u"<p>This screencast shows how video or audio can be added in MediaCore.</p><p>MediaCore supports a wide range of formats including (but not limited to): YouTube, Vimeo, Amazon S3, Bits on the Run, BrightCove, Kaltura, and either your own server or someone else's.</p><p>Videos can be uploaded in any format, but can only be published in web-ready formats such as FLV, MP3, M4V, MP4 etc.</p>",
u"This screencast shows how video or audio can be added in MediaCore.\nMediaCore supports a wide range of formats including (but not limited to): YouTube, Vimeo, Amazon S3, Bits on the Run, BrightCove, Kaltura, and either your own server or someone else's.\nVideos can be uploaded in any format, but can only be published in web-ready formats such as FLV, MP3, M4V, MP4 etc.",
datetime.datetime(2010, 5, 13, 02, 37, 36),
169,
u"http://mediacorecommunity.org/files/videos/tutorial-add-video-in-mediacore.mp4",
u"video",
u"mp4",
),
]
name = u"MediaCore Team"
email = u"[email protected]"
for slug, title, desc, desc_plain, publish_on, duration, url, type_, container in instructional_media:
media = Media()
media.author = Author(name, email)
media.description = desc
media.description_plain = desc_plain
media.duration = duration
media.publish_on = publish_on
media.slug = slug
media.title = title
media.type = type_
media_file = MediaFile()
media_file.container = container
media_file.created_on = publish_on
media_file.display_name = os.path.basename(url)
media_file.duration = duration
media_file.type = type_
media_file.storage = remote_url_storage
media_file.unique_id = url
DBSession.add(media)
DBSession.add(media_file)
media.files.append(media_file)
media.categories.append(category2)
media.encoded = True
media.reviewed = True
media.publishable = True