0

My problem is that the website I built with django has 100s of links to YouTube videos so that we can embed them in our pages.

I don't want to validate that the urls exist in the template because that seems to be a waist of resources. Is there a way to test all of the links once a day and put a flag on them in the MySQL database? This way the bad links wouldn't even be looked at by the templates, which should speed up page load times.

Any ideas would be greatly appreciated.

1 Answers1

0

This would seem to be a duplicate, but since you're new to StackOverflow I'll just say "hi", and welcome.

Go to the post I referenced for some advice on how to approach the problem, and then read up on the python urllib2 docs, and then you should be able to write a small python script outside of django that connects to your database and checks the YouTube API for each URL. Flag the ones that don't exist, and you're golden.

Community
  • 1
  • 1
khoxsey
  • 1,405
  • 9
  • 13
  • sorry about the duplicate, I was so confused that I didn't know what to search for. Many thanks –  Jul 27 '12 at 20:44
  • Not a problem. Always a good idea on SO to use the search box and see if other people have already worked through whatever is giving you troubles. Welcome! – khoxsey Jul 27 '12 at 20:47
  • Okay I have another clarification. How would I do this validation of urls at say 3:00 in the morning each day? –  Jul 28 '12 at 00:07
  • Search for the tag `[cron]` in the upper right of this page. Once you get your task working well from the command line, you can schedule it to run daily. – khoxsey Jul 28 '12 at 16:10