docs: def do_session(self):
          """Restore state from session files."""
          def filenames():
              'Helper'
              for arg in self.args:
                  if os.path.isdir(arg):
                      for name in glob.glob(os.path.join(arg, '*.torrent.rtorrent')):
                          yield name
                  elif arg == '@-':
                      for line in sys.stdin.read().splitlines():
                          if line.strip():
                              yield line.strip()
                  elif arg.startswith('@'):
                      if not os.path.isfile(arg[1:]):
                          self.parser.error("File not found (or not a file): {}".format(arg[1:]))
                      with io.open(arg[1:], encoding='utf-8') as handle:
                          for line in handle:
                              if line.strip():
                                  yield line.strip()
                  else:
                      yield arg
  
          proxy = self.open()
          for filename in filenames():
              # Check filename and extract infohash
              self.LOG.debug("Reading '%s'...", filename)
              match = re.match(r'(?:.+?[-._])?([a-fA-F0-9]{40})(?:[-._].+?)?\.torrent\.rtorrent',
                               os.path.basename(filename))
              if not match:
                  self.LOG.warn("Skipping badly named session file '%s'...", filename)
                  continue
              infohash = match.group(1)
  
              # Read bencoded data
              try:
                  with open(filename, 'rb') as handle:
                      raw_data = handle.read()
                  data = Bunch(bencode.bdecode(raw_data))
              except EnvironmentError as exc:
                  self.LOG.warn("Can't read '%s' (%s)" % (
                      filename, str(exc).replace(": '%s'" % filename, ""),
                  ))
                  continue
  
              ##print(infohash, '=', repr(data))
              if 'state_changed' not in data:
                  self.LOG.warn("Skipping invalid session file '%s'...", filename)
                  continue
  
              # Restore metadata
              was_active = proxy.d.is_active(infohash)
              proxy.d.ignore_commands.set(infohash, data.ignore_commands)
              proxy.d.priority.set(infohash, data.priority)
  
              if proxy.d.throttle_name(infohash) != data.throttle_name:
                  proxy.d.pause(infohash)
                  proxy.d.throttle_name.set(infohash, data.throttle_name)
  
              if proxy.d.directory(infohash) != data.directory:
                  proxy.d.stop(infohash)
                  proxy.d.directory_base.set(infohash, data.directory)
  
              for i in range(5):
                  key = 'custom%d' % (i + 1)
                  getattr(proxy.d, key).set(infohash, data[key])
  
              for key, val in data.custom.items():
                  proxy.d.custom.set(infohash, key, val)
  
              for name in data.views:
                  try:
                      proxy.view.set_visible(infohash, name)
                  except xmlrpclib.Fault as exc:
                      if 'Could not find view' not in str(exc):
                          raise
  
              if was_active and not proxy.d.is_active(infohash):
                  (proxy.d.resume if proxy.d.is_open(infohash) else proxy.d.start)(infohash)
              proxy.d.save_full_session(infohash)
  
              """ TODO:
                  NO public "set" command! 'timestamp.finished': 1503012786,
                  NO public "set" command! 'timestamp.started': 1503012784,
                  NO public "set" command! 'total_uploaded': 0,
              """