def restore_watched(plex, opts):
with open(opts.filepath, '<STR_LIT:r>') as handle:<EOL><INDENT>source = json.load(handle)<EOL><DEDENT>differences = 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>ikey = _item_key(item)<EOL>sval = source.get(skey,{}).get(ikey)<EOL>if sval is None:<EOL><INDENT>raise SystemExit('<STR_LIT>' % ikey)<EOL><DEDENT>if (sval is not None and item.isWatched != sval) and (not opts.watchedonly or sval):<EOL><INDENT>differences[skey][ikey] = {'<STR_LIT>':sval, '<STR_LIT>':item}<EOL><DEDENT><DEDENT><DEDENT>print('<STR_LIT>' % len(differences))<EOL>import pprint; pprint.pprint(differences)<EOL>
Restore watched status from the specified filepath.