Thank you for the response. I don't believe I explained well enough
exactly what I'm trying to do.

I have table Video with a field vimeo_code. Each vimeo_code has its
own XML file. The XML file I used in my views.py is just a random
video I saw on vimeo. I need to replace the vimeo_code so the XML file
I'm parsing looks like http://vimeo.com/api/v2/video/vimeo_code.xml

Would it be a better idea to do this as a tag filter? Any additional
information for me if I do it that way?

Thanks again, I appreciate your help.
Matt

On Dec 5, 10:07 pm, Sam Lai <samuel....@gmail.com> wrote:
> See inline.
>
> 2009/12/6 sleepjunk <sleepj...@gmail.com>:
>
> > Hello :) I am working on a small video site that allows a user to add
> > a video to the site by submitting a Vimeo.com or Youtube.com URL. I'm
> > trying to display thumbnails without hosting them. For Vimeo videos I
> > need to parse an XML file to find the thumbnail location.
>
> > On my homepage I would like to display the 5 newest videos. As of now
> > I'm displaying every video in the database on the homepage. Each video
> > will have a different thumbnail and XML file to parse. As of right now
> > my "main_page" in my views.py file looks like this:
>
> > def home_page(request):
> >        template = get_template('home_page.html')
> >        videos = Video.objects.all()
>
>           videos_context = [ ]
>           for v in videos:>             feed = 
> urllib.urlopen("http://vimeo.com/api/v2/video/7875440.xml";)
> >             tree = ET.parse(feed)
> >             root = tree.getroot()
> >             vimeo_thumbnail = root.findtext("video/thumbnail_medium")
>
>                videos_context.append( { 'video' : v, 'thumbnail_url' :
> vimeo_thumbnail } )
>
> >        variables = Context({
> >                'videos' : videos_context,
> >        })
> >        output = template.render(variables)
> >        return HttpResponse(output)
>
> > How can I parse a different XML file for every video? Thank you much.
> > Again, I am new and could be going about this completely wrong and
> > gladly accept any feedback you have.
>
> You could try something like the modified view above. It loops through
> every video, gets the thumbnail URL, creates an object containing the
> video model instance and the thumbnail URL, and adds it to the list
> videos_context.
>
> You could then access them in your template like this (assuming
> there's a name field in your Video model):
>
> {% for v in videos %}
> <img src="{{v.thumbnail_url}}">{{ v.video.name }}
> {% endfor %}
>
> The alternate way of doing this is to make a tag filter, 
> seehttp://docs.djangoproject.com/en/dev/howto/custom-template-tags/
>
> HTH,
>
> Sam

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to