remove datestamp arg. Use datestamp from script
This commit is contained in:
@ -35,7 +35,7 @@ Taultulli > Settings > Notification Agents > New Script > Script Arguments:
|
|||||||
Arguments: --jbop SELECTOR --username {username}
|
Arguments: --jbop SELECTOR --username {username}
|
||||||
--sessionId {session_id} --notify notifierID
|
--sessionId {session_id} --notify notifierID
|
||||||
--grandparent_rating_key {grandparent_rating_key}
|
--grandparent_rating_key {grandparent_rating_key}
|
||||||
--datestamp {datestamp} --unixtime {unixtime}
|
--unixtime {unixtime}
|
||||||
--limit plays=3 --delay 60
|
--limit plays=3 --delay 60
|
||||||
--killMessage 'Your message here.'
|
--killMessage 'Your message here.'
|
||||||
|
|
||||||
@ -45,6 +45,7 @@ Taultulli > Settings > Notification Agents > New Script > Script Arguments:
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
import argparse
|
import argparse
|
||||||
|
from datetime import datetime
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from plexapi.server import PlexServer, CONFIG
|
from plexapi.server import PlexServer, CONFIG
|
||||||
@ -89,6 +90,7 @@ lib_dict = {x.title : x.key for x in plex.library.sections()}
|
|||||||
|
|
||||||
|
|
||||||
SELECTOR = ['watch', 'plays', 'time', 'limit']
|
SELECTOR = ['watch', 'plays', 'time', 'limit']
|
||||||
|
TODAY = datetime.today().strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
|
||||||
def send_notification(subject_text, body_text, notifier_id):
|
def send_notification(subject_text, body_text, notifier_id):
|
||||||
@ -172,7 +174,7 @@ def get_history(username, start_date=None, section_id=None):
|
|||||||
'user': username}
|
'user': username}
|
||||||
|
|
||||||
if start_date:
|
if start_date:
|
||||||
payload['start_date'] = start_date
|
payload['start_date'] = TODAY
|
||||||
|
|
||||||
if section_id:
|
if section_id:
|
||||||
payload['section_id '] = section_id
|
payload['section_id '] = section_id
|
||||||
@ -274,9 +276,6 @@ if __name__ == "__main__":
|
|||||||
'notification.')
|
'notification.')
|
||||||
parser.add_argument('--limit', action='append', type=lambda kv: kv.split("="),
|
parser.add_argument('--limit', action='append', type=lambda kv: kv.split("="),
|
||||||
help='The limit related to the limit selector chosen.')
|
help='The limit related to the limit selector chosen.')
|
||||||
parser.add_argument('--datestamp',
|
|
||||||
help='The date (in date format) when the notification is '
|
|
||||||
'triggered. Most for narrowing to Today\'s history.')
|
|
||||||
parser.add_argument('--grandparent_rating_key', type=int,
|
parser.add_argument('--grandparent_rating_key', type=int,
|
||||||
help='The unique identifier for the TV show or artist.')
|
help='The unique identifier for the TV show or artist.')
|
||||||
parser.add_argument('--unixtime', type=int,
|
parser.add_argument('--unixtime', type=int,
|
||||||
@ -317,19 +316,11 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
message = ''
|
message = ''
|
||||||
|
|
||||||
if opts.datestamp:
|
if opts.section:
|
||||||
if opts.section:
|
section_id = lib_dict[opts.section]
|
||||||
section_id = lib_dict[opts.section]
|
history = get_history(username=opts.username, section_id=section_id)
|
||||||
history = get_history(username=opts.username, start_date=opts.datestamp,
|
|
||||||
section_id=section_id)
|
|
||||||
else:
|
|
||||||
history = get_history(username=opts.username, start_date=opts.datestamp)
|
|
||||||
else:
|
else:
|
||||||
if opts.section:
|
history = get_history(username=opts.username)
|
||||||
section_id = lib_dict[opts.section]
|
|
||||||
history = get_history(username=opts.username, section_id=section_id)
|
|
||||||
else:
|
|
||||||
history = get_history(username=opts.username)
|
|
||||||
|
|
||||||
if opts.jbop == 'watch':
|
if opts.jbop == 'watch':
|
||||||
total_jbop = sum([data['watched_status'] for data in history['data']])
|
total_jbop = sum([data['watched_status'] for data in history['data']])
|
||||||
@ -348,6 +339,7 @@ if __name__ == "__main__":
|
|||||||
.format(opts.jbop, total_jbop, total_limit))
|
.format(opts.jbop, total_jbop, total_limit))
|
||||||
|
|
||||||
if opts.jbop == 'limit' and opts.grandparent_rating_key:
|
if opts.jbop == 'limit' and opts.grandparent_rating_key:
|
||||||
|
history = get_history(username=opts.username, start_date=True)
|
||||||
message = LIMIT_MESSAGE.format(delay=opts.delay)
|
message = LIMIT_MESSAGE.format(delay=opts.delay)
|
||||||
ep_watched = [data['watched_status'] for data in history['data']
|
ep_watched = [data['watched_status'] for data in history['data']
|
||||||
if data['grandparent_rating_key'] == opts.grandparent_rating_key
|
if data['grandparent_rating_key'] == opts.grandparent_rating_key
|
||||||
|
Reference in New Issue
Block a user