static struct movie_list * parse_favorites(json_object *root) { int i; json_object *bookmarks, *bookmark; int bookmarks_count; int status = get_int(root, "status_code"); if (status != 200) { sprintf(last_error, "invalid status %d", status); provider->error_number = 1; return NULL; } struct movie_list *list = calloc(1, sizeof(struct movie_list)); bookmarks = get_data(root, "bookmarks"); bookmarks_count = json_object_array_length(bookmarks); for (i = 0; i < bookmarks_count; i++) { bookmark = json_object_array_get_idx(bookmarks, i); if (bookmark == NULL) { sprintf(last_error, "Cannot get bookmark[%d]", i); provider->error_number = 1; return NULL; } struct movie_entry *e = create_movie(bookmark); append_movie(list, e); } return list; }
void IBBL_LargeFile::build_movie_binaries(bool compile_user_list) { string movie_binary_filename = get_movie_binary_filename(); string movie_offset_filename = get_movie_offset_filename(); ofstream movie_file(movie_binary_filename.c_str(), ofstream::binary); ofstream movie_offset_file(movie_offset_filename.c_str(), ofstream::binary); cout << "Building movie binaries:" << endl << flush; cout << '['; for (int i = 0; i < 70; ++i) cout << " "; cout << "]\n[" << flush; time_t start_time = time(NULL); const int num_movies_div_70 = NUM_MOVIES / 70; int offset = 0; for (int i = 1; i <= NUM_MOVIES; ++i) { if (i % num_movies_div_70 == 0) cout << '*' << flush; append_movie(i, offset, compile_user_list, movie_offset_file, movie_file); } movie_file.flush(); movie_file.close(); movie_offset_file.flush(); movie_offset_file.close(); time_t diff_time = time(NULL) - start_time; cout << ']' << endl; cout << "Movie binaries completed building in " << (diff_time / 60) << ':'; cout.width(2); cout.fill('0'); cout << (diff_time % 60) << endl; cout.width(1); }