def tagVideo(conn, youtubeID, userID, tagName): viddb.insert(conn, 'tags', _ignore = True, youtube_id = youtubeID, tag_name = tagName, user_id = userID)
def createPlaylist(conn, user_id, title, subdomain=None): playlist = {'title':title, 'user_id':uid } if subdomain: playlist['subdomain'] viddb.insert(conn, 'playlists', **playlist)
def addUser(conn, email, password=None): email = conn.escape_string(email) if not password: # Make a temp pw and sent the user a session password = vidauth.generate_secret() salt = vidauth.generate_secret() user_data = { 'salt' : salt, 'email' : email, 'passwd_hash' : vidauth.hash_pass( password, salt ) } try: viddb.insert(conn, 'users', **user_data) except _mysql_exceptions.IntegrityError: raise vidfail.UserExists()
def create_user(conn, subdomain='', origin_network=0): uid = viddb.insert(conn, 'users', {'origin_network':origin_network, 'subdomain':subdomain}) createPlaylist(conn, uid, 'default') return uid
def tset_fbid(conn, fbid, uid=None): cursor = conn.cursor() resp = viddb.load(conn, 'user_foreign_map', ['user_id'], where="network=1 && foreign_id=%s" % fbid) if resp: return resp[0]['user_id'] if not uid: uid = create_user(cursor, subdomain='', origin_network = 1) viddb.insert(cursor, 'user_foreign_map', **{'network':1, 'foreign_id':fbid, 'user_id':uid, '_ignore':True }) return uid
def log(*args, **kwargs): keylist = ['session_id','user_id','data_1','data_2','data_3','data_4','data_5','data_6','text_info'] #[ assert (k in keylist) for k in kwargs.keys() ] conn = viddb.get_conn() viddb.insert(conn, 'log', **kwargs)
def saveVideo(conn, vidInfo): viddb.insert(conn, 'youtube_videos', _ignore = True, **vidInfo)