def backup_watched(plex, opts):
data = defaultdict(lambda: dict())<EOL>for section in _iter_sections(plex, opts):<EOL><INDENT>print('<STR_LIT>' % section.title)<EOL>skey = section.title.lower()<EOL>for item in _iter_items(section):<EOL><INDENT>if not opts.watchedonly or item.isWatched:<EOL><INDENT>ikey = _item_key(item)<EOL>data[skey][ikey] = item.isWatched<EOL>import pprint; pprint.pprint(item.__dict__); break<EOL><DEDENT><DEDENT><DEDENT>print('<STR_LIT>' % opts.filepath)<EOL>with open(opts.filepath, '<STR_LIT:w>') as handle:<EOL><INDENT>json.dump(dict(data), handle, sort_keys=True, indent=<NUM_LIT:2>)<EOL><DEDENT>
Backup watched status to the specified filepath.