Public Controllers

MediaDrop provides a robust frontend, but if it does not suit your needs you can easily revise it or even completely replace it, while still maintaining the benefits of MediaDrop’s admin interface.

A listing of the public-facing controller methods is below. See the mediadrop/config/routing.py file for information on the URLs that point to these methods.

Browsing/Viewing Media

Publicly Facing Media Controllers

class mediadrop.controllers.media.MediaController(*args, **kwargs)

Media actions – for both regular and podcast media

comment(*args, **kwargs)

Post a comment from PostCommentForm.

Parameters:slug – The media slug
Returns:Redirect to view() page for media.
embed_player(*args, **kwargs)
explore(*args, **kwargs)

Display the most recent 15 media.

Return type:Dict
Returns:
latest
Latest media
popular
Latest media
index(*args, **kwargs)

List media with pagination.

The media paginator may be accessed in the template with c.paginators.media, see webhelpers.paginate.Page.

Parameters:
  • page (int) – Page number, defaults to 1.
  • show (unicode or None) – ‘latest’, ‘popular’ or ‘featured’
  • q (unicode or None) – A search query to filter by
  • tag (unicode or None) – A tag slug to filter for
Return type:

dict

Returns:

media

The list of Media instances for this page.

result_count

The total number of media items for this query

search_query

The query the user searched for, if any

random(**kwargs)

Redirect to a randomly selected media item.

rate(*args, **kwargs)

Say ‘I like this’ for the given media.

Parameters:slug – The media slug
Return type:unicode
Returns:The new number of likes
serve(id, download=False, **kwargs)

Serve a MediaFile binary.

Parameters:
  • id (int) – File ID
  • download (bool) – If true, serve with an Content-Disposition that makes the file download to the users computer instead of playing in the browser.
Raises:
  • webob.exc.HTTPNotFound – If no file exists with this ID.
  • webob.exc.HTTPNotAcceptable – If an Accept header field is present, and if the mimetype of the requested file doesn’t match, then a 406 (not acceptable) response is returned.
tags(*args, **kwargs)

Display a listing of all tags.

view(*args, **kwargs)

Display the media player, info and comments.

Parameters:
  • slug – The slug to lookup
  • podcast_slug – The slug for podcast this media belongs to. Although not necessary for looking up the media, it tells us that the podcast slug was specified in the URL and therefore we reached this action by the preferred route.
Rtype dict:
Returns:

media

The Media instance for display.

related_media

A list of Media instances that rank as topically related to the given media item.

comments

A list of Comment instances associated with the selected media item.

comment_form_action

str comment form action

comment_form_values

dict form values

next_episode

The next episode in the podcast series, if this media belongs to a podcast, another Media instance.

Browsing Podcasts

class mediadrop.controllers.podcasts.PodcastsController(*args, **kwargs)

Podcast Series Controller

This handles episode collections, individual episodes are handled as regular media by mediadrop.controllers.media.

feed(*args, **kwargs)

Serve the feed as RSS 2.0.

If feedburner_url is specified for this podcast, we redirect there if the useragent does not contain ‘feedburner’, as described here: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464

Parameters:feedburner_bypass – If true, the redirect to feedburner is disabled.
Return type:Dict
Returns:
podcast
A Podcast instance.
episodes
A list of Media instances that belong to the podcast.

Renders: podcasts/feed.xml XML

index(*args, **kwargs)

List podcasts and podcast media.

Return type:dict
Returns:
podcasts
The Podcast instance
view(*args, **kwargs)

View a podcast and the media that belongs to it.

Parameters:
  • slug – A slug
  • page (int) – Page number, defaults to 1.
Return type:

dict

Returns:

podcast

A Podcast instance.

episodes

A list of Media instances that belong to the podcast.

podcasts

A list of all the other podcasts

Uploading Videos

class mediadrop.controllers.upload.UploadController(*args, **kwargs)

Media Upload Controller

failure(*args, **kwargs)
index(*args, **kwargs)

Display the upload form.

Return type:Dict
Returns:
legal_wording
XHTML legal wording for rendering
support_email
An help contact address
upload_form
The UploadForm instance
form_values
dict form values, if any
save_media_obj(name, email, title, description, tags, uploaded_file, url)
submit(*args, **kwargs)
submit_async(*args, **kwargs)

Ajax form validation and/or submission.

This is the save handler for UploadForm.

When ajax is enabled this action is called for each field as the user fills them in. Although the entire form is validated, the JS only provides the value of one field at a time,

Parameters:validate – A JSON list of field names to check for validation
Parma **kwargs:One or more form field values.
Return type:JSON dict
Returns:
When validating one or more fields:
 
valid
bool
err
A dict of error messages keyed by the field names
When saving an upload:
 
success
bool
redirect
If valid, the redirect url for the upload successful page.
success(*args, **kwargs)

XML Sitemaps

Sitemaps Controller

class mediadrop.controllers.sitemaps.SitemapsController(*args, **kwargs)

Sitemap generation

crossdomain_xml(**kwargs)

Serve the crossdomain XML file manually if static_files is disabled.

If someone forgets to add this Alias we might as well serve this file for them and save everyone the trouble. This only works when MediaDrop is served out of the root of a domain and if Cooliris is enabled.

featured(*args, **kwargs)

Generate a media rss (mRSS) feed of the sites featured media.

google(*args, **kwargs)

Generate a sitemap which contains googles Video Sitemap information.

This action may return a <sitemapindex> or a <urlset>, depending on how many media items are in the database, and the values of the page and limit params.

Parameters:
  • page (int) – Page number, defaults to 1.
  • page – max records to display on page, defaults to 10000.
latest(*args, **kwargs)

Generate a media rss (mRSS) feed of all the sites media.

mrss(*args, **kwargs)

Generate a media rss (mRSS) feed of all the sites media.

Error Messages

You're reading the documentation for MediaDrop 0.11dev (current git master). For the latest stable release please consult the documentation for MediaCore CE 0.10.