Media Platform¶
Media Platform Application
Models¶
-
class
mediaplatform.models.
MediaItemQuerySet
(model=None, query=None, using=None, hints=None)¶ -
annotate_viewable
(user, name='viewable')¶ Annotate the query set with a boolean indicating if the user can view the item.
-
viewable_by_user
(user)¶ Filter the queryset to only those items which can be viewed by the passed Django user.
-
annotate_editable
(user, name='editable')¶ Annotate the query set with a boolean indicating if the user can edit the item.
-
editable_by_user
(user)¶ Filter the queryset to only those items which can be edited by the passed Django user.
-
annotate_downloadable
(user, name='downloadable_by_user')¶ Annotate the query set with a boolean indicating if the user can download the item. To avoid clashing with the model’s downloadable flag, the annotation is called “downloadable_by_user”.
-
downloadable_by_user
(user)¶ Filter the queryset to only those items which can be downloaded by the passed Django user.
-
-
class
mediaplatform.models.
MediaItemManager
(*args, include_deleted=False, **kwargs)¶ An object manager for
MediaItem
objects. Accepts an additional named parameter include_deleted which specifies if the default queryset should include deleted items.-
get_queryset
()¶ Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
-
create_for_user
(user, **kwargs)¶ Convenience wrapper for create() which will create an item but also give the passed user view and edit permissions if the user is not anonymous.
-
-
class
mediaplatform.models.
MediaItem
(*args, **kwargs)¶ An individual media item in the media platform.
Most fields in this model can store blank values since they are synced from external providers who may not have the degree of rigour we want. For the same reason, we have default values for most fields.
-
class
Source
(item: object, mime_type: str, url: str, width: Optional[int] = None, height: Optional[int] = None)¶ An encoded media stream for a media item.
-
item
= None¶ MediaItem for this source (post Python3.7, we’ll be able to refer to MediaItem as the type.)
-
mime_type
= None¶ Media type of the stream
-
url
= None¶ URL pointing to this source
-
width
= None¶ Width of the stream or None if this is an audio stream
-
height
= None¶ Height of the stream or None if this is an audio stream
-
-
objects
= <mediaplatform.models.MediaItemManager object>¶ Object manager. See
MediaItemManager
. The objects returned by this manager do not include deleted objects. See :py:attr:~.objects_including_deleted`.
-
objects_including_deleted
= <mediaplatform.models.MediaItemManager object>¶ Object manager whose objects include the deleted items. This has been separated out into a separate manager to avoid inadvertently including deleted objects in a query
-
id
¶ Primary key
-
channel
¶ Channel which contains media item - if NULL, then the media item is in no channel.
-
title
¶ Media item title
-
description
¶ Media item description
-
duration
¶ Duration
-
type
¶ Type of media
-
published_at
¶ Publication date
-
downloadable
¶ Downloadable flag
-
language
¶ ISO 693-3 language code
-
copyright
¶ Video copyright
List of tags for video
-
text_search_vector
¶ Full text search vector field
-
initially_fetched_from_url
¶ A source URL for the media. Can only be set at creation time to have any effect. If set when the media item is created, the URL will be fetched and transcoded.
-
created_at
¶ Creation time
-
updated_at
¶ Last update time
-
deleted_at
¶ Deletion time. If non-NULL, the item has been “deleted” and should not usually be visible.
-
sources
¶ A list of
Source
instances representing the raw media sources for this media item. This list is populated irrespective of the downloadable flag.
-
fetched_analytics
¶ A cached property which returns legacy statistics if the media item is a legacy item.
-
fetched_size
¶ A cached property which returns the storage size of the video in bytes (the sum of all the sources). Returns 0 if the size isn’t available.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
-
class
mediaplatform.models.
Permission
(*args, **kwargs)¶ Specify whether a user has permission to perform some action.
A user has permission to perform the action if any of the following are true:
- They have a crsid and that crsid appears in
crsids
- The lookup groupid of a lookup group which they are a member of appears in
lookup_groups
- The instid of an an institution they are a member of appears in
lookup_insts
- The
is_public
flag isTrue
- The user is not anonymous and
is_signed_in
isTrue
-
id
¶ Primary key
-
allows_view_item
¶ MediaItem whose view permission is this object
-
allows_edit_channel
¶ Channel whose edit permission is this object
-
allows_create_channel_on_billing_account
¶ BillingAccount whose channel create permission is this object.
-
crsids
¶ List of crsids of users with this permission
-
lookup_groups
¶ List of lookup groups which users with this permission belong to
-
lookup_insts
¶ List of lookup institutions which users with this permission belong to
-
is_public
¶ Do all users (including anonymous ones) have this permission?
-
is_signed_in
¶ Do all signed in (non-anonymous) users have this permission?
-
reset
()¶ Reset this permission to the “allow nobody” state.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
- They have a crsid and that crsid appears in
-
class
mediaplatform.models.
UploadEndpoint
(*args, **kwargs)¶ An endpoint which can be used to upload a media item.
-
id
¶ Primary key
-
url
¶ URL for upload
-
item
¶ Related media item
-
expires_at
¶ Date and time at which this upload URL will expire
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
-
class
mediaplatform.models.
ChannelQuerySet
(model=None, query=None, using=None, hints=None)¶ -
annotate_viewable
(user, name='viewable')¶ Annotate the query set with a boolean indicating if the user can view the channel.
This is always true but this method is provided for compatibility with code shared between media items and channels.
-
viewable_by_user
(user)¶ Filter the queryset to only those items which can be viewed by the passed Django user.
This is a no-op filter but this method is provided for compatibility with code shared between media items and channels.
-
annotate_editable
(user, name='editable')¶ Annotate the query set with a boolean indicating if the user can edit the item.
-
editable_by_user
(user)¶ Filter the queryset to only those items which can be edited by the passed Django user.
-
-
class
mediaplatform.models.
ChannelManager
(*args, include_deleted=False, **kwargs)¶ An object manager for
Channel
objects. Accepts an additional named parameter include_deleted which specifies if the default queryset should include deleted items.-
get_queryset
()¶ Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
-
create_for_user
(user, **kwargs)¶ Convenience wrapper for create() which will create a channel but also give the passed user edit permissions if the user is not anonymous.
-
-
class
mediaplatform.models.
Channel
(*args, **kwargs)¶ An individual channel in the media platform.
-
objects
= <mediaplatform.models.ChannelManager object>¶ Object manager. See
ChannelManager
. The objects returned by this manager do not include deleted objects. See :py:attr:~.objects_including_deleted`.
-
objects_including_deleted
= <mediaplatform.models.ChannelManager object>¶ Object manager whose objects include the deleted items. This has been separated out into a separate manager to avoid inadvertently including deleted objects in a query
-
id
¶ Primary key
-
title
¶ Channel title
-
description
¶ Channel description
-
text_search_vector
¶ Full text search vector field
-
billing_account
¶ Billing account associated with this channel. To avoid potential data loss, once a billing account is associated with a channel we use the PROTECT argument to on_delete to prevent deletion of the account until it has no channels.
-
created_at
¶ Creation time
-
updated_at
¶ Last update time
-
deleted_at
¶ Deletion time. If non-NULL, the channel has been “deleted” and should not usually be visible.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
-
class
mediaplatform.models.
PlaylistQuerySet
(model=None, query=None, using=None, hints=None)¶ -
annotate_viewable
(user, name='viewable')¶ Annotate the query set with a boolean indicating if the user can view the item.
-
viewable_by_user
(user)¶ Filter the queryset to only those items which can be viewed by the passed Django user.
-
annotate_editable
(user, name='editable')¶ Annotate the query set with a boolean indicating if the user can edit the playlist.
-
editable_by_user
(user)¶ Filter the queryset to only those playlists which can be edited by the passed Django user.
-
-
class
mediaplatform.models.
PlaylistManager
(*args, include_deleted=False, **kwargs)¶ An object manager for
Playlist
objects. Accepts an additional named parameter include_deleted which specifies if the default queryset should include deleted items.-
get_queryset
()¶ Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
-
-
class
mediaplatform.models.
Playlist
(*args, **kwargs)¶ An individual playlist in the media platform.
-
objects
= <mediaplatform.models.PlaylistManager object>¶ Object manager. See
PlaylistManager
. The objects returned by this manager do not include deleted objects. See :py:attr:~.objects_including_deleted`.
-
objects_including_deleted
= <mediaplatform.models.PlaylistManager object>¶ Object manager whose objects include the deleted items. This has been separated out into a separate manager to avoid inadvertently including deleted objects in a query
-
id
¶ Primary key
-
channel
¶ Channel which contains playlist
-
title
¶ Playlist title
-
description
¶ Playlist description
-
text_search_vector
¶ Full text search vector field
-
created_at
¶ Creation time
-
updated_at
¶ Last update time
-
deleted_at
¶ Deletion time. If non-NULL, the channel has been “deleted” and should not usually be visible.
-
ordered_media_item_queryset
¶ A queryset which returns the media items for the play list with the same ordering as
media_items
.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
-
class
mediaplatform.models.
BillingAccountQuerySet
(model=None, query=None, using=None, hints=None)¶ -
annotate_can_create_channels
(user, name='can_create_channels')¶ Annotate the query set with a boolean indicating if the user can create channels.
-
channels_creatable_by_user
(user)¶ Filter the queryset to only those items which can have channels created by the passed user.
-
-
class
mediaplatform.models.
BillingAccountManager
(*args, **kwargs)¶ An object manager for
BillingAccount
objects.-
get_queryset
()¶ Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
-
-
class
mediaplatform.models.
BillingAccount
(*args, **kwargs)¶ A billing account represents a billable entity which is responsible for paying for resources used by channels.
-
objects
= <mediaplatform.models.BillingAccountManager object>¶ Object manager. See
BillingAccountManager
.
-
id
¶ Primary key
-
description
¶ Human readable description of billing account. Required.
-
lookup_instid
¶ “Owning” lookup instid. Currently this is non-NULL because all billing accounts have an associated institution. This may change in the future.
-
created_at
¶ Creation time
-
updated_at
¶ Last update time
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
-
class
mediaplatform.models.
TranscriptionRequest
(*args, **kwargs)¶ A transcription request represents a request that a media item have a caption track appended. A request may be in one of five states.
- A “pending” request is one which is outstanding and may be picked up by some transcription
- service.
- A “running” request is one which is currently underway.
- A “resolved” request is one which finished and resulted in a caption track.
- A “rejected” request is one which finished and resulted in some problem.
- The “cancelled” state is used to prevent a request from being picked up by a transcription service. For example, a user may upload a caption track after the initial upload. In this case, we do not need to automatically transcribe the video and so the request can be cancelled.
The difference between a “rejected” request and a “cancelled” request is that, in the former case, a transcription was attempted but failed and, in the latter case, a transcription was never attempted and is no-longer required.
-
id
¶ Primary key
-
state
¶ State of the request
-
media_item
¶ Media item for the request
-
created_at
¶ Creation time
-
updated_at
¶ Last update time
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶