MCPcopy
hub / github.com/blacktwin/JBOPS / watched_work

Function watched_work

utility/media_manager.py:450–489  ·  view source on GitHub ↗

Parameters ---------- user (object): User object holding user stats sectionID {int): Library key ratingKey (int): Item rating key -------

(user, sectionID=None, ratingKey=None)

Source from the content-addressed store, hash-verified

448
449
450def watched_work(user, sectionID=None, ratingKey=None):
451 """
452 Parameters
453 ----------
454 user (object): User object holding user stats
455 sectionID {int): Library key
456 ratingKey (int): Item rating key
457
458 -------
459 """
460 count = 25
461 start = 0
462 tt_history = ''
463
464 while True:
465
466 # Getting all watched history for userFrom
467 if sectionID:
468 tt_history = tautulli_server.get_history(user=user.name, section_id=sectionID,
469 start=start, length=count, watched=True)
470 elif ratingKey:
471 tt_history = tautulli_server.get_history(user=user.name, rating_key=ratingKey,
472 start=start, length=count, watched=True)
473
474 if all([tt_history]):
475 start += count
476 for item in tt_history:
477 metadata = Metadata(item)
478 if user.watch.get(metadata.rating_key):
479 user.watch.get(metadata.rating_key).watched_status += 1
480 else:
481 _meta = tautulli_server.get_metadata(metadata.rating_key)
482 if _meta: # rating_key that no longer exists on the Plex server will return blank metadata
483 metadata = Metadata(_meta)
484 user.watch.update({metadata.rating_key: metadata})
485
486 continue
487 elif not all([tt_history]):
488 break
489 start += count
490
491def rating_work(sectionID, operator, value):
492 """

Callers 1

media_manager.pyFile · 0.85

Calls 3

MetadataClass · 0.70
get_historyMethod · 0.45
get_metadataMethod · 0.45

Tested by

no test coverage detected