Media

Media Models

SQLAlchemy ORM definitions for:

  • Media: metadata for a collection of one or more files.
  • MediaFile: a single audio or video file.

Additionally, Media may be considered at podcast episode if it belongs to a mediacore.model.podcasts.Podcast.

Mapped Classes

class mediacore.model.media.Media

Media metadata and a collection of related files.

Primary Data

id
slug
A unique URL-friendly permalink string for looking up this object. Be sure to call mediacore.model.get_available_slug() to ensure the slug is unique.
type

Indicates whether the media is to be considered audio or video.

If this object has no files, the type is None. See Media.update_type() for details on how this is determined.

reviewed
A flag to indicate whether this file has passed review by an admin.
encoded
A flag to indicate whether this file is encoded in a web-ready state.
publishable
A flag to indicate if this media should be published in between its publish_on and publish_until dates. If this is false, this is considered to be in draft state and will not appear on the site.
created_on
modified_on
publish_on
publish_until
A datetime range during which this object should be published. The range may be open ended by leaving publish_until empty.
title
Display title
subtitle
An optional subtitle intended mostly for podcast episodes. If none is provided, the title is concatenated and used in its place.
description
A public-facing XHTML description. Should be a paragraph or more.
description_plain
A public-facing plaintext description. Should be a paragraph or more.
duration
Play time in seconds
views
The number of times the public media page has been viewed
likes
The number of users who clicked ‘i like this’.
notes
Notes for administrative use – never displayed publicly.
author
An instance of mediacore.model.authors.Author. Although not actually a relation, it is implemented as if it were. This was decision was made to make it easier to integrate with mediacore.model.auth.User down the road.

Relations

podcast_id
podcast
An optional mediacore.model.podcasts.Podcast to publish this object in.
files
A list of MediaFile instances.
categories

A list of mediacore.model.categories.Category.

See the set_categories() helper.

tags

A list of mediacore.model.tags.Tag.

See the set_tags() helper.

comments

A dynamic loader for related comments, see mediacore.model.comments.CommentQuery.

Todo

Reimplement as a dynamic loader.

comment_count
comment_count_published
increment_views()

Increment the number of views in the database.

We avoid concurrency issues by incrementing JUST the views and not allowing modified_on to be updated automatically.

set_categories(cats)

Set the related categories of this media.

Parameter:cats – A list of category IDs to set.
set_tags(tags)

Set the tags relations of this media, creating them as needed.

Parameter:tags – A list or comma separated string of tags to use.
update_status()

Ensure the type (audio/video) and encoded flag are properly set.

Call this after modifying any files belonging to this item.

class mediacore.model.media.MediaFile

Audio or Video file or link

Represents a locally- or remotely- hosted file or an embeddable YouTube video.

The URL for use when linking to a media file.

This is usually a direct link to the file, but for youtube videos and other files marked as embeddable, this may return a link to the hosting site’s view page.

This MAY return a different URL than the play_url property.

mimetype

The best-guess mimetype based on this file’s container format.

Defaults to ‘application/octet-stream’.

play_url(qualified=False)

The URL for use when embedding the media file in a page

This MAY return a different URL than the link_url property.

Helpers

Table Of Contents


Current topic


Previous topic

Model API


Next topic

Podcasts


This Page