View Single Post
Old 08-18-2016, 04:53 AM  
astronaut x
Too lazy to set a custom title
 
astronaut x's Avatar
 
Industry Role:
Join Date: May 2011
Location: From this www and beyond!
Posts: 4,844
Quote:
Originally Posted by drexl View Post
Well it is easy, in theory at least

1- create a table in MySQL to store perfomers data
2- Python script to load and parse the XML tree (JSON is easier) and save into mysql.
3- a cron job scheduled every minute that runs the above script
4- truncate the table every time to make sure the data is fresh


Python is widely supported and super powerful (it takes a few lines of code to achieve what you want)

Code:
import urllib2

insert_sql_statement = 'INSET INTO ...'
broadcasters = urllib2.urlopen(chaturbate_api_json_url)

try:
  cur.executemany(insert_sql_statement, broadcasters)
except Exception:
  logging.error('oops')
This assume you have an SQL statement that works (try it manually). cur is a MySQLdb cursor (plenty of code samples in google/stackoverflow)

It is very simplistic but it is a functional kick off snippet. It is worth spending some time doing this because you can then reuse this module to import data from everywhere.

Then there is the display part. You can use a php foreach loop. One solutions out of many.
Anyone have an opinion on a time interval to cron the database update? 4 seconds? 10 seconds? Less frequent?

Whats an acceptable amount of time for the update file to take to run? If I just run the chaturbate update, it only takes a few seconds in my browser. However, I also added a livejasmin to it and it takes nearly 15 to 20 seconds in a browser (locally). Maybe its faster running it on a server and setting up cron?

If I have several different cam sites I am updating, should I run them all on the same update file? or should I set and cron each one up using a different update file?

I suppose I will probably answer some of my questions after I move operations to my server. Any friendly advice is greatly appreciated though.
astronaut x is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote