Profile Service
The SkoobProfileService lets you modify your Skoob profile by labeling, shelving and rating books.
Example
import os
from pyskoob import SkoobClient
from pyskoob.models.enums import BookStatus
with SkoobClient() as client:
client.auth.login(
email=os.getenv("SKOOB_EMAIL"),
password=os.getenv("SKOOB_PASSWORD"),
)
client.profile.update_book_status(10, BookStatus.READ)
Profile management helpers for authenticated Skoob users.
AsyncSkoobProfileService
Bases: _ProfileServiceMixin, AsyncAuthenticatedService
Asynchronous variant of :class:SkoobProfileService.
Source code in pyskoob/profile.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
add_book_label(edition_id, label)
async
Add a label to a book in the authenticated profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
Edition identifier of the book. |
required |
label
|
BookLabel
|
Label to associate with the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pyskoob/profile.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
change_book_shelf(edition_id, bookshelf)
async
Move a book to a different bookshelf.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
Edition identifier of the book. |
required |
bookshelf
|
BookShelf
|
Destination bookshelf. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pyskoob/profile.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
rate_book(edition_id, rating)
async
Rate a book in the authenticated profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
Edition identifier of the book. |
required |
rating
|
float
|
Rating between |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pyskoob/profile.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
remove_book_label(edition_id)
async
Remove a label from a book in the authenticated profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
Edition identifier of the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pyskoob/profile.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
remove_book_status(edition_id)
async
Remove the user's status for a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
Edition identifier of the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pyskoob/profile.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
update_book_status(edition_id, status)
async
Update the user's status for a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
Edition identifier of the book. |
required |
status
|
BookStatus
|
New status to assign to the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pyskoob/profile.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
SkoobProfileService
Bases: _ProfileServiceMixin, AuthenticatedService
Perform profile-related actions such as labeling and rating books.
Source code in pyskoob/profile.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
__init__(client, auth_service)
Initialize the service with dependencies.
This service requires an authenticated session via
:class:AuthService and is typically used alongside
:class:UserService when manipulating the logged user's bookshelf
and other profile metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
SyncHTTPClient
|
The HTTP client to use for requests. |
required |
auth_service
|
AuthService
|
The authentication service. |
required |
Source code in pyskoob/profile.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
add_book_label(edition_id, label)
Adds a label to a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
The edition ID of the book. |
required |
label
|
BookLabel
|
The label to add. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the label was added successfully, False otherwise. |
Examples:
>>> service.add_book_label(10, BookLabel.FAVORITE)
True
Source code in pyskoob/profile.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
change_book_shelf(edition_id, bookshelf)
Changes the bookshelf of a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
The edition ID of the book. |
required |
bookshelf
|
BookShelf
|
The new bookshelf for the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the bookshelf was changed successfully, False otherwise. |
Examples:
>>> service.change_book_shelf(10, BookShelf.BOOK)
True
Source code in pyskoob/profile.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
rate_book(edition_id, rating)
Rates a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
The edition ID of the book. |
required |
rating
|
float
|
The rating to give to the book (from 0 to 5). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the book was rated successfully. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the rating is not between 0 and 5. |
ProfileError
|
If the service fails to persist the rating. |
Examples:
>>> service.rate_book(10, 4.5)
True
Source code in pyskoob/profile.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
remove_book_label(edition_id)
Removes a label from a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
The edition ID of the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the label was removed successfully, False otherwise. |
Examples:
>>> service.remove_book_label(10)
True
Source code in pyskoob/profile.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
remove_book_status(edition_id)
Removes the status of a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
The edition ID of the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the status was removed successfully, False otherwise. |
Examples:
>>> service.remove_book_status(10)
True
Source code in pyskoob/profile.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
update_book_status(edition_id, status)
Updates the status of a book.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition_id
|
int
|
The edition ID of the book. |
required |
status
|
BookStatus
|
The new status for the book. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the status was updated successfully, False otherwise. |
Examples:
>>> service.update_book_status(10, BookStatus.READ)
True
Source code in pyskoob/profile.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |