Beispiel #1
0
def getRecommend(uid):
    result = findAllJson2()
    recomm = getRecommendations(result, uid)
    resultjson = ''
    list1 = []
    dbutils = DBUtils(host, user, password, db, port)
    movie_list = []
    if recomm[0][1]:
        print(recomm[0][1])
        for i in range(5):
            redc = recomm[i][1]
            list1.append(redc)
        for item in list1:
            movie_item = getMovieByName(dbutils, item)
            movie_list.append(movie_item)
    else:
        sql = 'select * from movie where id<6'
        result = dbutils.query(sql)
        for item in result:
            movie_item = {}
            movie_item['id'] = item[0]
            movie_item['movieName'] = item[1].strip()
            movie_item['src'] = item[7]
            movie_item['averating'] = item[9].strip()
            movie_item['playPage'] = item[8]
            movie_item['fileName'] = item[10]
            movie_list.append(movie_item)
    dbutils.close()
    print(movie_list)
    return movie_list
Beispiel #2
0
def getMovieList():
    dbutils = DBUtils(host, user, password, db, port)
    sql = 'select * from movie'
    result = dbutils.query(sql)
    movie_list = []
    for item in result:
        movie_item = {}
        movie_item['id'] = item[0]
        movie_item['movieName'] = item[1].strip()
        movie_item['src'] = item[7]
        movie_item['averating'] = item[9].strip()
        movie_list.append(movie_item)
    dbutils.close()
    return movie_list
Beispiel #3
0
def getHistoryList(uid):
    dbutils = DBUtils(host, user, password, db, port)
    sql = 'select distinct m.id,m.movieName,m.movieType,m.director,m.star,m.release,m.language,m.coverUrl,m.playPage,m.averageScore,' \
          'm.fileName,m.year from movie as m join history ' \
          'as h where h.uid=%d and m.id = h.mid;' % int(uid)
    result = dbutils.query(sql)
    movie_list = []
    for item in result:
        movie_item = {}
        movie_item['id'] = item[0]
        movie_item['movieName'] = item[1]
        movie_item['src'] = item[7]
        movie_item['averating'] = item[9]
        movie_list.append(movie_item)
    dbutils.close()
    return movie_list
Beispiel #4
0
def getMovieById(id):
    dbutils = DBUtils(host, user, password, db, port)
    sql = 'select * from movie where id=%d' % id
    result = dbutils.query(sql)
    movie = {}
    for item in result:
        movie['id'] = item[0]
        movie['name'] = item[1].strip()
        movie['src'] = item[7].strip()
        movie['averating'] = item[9].strip()
        movie['year'] = item[11]
        movie['director'] = item[3].strip()
        movie['star'] = item[4].strip()
        movie['type'] = item[2].strip()
        movie['language'] = item[6].strip()
        movie['release'] = item[5].strip()
        movie['playPage'] = item[8]
        movie['fileName'] = item[10]
    dbutils.close()
    return movie
Beispiel #5
0
def recordScore(uid, score, movieId):
    dbutils = DBUtils(host, user, password, db, port)
    sql = 'insert into history (uid,mid,score,dt) values (%d,%d,%d,now())' % (int(uid),  int(movieId), int(score))
    dbutils.insert(sql)
    dbutils.close()
'''
 @Time    : 2017-2-28 21:20
 @Author  : Moses
 @File    : GetLeagueListing.py
'''

import requests
from utils.DBUtils import DBUtils
# https://wiki.teamfortress.com/wiki/WebAPI/GetLeagueListing
url = "http://api.steampowered.com/IDOTA2Match_570/GetLeagueListing/v1"
# url ="http://api.steampowered.com/IDOTA2Match_<ID>/GetLeagueListing/v1/"
key = "?key=<key>"
params = "&language=zh_cn"

r = requests.get(url + key + params)
rj = r.json()

leagues = rj['result']['leagues']
dbutils = DBUtils()
for l in leagues:
    league_name = l['name']
    league_id = l['leagueid']
    tournament_url = l['tournament_url']
    itemdef = l['itemdef']
    description = l['description']
    dbutils.insertLeagues(
        [league_name, league_id, tournament_url, itemdef, description])
dbutils.close()