old_contents: from time import sleep
  import json
  from urllib import request
  
  import plugin
  
  defaults = {
      'nkdsu_np_channels': [],
      'nkdsu_interval': 20,
  }
  
  
  class Plugin(plugin.Plugin):
      """
      <pyfoot> is capable of reading an RSS feed into a channel, but it's not
      configurable live. Talk to whoever is operating your local pyfoot instance
      if you have a feed you'd like in a channel.
      """
  
      url = 'http://nkd.su/api'
      np_str = 'now playing\x03# |\x03 \x02%s\x02\x03# :\x03 %s\x03# :\x03 %s'
      unroled_np_str = 'now playing\x03# |\x03 \x02%s\x02\x03# :\x03 %s'
  
      def prepare(self):
          np = self.now_playing()
          if np:
              self.latest_play = np['id']
          else:
              self.latest_play = None
  
      def now_playing(self):
          week = self.get_week()
          if week['playlist']:
              return week['playlist'][-1]['track']
          else:
              return None
  
      def get_week(self):
          bytes = request.urlopen(self.url).read()
          serial = bytes.decode('utf-8')
          return json.loads(serial)
  
      def notify_our_channels(self, np):
          if np['role']:
              np_str = self.np_str % (
                  np['title'], np['role'], np['artist'])
          else:
              np_str = self.unroled_np_str % (
                  np['title'], np['artist'])
  
          for channel in self.conf.conf['nkdsu_np_channels']:
              self.irc.privmsg(channel, np_str)
  
      def run(self):
          while True:
              sleep(self.conf.conf['nkdsu_interval'])
              np = self.now_playing()
  
              if np and np['id'] != self.latest_play:
                  self.notify_our_channels(np)
                  self.latest_play == np['id']
              elif (not np) and (self.latest_play is not None):
                  self.latest_play = None
  
new_contents: from time import sleep
  import json
  from urllib import request
  
  import plugin
  
  defaults = {
      'nkdsu_np_channels': [],
      'nkdsu_interval': 20,
  }
  
  
  class Plugin(plugin.Plugin):
      """
      A plugin that keeps channels updated with the currently playing track on
      <a href="http://thisisthecat.com/index.php/neko-desu">Neko Desu</a>
      according to the <a href="http://nkd.su/help/api">nkd.su api</a>.
      """
  
      url = 'http://nkd.su/api'
      np_str = 'now playing\x03# |\x03 \x02%s\x02\x03# :\x03 %s\x03# :\x03 %s'
      unroled_np_str = 'now playing\x03# |\x03 \x02%s\x02\x03# :\x03 %s'
  
      def prepare(self):
          np = self.now_playing()
          if np:
              self.latest_play = np['id']
          else:
              self.latest_play = None
  
      def now_playing(self):
          week = self.get_week()
          if week['playlist']:
              return week['playlist'][-1]['track']
          else:
              return None
  
      def get_week(self):
          bytes = request.urlopen(self.url).read()
          serial = bytes.decode('utf-8')
          return json.loads(serial)
  
      def notify_our_channels(self, np):
          if np['role']:
              np_str = self.np_str % (
                  np['title'], np['role'], np['artist'])
          else:
              np_str = self.unroled_np_str % (
                  np['title'], np['artist'])
  
          for channel in self.conf.conf['nkdsu_np_channels']:
              self.irc.privmsg(channel, np_str)
  
      def run(self):
          while True:
              sleep(self.conf.conf['nkdsu_interval'])
              np = self.now_playing()
  
              if np and np['id'] != self.latest_play:
                  self.notify_our_channels(np)
                  self.latest_play == np['id']
              elif (not np) and (self.latest_play is not None):
                  self.latest_play = None
  
subject: Fix docstring in nkdsu.