Created
October 20, 2011 21:40
-
-
Save thomasboyt/1302459 to your computer and use it in GitHub Desktop.
Test Gist for Djangocasts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from django.utils.translation import ugettext_lazy as _ | |
from django.db import models | |
from django.contrib.auth.models import User | |
from django.template.defaultfilters import slugify | |
from django.template.loader import render_to_string | |
from django.conf import settings | |
from model_utils import Choices | |
from model_utils.fields import StatusField, SplitField | |
from taggit.managers import TaggableManager | |
from youtube import Youtube | |
class Category(models.Model): | |
name = models.CharField(_("name"), max_length=75) | |
description = models.TextField(_("description"), max_length=250) | |
slug = models.SlugField(_("name slug"), max_length=150, editable=False) | |
class Meta: | |
verbose_name = _("category") | |
verbose_name_plural = _("categories") | |
def __unicode__(self): | |
return "{0}".format(self.name) | |
def save(self, *args, **kwargs): | |
self.slug = slugify(self.name) | |
super(Category, self).save(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.conf.urls.defaults import * | |
from django.views.generic import ListView, DetailView | |
from django.contrib import admin | |
from tastypie.api import Api | |
from casts.models import Screencast | |
from casts.resources import PodcastResource, ScreencastResource | |
admin.autodiscover() | |
v1_api = Api(api_name='v1') | |
v1_api.register(PodcastResource()) | |
v1_api.register(ScreencastResource()) | |
handler500 = "pinax.views.server_error" | |
urlpatterns = patterns("", | |
#url(r"^$", 'casts.views.list'), | |
url(r"^$", ListView.as_view( | |
queryset = Screencast.objects.filter(status="published").order_by("when").reverse(), | |
template_name = "casts/list.html", | |
paginate_by = 10, | |
)), | |
url(r"^cast/(?P<slug>.+)/$", DetailView.as_view( | |
model = Screencast, | |
template_name = "casts/cast.html", | |
)), | |
url(r"^admin/", include(admin.site.urls)), | |
url(r"^postmin/", include("postmin.urls")), | |
url(r"^api/", include(v1_api.urls)), | |
) | |
if settings.SERVE_MEDIA: | |
urlpatterns += patterns("", | |
url(r"", include("staticfiles.urls")), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
class Youtube(object): | |
def __init__(self, videoid): | |
self.video_id = videoid | |
def getinfo(self): | |
url = "http://gdata.youtube.com/feeds/api/videos/%s&v=2&alt=jsonc" % self.video_id | |
r = requests.get(url) | |
return self.video_id | |
if __name__ == "__main__": | |
y = Youtube("29khjYTOLC8") | |
print y.getinfo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment