コード例 #1
0
def new_user_full_setup(gr_user_id, user_id, goodreads_key):
    shelves = get_shelves(gr_user_id, goodreads_key)
    book_list = get_books_from_shelves(shelves, goodreads_key)
    
    # check if book in library; if not, add to library
    add_book_to_library(book_list)
    
    # add book to UserBook table
    add_userbook_to_userbooks(book_list, gr_user_id)

    # get subjects for all new books
    # subject_dict = fetch_google_books_categories()
    subject_dict2 = fetch_openlib_subject_info()
    # print len(subject_dict)
    print len(subject_dict2)

    # create new book_subjects for new books
    # create_book_subjects(subject_dict)
    create_book_subjects(subject_dict2)

    # generate recommendations
    rated, to_rate = set_up_data(user_id)
    generate_new_user_predictions(rated, to_rate, user_id)

    return "New User Setup Complete"
コード例 #2
0
def new_user_full_setup(gr_user_id, user_id, goodreads_key):
    shelves = get_shelves(gr_user_id, goodreads_key)
    book_list = get_books_from_shelves(shelves, goodreads_key)

    # check if book in library; if not, add to library
    add_book_to_library(book_list)

    # add book to UserBook table
    add_userbook_to_userbooks(book_list, gr_user_id)

    # get subjects for all new books
    # subject_dict = fetch_google_books_categories()
    subject_dict2 = fetch_openlib_subject_info()
    # print len(subject_dict)
    print len(subject_dict2)

    # create new book_subjects for new books
    # create_book_subjects(subject_dict)
    create_book_subjects(subject_dict2)

    # generate recommendations
    rated, to_rate = set_up_data(user_id)
    generate_new_user_predictions(rated, to_rate, user_id)

    return "New User Setup Complete"
コード例 #3
0
                    goodreads_bid=int(goodreads_id),
                    title=title,
                    pages=pages,
                    pub_year=pub_year,
                    publisher=book_info["publisher"],
                    language=book_info["language_code"],
                    original_pub_year=year,
                    goodreads_url=book_info["url"],
                    img_url=book_info["image_url"],
                    get_subjects=1,
                )
                db.session.add(new_book)

    db.session.commit()


###################################
# FUNCTION CALLS

connect_to_db(app)

# get new books
titles_file = sys.argv[1]
book_data_by_title(titles_file)

subject_dict = fetch_google_books_categories()
subject_dict2 = fetch_openlib_subject_info()

create_book_subjects(subject_dict)
create_book_subjects(subject_dict2)
コード例 #4
0
import os
import requests
import pdb
import sys
import xmltodict
from model import Book, Subject, BookSubject, connect_to_db, db

from googlebooks_api import fetch_google_books_categories, create_book_subjects
from openlib_api import fetch_openlib_subject_info

GOOGLE_API_KEY = os.environ['GOOGLE_API_KEY']

# get subjects for new books
subject_dict = fetch_google_books_categories()
subject_dict2 = fetch_openlib_subject_info()

# create new book_subjects for new books
create_book_subjects(subject_dict)
create_book_subjects(subject_dict2)