Example #1
0
def start(req):
    form = util.FieldStorage(req)
    directory = 'YOUR_SAVE_FILE_DIRECTORY'
    api_key = 'YOUR_API_KEY'
    username = form.getfirst('user')
    if not username:
        raise InputDataIncorrect('Specify the username with the \'user\' GET attribute.')

    handling = Handler(directory, api_key, username, 50)
    handling.add_to_watched(form.getfirst('watched'))
    handling.add_video(form.getfirst('add_video'))
    handling.save()
    req.write(handling.build_html())

    if not form.getfirst('watched'):
        handling.update_videos()
        req.write('Refresh the page to see new videos.')
Example #2
0
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import cgi
import cgitb
import sys
from handler import Handler
from fetcher import InputDataIncorrect

cgitb.enable()
directory = "YOUR_SAVE_FILE_DIRECTORY"
api_key = "YOUR_API_KEY"

form = cgi.FieldStorage()
username = form.getvalue("user")
if not username:
    raise InputDataIncorrect("Specify the username with the 'user' GET attribute.")
handling = Handler(directory, api_key, username, 50)
handling.add_to_watched(form.getvalue("watched"))
handling.add_video(form.getvalue("add_video"))
handling.save()
xmlstr = handling.build_html()

f = sys.stdout
f.write("Content-type:text/html\r\n\r\n")
f.write("<!DOCTYPE html>")
f.write(xmlstr)

if not form.getvalue("watched"):
    handling.update_videos()
    print "Refresh the page to see new videos."