Skip to content

Commit

Permalink
Busca do youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoFelipe committed Oct 15, 2010
1 parent 4711264 commit a1cbdaa
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion youtube_search/views.py
@@ -1,11 +1,16 @@
#coding: utf-8
# coding:utf-8

from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect

from youtube_search.forms import SearchForm

import gdata.youtube
import gdata.youtube.service
from xml.dom import minidom
import re


def search(request):
context = RequestContext(request, {'form': SearchForm()})
Expand All @@ -24,3 +29,27 @@ def do_search(request):

return render_to_response('search.html', context)

def SearchVideo(search_terms):

yt_service = gdata.youtube.service.YouTubeService()

# The YouTube API does not currently support HTTPS/SSL access.
yt_service.ssl = False

yt_service.developer_key = 'AI39si68dTO_CHSQaYNalWbwLpFk3kGl14BsKeSrHNiC-n1FttkRBzpAHzkz77pKNdaZMa9s1lispwHXA1XSLJE8g8VgqI2X2Q'
yt_service.client_id = 'youcover'

yt_service = gdata.youtube.service.YouTubeService()
query = gdata.youtube.service.YouTubeVideoQuery()
query.vq = search_terms
query.orderby = 'viewCount'
query.racy = 'include'
feed = yt_service.YouTubeQuery(query)

resultados = []
for entry in feed.entry:
m = re.search('^.*v\/([^?]+)', entry.GetSwfUrl())
resultados.append(m.group(1))

return resultados

0 comments on commit a1cbdaa

Please sign in to comment.